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.
Related issue (if exists)
it's a common question that users import node globals like
process
andBuffer
like #2994, so we provide an example about how to provide custom shims to avoid runtime error on browser.Summary
馃 Generated by Copilot at 8959d13
This pull request adds a new example project that shows how to use the
rspack
CLI tool to bundle and serve JavaScript modules that use Node.js globals in the browser. It creates a simple app that renders a message with the answer to life, the universe, and everything.Walkthrough
馃 Generated by Copilot at 8959d13
index.html
and inject it into the output bundle with the html plugin (link, link)package.json
and reference the rspack CLI tool as a workspace package (link)rspack.config.js
and use the provide plugin to shim the process global variable with a custom module (link, link)src/index.js
and import the util and answer modules (link, link, link)src/answer.js
and export it (link)src/util.js
and demonstrate how the provide plugin works (link, link)