-
Notifications
You must be signed in to change notification settings - Fork 742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix path resolution in Pages esbuild #773
Conversation
…o the esbuild file which then used a relative path back from pages. When ran inside a test would get a resolved absolute path to the template from "pages/pages/functions/template-workers.ts
🦋 Changeset detectedLatest commit: 743d6b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2117932154/npm-package-wrangler-773 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/773/npm-package-wrangler-773 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2117932154/npm-package-wrangler-773 dev path/to/script.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for @GregBrimble to confirm this is a bug before we merge.
Oh interesting... https://github.com/cloudflare/wrangler2/runs/5892721660?check_suite_focus=true#step:6:942 This implies that the original pathing is correct, at least for how that e2e test is setup. |
entryPoints: [ | ||
path.resolve(__dirname, "../pages/functions/template-worker.ts"), | ||
], | ||
entryPoints: [path.resolve(__dirname, "./template-worker.ts")], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if __dirname
returns a different result once this file is bundled?
In other words, the __dirname
at runtime is packages/wrangler/wrangler-dist
rather than the source path of packages/wrangler/pages/functions
.
I note that this only came up when we were trying to run Pages in a Wrangler unit test, which is not bundled...
Tests are failing too, expected? |
Is this linked to an issue? The existing template resolution is working fine for me in prod and for local dev. This new one doesn't. |
So the problem is that esbuild does not rewrite |
I will take a look into implementing the plugin in this PR then we can discuss adding it to ESBuild for the Wrangler side as well. |
Any update on this @JacobMGEvans ? |
Not at the moment. |
Closing due to work in #860 |
fix: the pathing for the template was resolving using
__dirname
into the esbuild file which then used a relative path back from pages. When ran inside a test would get a resolved absolute path to the template from "pages/pages/functions/template-workers.ts