Skip to content
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: use entrypoint specified in esbuild's metafile as source for building the worker #292

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented Jan 24, 2022

When we pass a non-js file as entry to esbuild, it generates a .js file. (which, that's the whole job of esbuild, haha). So, given <source>/index.ts, it'll generate <destination>/index.js. However, when we try to 'find' the matching file to pass on as an input to creating the actual worker, we try to use the original file name inside the destination directory. At this point, the extension has changed, so it doesn't find the file, and hence we get the error that looks like ENOENT: no such file or directory, open '/var/folders/3f/fwp6mt7n13bfnkd5vl3jmh1w0000gp/T/tmp-61545-4Y5kwyNI8DGU/src/worker.ts'

The actual path to the destination file is actually the key of the block in metafile.outputs that matches the given output.entryPoint, so this PR simply rewrites the logic to use that instead.

fixes #288

…ilding the worker

When we pass a non-js file as entry to esbuild, it generates a `.js` file. (which, that's the whole job of esbuild, haha). So, given `<source>/index.ts`, it'll generate `<destination>/index.js`. However, when we try to 'find' the matching file to pass on as an input to creating the actual worker, we try to use the original file name inside the destination directory. At this point, the extension has changed, so it doesn't find the file, and hence we get the error that looks like `ENOENT: no such file or directory, open '/var/folders/3f/fwp6mt7n13bfnkd5vl3jmh1w0000gp/T/tmp-61545-4Y5kwyNI8DGU/src/worker.ts'`

The actual path to the destination file is actually the key of the block in `metafile.outputs` that matches the given output.entryPoint, so this PR simply rewrites the logic to use that instead.
@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2022

🦋 Changeset detected

Latest commit: e7873df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@threepointone threepointone changed the title fix: use entrypoint specified in esbuuild's metafile as source for building the worker fix: use entrypoint specified in esbuild's metafile as source for building the worker Jan 24, 2022
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix @threepointone - just a small typo in the changeset.

I would really love to see a test to prove this out...
I can write one tomorrow.

.changeset/popular-weeks-march.md Outdated Show resolved Hide resolved
@threepointone threepointone merged commit e5d3690 into main Jan 24, 2022
@threepointone threepointone deleted the fix-publish-entry branch January 24, 2022 21:58
@github-actions github-actions bot mentioned this pull request Jan 24, 2022
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this pull request Jan 25, 2022
petebacondarwin added a commit that referenced this pull request Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish throws missing file errors
2 participants