-
-
Notifications
You must be signed in to change notification settings - Fork 746
fix: support import.meta.url as the only param of new Worker()
#12095
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
Conversation
✅ Deploy Preview for rspack canceled.
|
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.
Pull Request Overview
This PR adds support for new Worker(import.meta.url) pattern (without wrapping in new URL()), enables webpack comment magic (like webpackIgnore and webpackChunkName) for worker imports, and fixes several test cases that were previously skipped.
Key changes:
- Added handling for direct
import.meta.urlusage in Worker constructors (not wrapped innew URL()) - Implemented support for webpack magic comments (
webpackIgnore,webpackChunkName) in worker imports - Updated test configurations to conditionally define
MODULE_FLAGbased on output module type
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_plugin_javascript/src/parser_plugin/worker_plugin.rs |
Added logic to handle import.meta.url directly in Worker constructors and process webpack magic comments for ignoring/naming worker chunks |
crates/rspack_plugin_javascript/src/parser_plugin/url_plugin.rs |
Extended get_url_request to support new URL(import.meta.url) with single argument |
crates/rspack_plugin_javascript/src/dependency/worker/mod.rs |
Added need_new_url field to conditionally wrap worker imports with new URL() during code generation |
tests/rspack-test/configCases/worker/self-import/rspack.config.js |
Added DefinePlugin configuration to inject MODULE_FLAG for different build configurations |
tests/rspack-test/configCases/worker/self-import/index.js |
Updated Worker constructor calls to use MODULE_FLAG as the type option |
tests/rspack-test/configCases/worker/self-import/test.filter.js |
Removed test filter as the feature is now implemented |
tests/rspack-test/configCases/worker/node-worker-esm/rspack.config.js |
Changed target from node14 to node and added trailing comma |
tests/rspack-test/configCases/worker/node-worker-esm/test.filter.js |
Removed test filter as the feature is now implemented |
tests/rspack-test/configCases/worker/ignore/test.filter.js |
Removed test filter as the feature is now implemented |
tests/rspack-test/configCases/url/dynamic-template-literals-expr/test.filter.js |
Updated TODO message to clarify missing support for webpackComments in Worker context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 2.50KB from 47.86MB to 47.86MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12095 will not alter performanceComparing Summary
|
Summary
support
new Worker(new URL(import.meta.url))andnew Worker(import.meta.url)Related links
Checklist