Skip to content

Commit 2ee9f55

Browse files
committed
perf: parallel find new name in concatenated code generation
1 parent 1161892 commit 2ee9f55

File tree

15 files changed

+338
-247
lines changed

15 files changed

+338
-247
lines changed

crates/rspack_core/src/concatenated_module.rs

Lines changed: 285 additions & 196 deletions
Large diffs are not rendered by default.

crates/rspack_plugin_javascript/src/plugin/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ impl JsPlugin {
11161116
let context = compilation.options.context.clone();
11171117
let readable_identifier = module.readable_identifier(&context).to_string();
11181118
let splitted_readable_identifier = split_readable_identifier(&readable_identifier);
1119-
let new_name = find_new_name(name, &all_used_names, &splitted_readable_identifier);
1119+
let new_name = find_new_name("", name, &all_used_names, &splitted_readable_identifier);
11201120

11211121
for identifier in refs.iter() {
11221122
let span = identifier.id.span();

packages/rspack-test-tools/tests/__snapshots__/StatsAPI.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Object {
330330
main.js,
331331
],
332332
filteredModules: undefined,
333-
hash: cfe10b32fa6df1ab,
333+
hash: f2679505795e0dc5,
334334
id: 909,
335335
idHints: Array [],
336336
initial: true,
@@ -718,7 +718,7 @@ Object {
718718
errorsCount: 0,
719719
filteredAssets: undefined,
720720
filteredModules: undefined,
721-
hash: de56093745c27934,
721+
hash: 2252b7b6fa0bc796,
722722
modules: Array [
723723
Object {
724724
assets: Array [],

packages/rspack-test-tools/tests/__snapshots__/StatsOutput.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ runtime modules xx KiB
5858
[no exports]
5959
[used exports unknown]
6060
61-
Rspack compiled successfully (cb468c46ad9d7f18)
61+
Rspack compiled successfully (b6a6c74437c67e0f)
6262
`;
6363

6464
exports[`statsOutput statsOutput/builtin-swc-loader-parse-error should print correct stats for 1`] = `

packages/rspack-test-tools/tests/builtinCases/samples/concatenate-modules/__snapshots__/output.snap.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"./index.js": (function () {
55

66
;// CONCATENATED MODULE: ./answer.js
7-
const answer = 103330;
7+
const _0_answer = 103330;
88

99
;// CONCATENATED MODULE: ./index.js
1010

11-
answer;
11+
_0_answer;
1212

13-
function index_answer() {}
13+
function _1_answer() {}
1414

15-
index_answer();
15+
_1_answer();
1616

1717
function test() {}
1818

packages/rspack-test-tools/tests/configCases/library/modern-module-asset-entry/rspack.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ module.exports = {
4747
const jsContent = assets[js].source().toString();
4848

4949
const preseveImport =
50-
/import\simg_namespaceObject\sfrom ['"]\.\/static\/img\/img\.png['"]/.test(
50+
/import\s_0_img_namespaceObject\sfrom ['"]\.\/static\/img\/img\.png['"]/.test(
5151
jsContent
5252
);
5353
assert(preseveImport);
5454
const hasExports =
55-
/export\s{\simg_namespaceObject\sas\sdefault\s}/.test(jsContent);
55+
/export\s{\s_0_img_namespaceObject\sas\sdefault\s}/.test(
56+
jsContent
57+
);
5658
assert(hasExports);
5759
});
5860
});

packages/rspack-test-tools/tests/configCases/library/modern-module-export-char/rspack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
compilation.hooks.afterProcessAssets.tap("testcase", assets => {
3131
const bundle = Object.values(assets)[0]._value;
3232
expect(bundle)
33-
.toContain(`var __webpack_exports__cjsInterop = (foo_default());
33+
.toContain(`var __webpack_exports__cjsInterop = (_1_foo_default());
3434
export { external_module as defaultImport, namedImport, __webpack_exports__cjsInterop as cjsInterop };`);
3535
expect(bundle).toContain(
3636
'import external_module, { namedImport } from "external-module";'

packages/rspack-test-tools/tests/configCases/library/modern-module-force-concaten/__snapshot__/e.js.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj
6262
const foo = 'foo'
6363

6464
// EXTERNAL MODULE: ./e/bar.cjs
65-
var bar = __webpack_require__(997);
66-
var bar_default = /*#__PURE__*/__webpack_require__.n(bar);
65+
var _1_bar = __webpack_require__(997);
66+
var _1_bar_default = /*#__PURE__*/__webpack_require__.n(_1_bar);
6767
;// CONCATENATED MODULE: ./e/index.js
6868

6969

7070

7171

7272

73-
var __webpack_exports__bar = (bar_default());
73+
var __webpack_exports__bar = (_1_bar_default());
7474
export { foo, __webpack_exports__bar as bar };

packages/rspack-test-tools/tests/configCases/library/modern-module-force-concaten/__snapshot__/f.js.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj
6767
/************************************************************************/
6868

6969
// EXTERNAL MODULE: ./f/bar.cjs
70-
var bar = __webpack_require__(441);
71-
var bar_default = /*#__PURE__*/__webpack_require__.n(bar);
70+
var _0_bar = __webpack_require__(441);
71+
var _0_bar_default = /*#__PURE__*/__webpack_require__.n(_0_bar);
7272
;// CONCATENATED MODULE: ./f/foo.js
7373
const foo = 'foo'
7474

7575
;// CONCATENATED MODULE: ./f/index.js
7676

7777

7878

79-
const value = foo + (bar_default())
79+
const value = foo + (_0_bar_default())
8080

8181

8282

packages/rspack-test-tools/tests/configCases/library/modern-module-force-concaten/__snapshot__/g.js.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj
6060
/************************************************************************/
6161

6262
// EXTERNAL MODULE: ./g/foo.js
63-
var foo = __webpack_require__(974);
64-
var foo_default = /*#__PURE__*/__webpack_require__.n(foo);
63+
var _0_foo = __webpack_require__(974);
64+
var _0_foo_default = /*#__PURE__*/__webpack_require__.n(_0_foo);
6565
;// CONCATENATED MODULE: ./g/index.js
6666

6767

6868

6969

70-
var __webpack_exports__foo = (foo_default());
70+
var __webpack_exports__foo = (_0_foo_default());
7171
export { __webpack_exports__foo as foo };

0 commit comments

Comments
 (0)