Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

support new Worker(new URL(import.meta.url)) and new Worker(import.meta.url)

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 5, 2025 10:51
@netlify
Copy link

netlify bot commented Nov 5, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit aa386a7
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/690b2c2f31b9db0008313716

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 5, 2025
Copy link
Contributor

Copilot AI left a 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.url usage in Worker constructors (not wrapped in new URL())
  • Implemented support for webpack magic comments (webpackIgnore, webpackChunkName) in worker imports
  • Updated test configurations to conditionally define MODULE_FLAG based 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.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

📦 Binary Size-limit

Comparing aa386a7 to chore: release v1.6.1 (#12092) by Hana

❌ Size increased by 2.50KB from 47.86MB to 47.86MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #12095 will not alter performance

Comparing fix/worker-only-meta-url (aa386a7) with main (11814b5)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder requested a review from ahabhgk November 5, 2025 12:23
@LingyuCoder LingyuCoder enabled auto-merge (squash) November 5, 2025 12:31
@LingyuCoder LingyuCoder merged commit ad5a143 into main Nov 5, 2025
53 checks passed
@LingyuCoder LingyuCoder deleted the fix/worker-only-meta-url branch November 5, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants