Skip to content

Conversation

@fi3ework
Copy link
Member

@fi3ework fi3ework commented Jan 5, 2026

Summary

  • Add preserveNewUrl option to RstestPlugin (default: false)

  • When enabled, matched new URL expression like new URL("*.wasm", import.meta.url) expressions are preserved in output, this is useful in testing case, especially for following code:

    const path = new URL('a.wasm')
    const binary = fs.readFile(path)
  • Non-matched assets continue to be processed normally

Related links

Checklist

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

Copilot AI review requested due to automatic review settings January 5, 2026 13:03
@fi3ework fi3ework requested a review from LingyuCoder as a code owner January 5, 2026 13:03
@netlify
Copy link

netlify bot commented Jan 5, 2026

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit dbeab46
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/695cf661c5c7bb00084e1b13
😎 Deploy Preview https://deploy-preview-12632--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Jan 5, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @fi3ework, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the RstestPlugin by introducing a preserveNewUrl option. This feature provides finer control over how new URL() expressions are handled, specifically allowing WebAssembly module URLs to remain un-transformed in the output. This is crucial for scenarios where the original URL structure for WASM assets is required, while ensuring that other asset types continue to benefit from RstestPlugin's standard processing.

Highlights

  • New Option preserveNewUrl: Introduced a new preserveNewUrl option to the RstestPlugin configuration, which defaults to false.
  • WASM URL Preservation: When preserveNewUrl is enabled, new URL("*.wasm", import.meta.url) expressions are no longer processed by RstestPlugin, ensuring they remain untouched in the output bundle.
  • Normal Asset Processing: Non-WASM assets (e.g., .png) referenced via new URL() continue to be processed normally by the RstestPlugin, even when preserveNewUrl is active.
  • Test Coverage: Added new test cases to validate the behavior of the preserveNewUrl option for both WASM and non-WASM assets, ensuring correct functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 a preserveNewUrl option to the RstestPlugin to keep new URL("*.wasm", import.meta.url) expressions untouched in the output, which is useful for testing scenarios where the original URL construction needs to be preserved (e.g., when using fs.readFile() with WASM paths in tests).

