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

feat: Add "worker" export in package.json #400

Merged
merged 1 commit into from Apr 26, 2022

Conversation

desjoerd
Copy link
Contributor

To support setting the environment in esbuild to "worker" when building for cloudflare it cannot match the worker exports. Adding the "worker" export would resolve this.

Adding a "worker" export type is logical as the cloudflare environment has the same capabilities as a "worker like webworker serviceworker.

@desjoerd
Copy link
Contributor Author

desjoerd commented Apr 26, 2022

Some background for this PR, I am using this package with Remix run and want to deploy it to cloudflare. When building remix run it resolves all packages by searching for the "worker" export. I think it's a good convention especially when considering that cloudflare has (almost) the same api and capabilities as a serviceworker.

Please let me know what you think, and whether I need to update/change something :).

@panva
Copy link
Owner

panva commented Apr 26, 2022

@desjoerd thank you, can you point me to the documentation for this build target?

@desjoerd
Copy link
Contributor Author

Wow, quick response 👍 . I dived a little bit more into the documentation of esbuild, they didn't mention platform "worker" explicitly. Found some references from this issue: evanw/esbuild#1189 (comment)

Looks like webpack has support for it as defined here: https://webpack.js.org/guides/package-exports/#target-environment and I think remix run (where I want to use this library ;)) mimics this when setting the environment to cloudflare-workers.

@panva panva merged commit c58c80a into panva:main Apr 26, 2022
@desjoerd desjoerd deleted the feature/worker-exports branch April 26, 2022 09:40
@github-actions github-actions bot locked and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants