Skip to content

Conversation

@fi3ework
Copy link
Member

@fi3ework fi3ework commented Sep 9, 2024

Summary

This PR will simplify "module" external type's runtime like below. When building a package with Rspack, it can be ensured that external modules can be tree shaken.

Changes summary:

  1. only changed "module" external type.
  2. variable name folding theoretically should not cause any potential problems, as there is currently no module remapping, it merely eliminates intermediate variables.
  3. MultiTaskProcessor could handle function config.
// --- before ---
import * as __WEBPACK_EXTERNAL_MODULE_react_alias__ from "react-alias";

;// CONCATENATED MODULE: external "react-alias"

const external_react_alias_namespaceObject = __WEBPACK_EXTERNAL_MODULE_react_alias__;

;// CONCATENATED MODULE: ./src/main.mjs

function main() {
    (0,external_react_alias_namespaceObject.createElement)('div');
}

// --- after ---
import * as __WEBPACK_EXTERNAL_MODULE_react_alias__ from "react-alias";

;// CONCATENATED MODULE: external "react-alias"

;// CONCATENATED MODULE: ./src/main.mjs

function main() {
    (0,__WEBPACK_EXTERNAL_MODULE_react_alias__.createElement)('div');
}

Checklist

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

@netlify
Copy link

netlify bot commented Sep 9, 2024

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 7eeb9cc
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66ea699caad7a10008d9db35
😎 Deploy Preview https://deploy-preview-7839--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 site configuration.

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Sep 9, 2024
@fi3ework fi3ework force-pushed the optimize-external-concat branch 7 times, most recently from b0c3b18 to 0182d0d Compare September 13, 2024 06:46
@fi3ework fi3ework marked this pull request as ready for review September 13, 2024 06:57
@fi3ework fi3ework force-pushed the optimize-external-concat branch from c4d856b to 7eeb9cc Compare September 18, 2024 05:48
@fi3ework fi3ework merged commit 0a89e43 into web-infra-dev:main Sep 18, 2024
@fi3ework fi3ework deleted the optimize-external-concat branch September 18, 2024 11:38
JSerFeng pushed a commit that referenced this pull request Sep 29, 2024
* fix: avoid import external module re-assigin in concatenation

* test: add test
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants