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

feature req: pass through Webpack "magic comments" inside Worker constructor #2439

Closed
benjamind opened this issue Aug 3, 2022 · 6 comments
Closed

Comments

@benjamind
Copy link

Feature Request

In #309 support was added to pass through Webpack "magic comments" in import(/* webpackChunkName: "foo" */ './foo.js') style statements. Webpack also supports these chunk name comments in the new Worker constructor syntax:

new Worker(
        /* webpackChunkName: "foo-worker" */ new URL(
            "../foo-worker.ts",
            import.meta.url
        ),
        { type: "module" }
    );

It would be great if this was supported in ESbuild for the same reasons, allowing the esbuild-loader project to work correctly for workers.

@evanw
Copy link
Owner

evanw commented Dec 3, 2022

Is this behavior documented anywhere? I don't see it on https://webpack.js.org/api/module-methods/#magic-comments or https://webpack.js.org/guides/web-workers/. If it's indeed not documented, then it'd be good for someone to document it so people can find out about them.

@evanw evanw closed this as completed in 48a4ae5 Dec 3, 2022
@privatenumber
Copy link
Contributor

privatenumber commented Dec 4, 2022

@benjamind
Copy link
Author

Thanks for the fix!

@privatenumber
Copy link
Contributor

@benjamind Where did you learn about Webpack's magic comments support in Workers?

@benjamind
Copy link
Author

We only encountered it after trying to adopt esbuild in our workflow for TS stripping. I dug into the webpack source to confirm the behavior should have worked. Agree they should publicly document this feature.

@privatenumber
Copy link
Contributor

Would you mind opening an issue with Webpack to document the behavior?

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

No branches or pull requests

3 participants