Skip to content

Commit b257e4b

Browse files
fi3eworkTimeless0911
authored andcommitted
fix: adapt @rspack/core 1.1.9 (#602)
1 parent b6b21b3 commit b257e4b

File tree

19 files changed

+218
-219
lines changed

19 files changed

+218
-219
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
},
6565
"pnpm": {
6666
"overrides": {
67+
"@rspack/core": "npm:@rspack-canary/[email protected]",
6768
"zx>@types/node": "-"
6869
}
6970
}

packages/core/src/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ const composeFormatConfig = ({
543543
optimization: {
544544
concatenateModules: true,
545545
sideEffects: 'flag',
546+
avoidEntryIife: true,
546547
},
547548
output: {
548549
module: true,

packages/core/tests/__snapshots__/config.test.ts.snap

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
189189
"__filename": false,
190190
},
191191
"optimization": {
192+
"avoidEntryIife": true,
192193
"concatenateModules": true,
193194
"sideEffects": "flag",
194195
},

pnpm-lock.yaml

+100-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/alias/__snapshots__/index.test.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
2020
`;
2121

2222
exports[`source.alias 3`] = `
23-
"import * as __WEBPACK_EXTERNAL_MODULE__a_js__ from "./a.js";
24-
console.info(__WEBPACK_EXTERNAL_MODULE__a_js__.a);
23+
"import * as __WEBPACK_EXTERNAL_MODULE__a_js_256e6de1__ from "./a.js";
24+
console.info(__WEBPACK_EXTERNAL_MODULE__a_js_256e6de1__.a);
2525
"
2626
`;
2727

tests/integration/alias/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test('source.alias', async () => {
2828

2929
// bundleless mode
3030
expect(indexBundlelessEsmContent).toContain(
31-
'import * as __WEBPACK_EXTERNAL_MODULE__a_js__ from "./a.js";',
31+
'import * as __WEBPACK_EXTERNAL_MODULE__a_js_256e6de1__ from "./a.js";',
3232
);
3333
expect(indexBundlelessCjsContent).toContain(
3434
'const external_a_cjs_namespaceObject = require("./a.cjs");',

tests/integration/asset/__snapshots__/index.test.ts.snap

+24-24
Large diffs are not rendered by default.

tests/integration/auto-external/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('auto external sub path should works', async () => {
2929
'import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react"',
3030
);
3131
expect(entries.esm).toContain(
32-
'import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime"',
32+
'import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime"',
3333
);
3434

3535
expect(entries.cjs).toContain(

tests/integration/bundle-false/__snapshots__/index.test.ts.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`svgr in bundleless 1`] = `
4-
"import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
4+
"import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
55
import "react";
6-
const SvgLogo = (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("svg", {
6+
const SvgLogo = (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("svg", {
77
xmlns: "http://www.w3.org/2000/svg",
88
viewBox: "0 0 841.9 595.3",
99
...props,
10-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("g", {
10+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("g", {
1111
fill: "#61DAFB",
1212
children: [
13-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("path", {
13+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("path", {
1414
d: "M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3m-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9m-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9m32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1M421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32m-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24q7.05 12 14.4 23.4M420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32m-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9m-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6s22.9-35.6 58.3-50.6c8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2M310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7m237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1m38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6M320.8 78.4"
1515
}),
16-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("circle", {
16+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("circle", {
1717
cx: 420.9,
1818
cy: 296.5,
1919
r: 45.7
2020
}),
21-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("path", {
21+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("path", {
2222
d: "M520.5 78.1"
2323
})
2424
]

tests/integration/bundle-false/index.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ test('auto add js extension for relative import', async () => {
8989

9090
// basic esm
9191
for (const importer of [
92-
'import * as __WEBPACK_EXTERNAL_MODULE__bar_js__ from "./bar.js";',
93-
'import * as __WEBPACK_EXTERNAL_MODULE__baz_js_js__ from "./baz.js.js";',
94-
'import * as __WEBPACK_EXTERNAL_MODULE__foo_js__ from "./foo.js";',
95-
'import * as __WEBPACK_EXTERNAL_MODULE__qux_js__ from "./qux.js";',
92+
'import * as __WEBPACK_EXTERNAL_MODULE__bar_js_69b41beb__ from "./bar.js";',
93+
'import * as __WEBPACK_EXTERNAL_MODULE__baz_js_js_7d4e15b7__ from "./baz.js.js";',
94+
'import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";',
95+
'import * as __WEBPACK_EXTERNAL_MODULE__qux_js_3d9e4fc9__ from "./qux.js";',
9696
]) {
9797
expect(Object.values(contents.esm0!)[3]).toContain(importer);
9898
}
@@ -109,10 +109,10 @@ test('auto add js extension for relative import', async () => {
109109

110110
// using `autoExtension: false` along with `output.filename.js` - esm
111111
for (const importer of [
112-
'import * as __WEBPACK_EXTERNAL_MODULE__bar_mjs__ from "./bar.mjs";',
113-
'import * as __WEBPACK_EXTERNAL_MODULE__baz_js_mjs__ from "./baz.js.mjs";',
114-
'import * as __WEBPACK_EXTERNAL_MODULE__foo_mjs__ from "./foo.mjs";',
115-
'import * as __WEBPACK_EXTERNAL_MODULE__qux_mjs__ from "./qux.mjs";',
112+
'import * as __WEBPACK_EXTERNAL_MODULE__bar_mjs_89c909f2__ from "./bar.mjs";',
113+
'import * as __WEBPACK_EXTERNAL_MODULE__baz_js_mjs_09565ba6__ from "./baz.js.mjs";',
114+
'import * as __WEBPACK_EXTERNAL_MODULE__foo_mjs_ccdcdd01__ from "./foo.mjs";',
115+
'import * as __WEBPACK_EXTERNAL_MODULE__qux_mjs_83952e37__ from "./qux.mjs";',
116116
]) {
117117
expect(Object.values(contents.esm1!)[3]).toContain(importer);
118118
}

tests/integration/external-helpers/__snapshots__/index.test.ts.snap

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`should external @swc/helpers when externalHelpers is true 1`] = `
4-
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from "@swc/helpers/_/_class_call_check";
5-
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from "@swc/helpers/_/_create_class";
4+
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__ from "@swc/helpers/_/_class_call_check";
5+
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__ from "@swc/helpers/_/_create_class";
66
var src_rslib_entry_FOO = /*#__PURE__*/ function() {
77
"use strict";
88
function FOO() {
9-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__._)(this, FOO);
9+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__._)(this, FOO);
1010
}
11-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__._)(FOO, [
11+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__._)(FOO, [
1212
{
1313
key: "bar",
1414
get: function() {}
@@ -21,14 +21,14 @@ export { src_rslib_entry_FOO as default };
2121
`;
2222

2323
exports[`should external @swc/helpers when externalHelpers is true 2`] = `
24-
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from "@swc/helpers/_/_class_call_check";
25-
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from "@swc/helpers/_/_create_class";
24+
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__ from "@swc/helpers/_/_class_call_check";
25+
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__ from "@swc/helpers/_/_create_class";
2626
var src_rslib_entry_FOO = /*#__PURE__*/ function() {
2727
"use strict";
2828
function FOO() {
29-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__._)(this, FOO);
29+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__._)(this, FOO);
3030
}
31-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__._)(FOO, [
31+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__._)(FOO, [
3232
{
3333
key: "bar",
3434
get: function() {}
@@ -111,14 +111,14 @@ export { src_rslib_entry_FOO as default };
111111
`;
112112

113113
exports[`should respect user override externalHelpers config 2`] = `
114-
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from "@swc/helpers/_/_class_call_check";
115-
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from "@swc/helpers/_/_create_class";
114+
"import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__ from "@swc/helpers/_/_class_call_check";
115+
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__ from "@swc/helpers/_/_create_class";
116116
var src_rslib_entry_FOO = /*#__PURE__*/ function() {
117117
"use strict";
118118
function FOO() {
119-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__._)(this, FOO);
119+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check_f500f6c3__._)(this, FOO);
120120
}
121-
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__._)(FOO, [
121+
(0, __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class_63e94838__._)(FOO, [
122122
{
123123
key: "bar",
124124
get: function() {}

tests/integration/externals/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('auto externalize Node.js built-in modules when `output.target` is "node"',
1616

1717
for (const external of [
1818
'import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs"',
19-
'import * as __WEBPACK_EXTERNAL_MODULE_node_assert__ from "node:assert"',
19+
'import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert"',
2020
'import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react"',
2121
'import * as __WEBPACK_EXTERNAL_MODULE_bar__ from "bar"',
2222
'module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("foo");',

tests/integration/format/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ test('esm', async () => {
1414
}
1515
`);
1616
expect(entries.esm).toMatchInlineSnapshot(`
17-
"import * as __WEBPACK_EXTERNAL_MODULE_node_url__ from "node:url";
18-
const packageDirectory = __WEBPACK_EXTERNAL_MODULE_node_url__["default"].fileURLToPath(new URL('.', import.meta.url));
17+
"import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
18+
const packageDirectory = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__["default"].fileURLToPath(new URL('.', import.meta.url));
1919
const foo = 'foo';
2020
export { foo, packageDirectory };
2121
"

tests/integration/minify/index.test.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ describe('minify config', () => {
77
const fixturePath = join(__dirname, 'default');
88
const { entries } = await buildAndGetResults({ fixturePath });
99
expect(entries.esm).toMatchInlineSnapshot(`
10-
"/*! For license information please see index.js.LICENSE.txt */
11-
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
12-
/*! Legal Comment */ const foo = ()=>{};
13-
const Button = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)('button', {});
14-
export { Button, foo };
15-
"
16-
`);
10+
"/*! For license information please see index.js.LICENSE.txt */
11+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
12+
/*! Legal Comment */ const foo = ()=>{};
13+
const Button = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)('button', {});
14+
export { Button, foo };
15+
"
16+
`);
1717
});
1818

1919
test('minify is disabled, nothing will be stripped', async () => {
2020
const fixturePath = join(__dirname, 'config/disabled');
2121
const { entries } = await buildAndGetResults({ fixturePath });
2222
expect(entries.esm).toMatchInlineSnapshot(`
23-
"import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
23+
"import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2424
25-
;// CONCATENATED MODULE: external "react/jsx-runtime"
25+
;// CONCATENATED MODULE: external "react/jsx-runtime"
2626
27-
;// CONCATENATED MODULE: ../../__fixtures__/src/index.ts?__rslib_entry__
28-
/*! Legal Comment */
29-
const foo = ()=>{};
30-
const bar = ()=>{};
31-
const baz = ()=>{
32-
return bar();
33-
};
34-
// normal comment
35-
const Button = ()=>/*#__PURE__*/ (0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)('button', {});
27+
;// CONCATENATED MODULE: ../../__fixtures__/src/index.ts?__rslib_entry__
28+
/*! Legal Comment */
29+
const foo = ()=>{};
30+
const bar = ()=>{};
31+
const baz = ()=>{
32+
return bar();
33+
};
34+
// normal comment
35+
const Button = ()=>/*#__PURE__*/ (0,__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)('button', {});
3636
37-
export { Button, foo };
38-
"
39-
`);
37+
export { Button, foo };
38+
"
39+
`);
4040
});
4141

4242
test('minify is enabled, only preserve some comments and annotations', async () => {

0 commit comments

Comments
 (0)