Skip to content

Commit e1836c3

Browse files
committed
chore(build): use advanced ESM
1 parent 5582839 commit e1836c3

File tree

11 files changed

+138
-443
lines changed

11 files changed

+138
-443
lines changed

packages/core/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export default defineConfig({
3030
{
3131
format: 'esm',
3232
syntax: ['node 18.12.0'],
33+
experiments: {
34+
advancedEsm: true,
35+
},
3336
dts: {
3437
bundle: false,
3538
// Only use tsgo in local dev for faster build, disable it in CI until it's more stable

packages/core/setupRstestTests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ expect.addSnapshotSerializer(
2323
escapeDoubleQuotes: false,
2424
transformCLR: false,
2525
},
26+
replace: [
27+
{
28+
match: /@rspack(?:-canary)?\/core/g,
29+
mark: '<RSPACK_CORE>',
30+
},
31+
],
2632
}),
2733
);
2834

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3822,7 +3822,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
38223822
use: [
38233823
/* config.module.rule('css').use('mini-css-extract') */
38243824
{
3825-
loader: '<ROOT>/node_modules/<PNPM_INNER>/@rspack/core/dist/cssExtractLoader.js'
3825+
loader: '<ROOT>/node_modules/<PNPM_INNER>/<RSPACK_CORE>/dist/cssExtractLoader.js'
38263826
},
38273827
/* config.module.rule('css').use('css') */
38283828
{

packages/create-rslib/rslib.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export default defineConfig({
88
{
99
format: 'esm',
1010
syntax: ['node 18.12.0'],
11+
experiments: {
12+
advancedEsm: true,
13+
},
1114
},
1215
],
1316
plugins: [

pnpm-lock.yaml

Lines changed: 107 additions & 425 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ onlyBuiltDependencies:
1818

1919
overrides:
2020
'zx>@types/node': '-'
21+
'@rspack/core': 'npm:@rspack-canary/core@1.6.2-canary-ae75bb5c-20251110081755'
2122

2223
strictPeerDependencies: false
2324
autoInstallPeers: false

tests/integration/entry/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test('multiple entry bundle', async () => {
5656
"<ROOT>/tests/integration/entry/multiple/dist/cjs/shared.cjs",
5757
],
5858
"esm": [
59-
"<ROOT>/tests/integration/entry/multiple/dist/esm/359.js",
59+
"<ROOT>/tests/integration/entry/multiple/dist/esm/994.js",
6060
"<ROOT>/tests/integration/entry/multiple/dist/esm/foo.js",
6161
"<ROOT>/tests/integration/entry/multiple/dist/esm/index.js",
6262
"<ROOT>/tests/integration/entry/multiple/dist/esm/shared.js",
@@ -86,7 +86,7 @@ test('multiple entry bundle', async () => {
8686
// cspell:disable
8787
if (process.env.ADVANCED_ESM) {
8888
expect(index).toMatchInlineSnapshot(`
89-
"import { shared } from "./359.js";
89+
"import { shared } from "./994.js";
9090
const foo = shared('foo');
9191
const src_text = ()=>\`\${foo} \${shared('index')}\`;
9292
export { src_text as text };
@@ -109,7 +109,7 @@ test('multiple entry bundle', async () => {
109109
// cspell:disable
110110
if (process.env.ADVANCED_ESM) {
111111
expect(foo).toMatchInlineSnapshot(`
112-
"import { shared } from "./359.js";
112+
"import { shared } from "./994.js";
113113
const foo = shared('foo');
114114
export { foo };
115115
"

tests/integration/minify/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('minify config (mf)', () => {
7474
const { mfExposeEntry } = await buildAndGetResults({ fixturePath });
7575
// biome-ignore format: snapshot
7676
expect(mfExposeEntry).toMatchInlineSnapshot(`
77-
"/*! For license information please see __federation_expose_default_export.81c80bb4.js.LICENSE.txt */
78-
"use strict";(globalThis["default_minify"]=globalThis["default_minify"]||[]).push([["525"],{5:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{Button:()=>Button,foo:()=>foo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(491);/*! Legal Comment */const foo=()=>{};const Button=()=>/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{})}}]);"
77+
"/*! For license information please see __federation_expose_default_export.fd95b46e.js.LICENSE.txt */
78+
"use strict";(globalThis["default_minify"]=globalThis["default_minify"]||[]).push([["525"],{807:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{Button:()=>Button,foo:()=>foo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(491);/*! Legal Comment */const foo=()=>{};const Button=()=>/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{})}}]);"
7979
`);
8080
});
8181

@@ -86,7 +86,7 @@ describe('minify config (mf)', () => {
8686
expect(mfExposeEntry).toMatchInlineSnapshot(`
8787
""use strict";
8888
(globalThis["disable_minify"] = globalThis["disable_minify"] || []).push([["525"], {
89-
5: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
89+
807: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9090
__webpack_require__.r(__webpack_exports__);
9191
__webpack_require__.d(__webpack_exports__, {
9292
Button: () => (Button),

tests/integration/output/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('output config', () => {
1818
const esm0BaseNames = (files.esm0 ?? []).map((p) => basename(p));
1919
const esm1BaseNames = (files.esm1 ?? []).map((p) => basename(p));
2020

21-
expect(esm0BaseNames.some((n) => /^0~188\.js$/.test(n))).toBeTruthy();
22-
expect(esm1BaseNames.some((n) => /^1~188\.js$/.test(n))).toBeTruthy();
21+
expect(esm0BaseNames.some((n) => /^0~159\.js$/.test(n))).toBeTruthy();
22+
expect(esm1BaseNames.some((n) => /^1~159\.js$/.test(n))).toBeTruthy();
2323
});
2424

2525
test('should prefix index for multi-compiler builds (with filename)', async () => {
@@ -41,10 +41,10 @@ describe('output config', () => {
4141
const esm1BaseNames = (files.esm1 ?? []).map((p) => basename(p));
4242

4343
expect(
44-
esm0BaseNames.some((n) => /^0~188\.\w+\.js$/.test(n)),
44+
esm0BaseNames.some((n) => /^0~159\.\w+\.js$/.test(n)),
4545
).toBeTruthy();
4646
expect(
47-
esm1BaseNames.some((n) => /^1~188\.\w+\.js$/.test(n)),
47+
esm1BaseNames.some((n) => /^1~159\.\w+\.js$/.test(n)),
4848
).toBeTruthy();
4949
});
5050

@@ -64,13 +64,13 @@ describe('output config', () => {
6464
);
6565

6666
expect(
67-
files.esm0!.some((n) => /static1\/js\/0~188\.js$/.test(n)),
67+
files.esm0!.some((n) => /static1\/js\/0~159\.js$/.test(n)),
6868
).toBeTruthy();
6969
expect(
7070
files.esm0!.some((n) => /static1\/js\/lib1\.js$/.test(n)),
7171
).toBeTruthy();
7272
expect(
73-
files.esm0!.some((n) => /static2\/js\/1~188\.\w+\.js$/.test(n)),
73+
files.esm0!.some((n) => /static2\/js\/1~159\.\w+\.js$/.test(n)),
7474
).toBeTruthy();
7575
expect(
7676
files.esm0!.some((n) => /static2\/js\/lib2\.\w+\.js$/.test(n)),

tests/integration/resolve/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ test('resolve false', async () => {
2323
expect(entries.esm).toMatchInlineSnapshot(`
2424
"import { __webpack_require__ } from "./rslib-runtime.js";
2525
__webpack_require__.add({
26-
"?b5d4": function() {}
26+
"?27ce": function() {}
2727
});
28-
const util_ignored_ = __webpack_require__("?b5d4");
28+
const util_ignored_ = __webpack_require__("?27ce");
2929
var util_ignored__default = /*#__PURE__*/ __webpack_require__.n(util_ignored_);
3030
console.log('foo:', util_ignored__default());
3131
console.log('bar: ', "bar");
@@ -34,7 +34,7 @@ test('resolve false', async () => {
3434
} else {
3535
expect(
3636
entries.esm,
37-
).toContain(`var util_ignored_ = __webpack_require__("?b5d4");
37+
).toContain(`var util_ignored_ = __webpack_require__("?27ce");
3838
var util_ignored_default = /*#__PURE__*/ __webpack_require__.n(util_ignored_);
3939
console.log('foo:', util_ignored_default());
4040
console.log('bar: ', "bar");`);

0 commit comments

Comments
 (0)