fix: support import.meta.url as the only param of new Worker()#12095
Merged
LingyuCoder merged 1 commit intomainfrom Nov 5, 2025
Merged
fix: support import.meta.url as the only param of new Worker()#12095LingyuCoder merged 1 commit intomainfrom
import.meta.url as the only param of new Worker()#12095LingyuCoder merged 1 commit intomainfrom
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
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.
Contributor
📦 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
|
ahabhgk
approved these changes
Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
support
new Worker(new URL(import.meta.url))andnew Worker(import.meta.url)Related links
Checklist