Skip to content

docs: update v1 upgrade guide - #1817

Open
elecmonkey wants to merge 2 commits into
mainfrom
elecmonkey/docs-upgrade-v1
Open

docs: update v1 upgrade guide#1817
elecmonkey wants to merge 2 commits into
mainfrom
elecmonkey/docs-upgrade-v1

Conversation

@elecmonkey

Copy link
Copy Markdown
Member

Summary

  • Document the default createRequire() parsing behavior in Rslib v1 and how to opt out.
  • Add v1 upgrade guidance for ESM resource modules, including new URL() assets, Web Workers, and WebAssembly.

@elecmonkey
elecmonkey marked this pull request as ready for review August 1, 2026 14:29
Copilot AI review requested due to automatic review settings August 1, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the v0-to-v1 upgrade guides to document Rslib v1’s default createRequire() parsing behavior and the new/changed handling of ESM resource modules (assets via new URL(), Web Workers, and WebAssembly).

Changes:

  • Document how to restore v0.x behavior by disabling Rspack’s module.parser.javascript.createRequire.
  • Add upgrade guidance for ESM resource module handling: new URL() assets, Web Workers, and WebAssembly (wasm.mode: 'preserve' for format: 'esm' + bundle: false).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
website/docs/zh/guide/upgrade/v0-to-v1.mdx Adds Chinese v1 upgrade guidance for createRequire() parsing and ESM resource modules.
website/docs/en/guide/upgrade/v0-to-v1.mdx Adds English v1 upgrade guidance for createRequire() parsing and ESM resource modules.


对于 `format: 'esm'` 且 `bundle: false` 的产物,Rslib v1 默认使用 [`wasm.mode: 'preserve'`](/config/lib/wasm#wasmmode)。生成的 JavaScript 会保留 `.wasm` import,`.wasm` 文件会保留原始文件名,并按照源代码中的目录结构输出。

`bundle: true` 时的行为保持不变。对于 `bundle: false`,Rslib v0.x 无法生成可用的 WASM 产物;Rslib v1 默认通过 `preserve` 模式支持这一场景。使用 `preserve` 模式时,需要确保下游构建工具或目标运行时支持 WebAssembly ESM Integration。更多信息请参考 [WASM 指南](/guide/advanced/wasm)。

For output with `format: 'esm'` and `bundle: false`, Rslib v1 uses [`wasm.mode: 'preserve'`](/config/lib/wasm#wasmmode) by default. The generated JavaScript preserves `.wasm` imports, while `.wasm` files retain their original filenames and source directory structure in the output.

The behavior for `bundle: true` is unchanged. With `bundle: false`, Rslib v0.x could not generate usable WASM output; Rslib v1 supports this scenario through `preserve` mode by default. When using `preserve` mode, ensure that the downstream bundler or target runtime supports WebAssembly ESM Integration. See the [WASM guide](/guide/advanced/wasm) for details.
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

Successfully merging this pull request may close these issues.

2 participants