Key Changes:

  • Added preserveNewUrl boolean option (default: false) to RstestPlugin configuration
  • Implemented custom URL dependency template that skips transformation for .wasm files when the option is enabled
  • Non-wasm assets continue to be processed normally through the standard URL dependency template

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/rspack_plugin_rstest/src/url_dependency.rs New module implementing RstestUrlDependencyTemplate that conditionally preserves wasm URL expressions
crates/rspack_plugin_rstest/src/plugin.rs Updated to conditionally register the custom URL dependency template when preserve_new_url is enabled
crates/rspack_plugin_rstest/src/lib.rs Added the new url_dependency module to the plugin exports
crates/rspack_binding_api/src/rstest.rs Added preserve_new_url field to the plugin options with default value of false
crates/node_binding/napi-binding.d.ts Added TypeScript type definition for the new optional preserveNewUrl field
tests/rspack-test/configCases/rstest/new-url-wasm/* New test case validating that wasm URLs are preserved while non-wasm URLs are transformed normally

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

📦 Binary Size-limit

Comparing dbeab46 to chore: release v1.7.1 (#12638) by harpsealjs

❌ Size increased by 3.13KB from 47.87MB to 47.87MB (⬆️0.01%)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 5, 2026

CodSpeed Performance Report

Merging #12632 will not alter performance

Comparing rst-url (dbeab46) with main (2ed1576)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a preserveNewUrl option to the RstestPlugin to prevent new URL("*.wasm", ...) expressions from being processed, which is useful in testing environments. The implementation is clean, adding a new dependency template to conditionally handle URL dependencies, and is well-supported by new tests. My feedback includes a minor cleanup to remove an unused import.

@fi3ework fi3ework changed the title feat(rstest): add preserveNewUrl option to keep wasm new URL untouched feat(rstest): add preserveNewUrl option to keep new URL untouched Jan 5, 2026
@fi3ework fi3ework requested a review from 9aoy January 5, 2026 13:28
9aoy
9aoy previously approved these changes Jan 6, 2026
@fi3ework
Copy link
Member Author

fi3ework commented Jan 6, 2026

@copilot fix the failed CI.

Copy link
Contributor

Copilot AI commented Jan 6, 2026

@fi3ework I've opened a new pull request, #12640, to work on those changes. Once the pull request is ready, I'll request review from you.

@fi3ework fi3ework enabled auto-merge (squash) January 7, 2026 03:39
@fi3ework fi3ework merged commit 25a4021 into main Jan 7, 2026
76 of 79 checks passed
@fi3ework fi3ework deleted the rst-url branch January 7, 2026 03:44
LingyuCoder pushed a commit that referenced this pull request Jan 8, 2026
…2632)

* feat(rstest): add preserveNewUrl option to keep new URL untouched

* fix: format Rust code with rustfmt
hardfist added a commit that referenced this pull request Jan 23, 2026
* react_server_components transform

* fix: ReactServerComponents

* ReactServerComponentPlugin

* fix: rspack_loader_swc Wtf8Atom

* feat: ReactServerComponentPlugin

* feat: ServerEntryModules

* exports_info

* temp

* feat: import with layer

* fix: before pass

* export ReactServerComponentsPlugin

* ServerEntries

* feat: client_entry_loader

* feat: client compiler

* feat: traverse_modules

* feat: ClientReferenceManifestPlugin

* feat: react_server_components layer

* fix ReactClientPlugin

* fix: ClientReferenceManifestPlugin

* refactor: rename to ReactServerPlugin

* remove eager

* feat: collect entry css files

* feat: use server-entry

* server actions transform

* feat: action_entry_loader

* collect server_actions

* temp

* manifest-loader

* RscManifestRuntimeModule

* fix: build_server_consumer_module_map

* fix: entry_css_files

* feat: record_entry_js_files

* refactor: entry_css_files

* fix: entry js files and entry css files should concat prefix

* remove unused code

* chore: rename loader and plugin

* fix: Coordinator

* fix: entry js files prevent hot-module files from being included

* clear PLUGIN_STATE_BY_COMPILER_ID

* feat: add_include client action

* feat: prev_server_component_hashs

* fix: client compiler not rebuild right

* export RSC_LAYERS_NAMES

* fix: remove import with layer

* refactor: rsc_pass

* refactor: rsc_meta

* refactor: to_module_ref

* fix: cargo clippy

* fix: lint and spelling

* api changed

* refactor: use get_module_resource

* fix: ts type

* fix: compiler watching

* feat: check should_inject_ssr_modules

* fix: only invalidate client after proxying client watching

* fix: client module chunks should exclude hot module replacement js

* chore: rename coordinator mod

* fix: collect_component_info_from_entry_denendency

* fix: panic in create_client_entries

* fix: browser action

* rm ACTION_BROWSER layer

* fix: use atomic ref

* refactor client plugin

* fix: should handle compile failed

* chore: rm unused print

* fix: use server-entry mix use client

* feat: ensureServerActions

* fix: RSC_HOT_RELOADER

* refactor: create_client_entries

* fix: encryptActionBoundArgs and decryptActionBoundArgs

* fix: should collect entry css files in after_process_assets hook

* fix: with concat module

* chore(deps): update patch npm dependencies (#12647)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update patch crates (#12646)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: run ci/eco-ci/eco-benchmark on v2 branch (#12650)

* fix: report error when access module_graph in loader (#12639)

* fix: report error when access module_graph in loader

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat(rstest): add preserveNewUrl option to keep new URL untouched (#12632)

* feat(rstest): add preserveNewUrl option to keep new URL untouched

* fix: format Rust code with rustfmt

* fix(lint): enable @typescript-eslint/await-thenable rule (#12644)

* fix(lint): enable await-thenable rule and fix violation

- Enable @typescript-eslint/await-thenable rule (off -> error)
- Remove unnecessary await on syncTraceEvent() which returns void

* Update rslint.json

---------

Co-authored-by: neverland <jait.chen@foxmail.com>

* fix: cargo clippy

* refactor: rm RSC_HOT_RELOADER runtime module

* fix: lint check

* refactor: rename RscPluginLayers

* warp rsc in namespace

* fix: rsc client plugin

* fix: cargo fmt

* add next.js Copyright

* fix: user can change fileDependencies in done hook

* chore: add comments

* fix: cargo fmt

* rm ustr dependencies

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: harpsealjs <lingyucoder@gmail.com>
Co-authored-by: hardfist <yangjianzju@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Max <fi3ework@gmail.com>
Co-authored-by: Tu Shaokun <53142663+tt-a1i@users.noreply.github.com>
Co-authored-by: neverland <jait.chen@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature 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