Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export default defineConfig({
{
format: 'esm',
syntax: ['node 18.12.0'],
experiments: {
advancedEsm: true,
},
dts: {
bundle: false,
// Only use tsgo in local dev for faster build, disable it in CI until it's more stable
Expand Down
6 changes: 6 additions & 0 deletions packages/core/setupRstestTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ expect.addSnapshotSerializer(
escapeDoubleQuotes: false,
transformCLR: false,
},
replace: [
{
match: /@rspack(?:-canary)?\/core/g,
mark: '<RSPACK_CORE>',
},
],
}),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3822,7 +3822,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
use: [
/* config.module.rule('css').use('mini-css-extract') */
{
loader: '<ROOT>/node_modules/<PNPM_INNER>/@rspack/core/dist/cssExtractLoader.js'
loader: '<ROOT>/node_modules/<PNPM_INNER>/<RSPACK_CORE>/dist/cssExtractLoader.js'
},
/* config.module.rule('css').use('css') */
{
Expand Down
3 changes: 3 additions & 0 deletions packages/create-rslib/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default defineConfig({
{
format: 'esm',
syntax: ['node 18.12.0'],
experiments: {
advancedEsm: true,
},
},
],
plugins: [
Expand Down
532 changes: 107 additions & 425 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ onlyBuiltDependencies:

overrides:
'zx>@types/node': '-'
'@rspack/core': 'npm:@rspack-canary/core@1.6.2-canary-ae75bb5c-20251110081755'

strictPeerDependencies: false
autoInstallPeers: false
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/entry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('multiple entry bundle', async () => {
"<ROOT>/tests/integration/entry/multiple/dist/cjs/shared.cjs",
],
"esm": [
"<ROOT>/tests/integration/entry/multiple/dist/esm/359.js",
"<ROOT>/tests/integration/entry/multiple/dist/esm/994.js",
"<ROOT>/tests/integration/entry/multiple/dist/esm/foo.js",
"<ROOT>/tests/integration/entry/multiple/dist/esm/index.js",
"<ROOT>/tests/integration/entry/multiple/dist/esm/shared.js",
Expand Down Expand Up @@ -86,7 +86,7 @@ test('multiple entry bundle', async () => {
// cspell:disable
if (process.env.ADVANCED_ESM) {
expect(index).toMatchInlineSnapshot(`
"import { shared } from "./359.js";
"import { shared } from "./994.js";
const foo = shared('foo');
const src_text = ()=>\`\${foo} \${shared('index')}\`;
export { src_text as text };
Expand All @@ -109,7 +109,7 @@ test('multiple entry bundle', async () => {
// cspell:disable
if (process.env.ADVANCED_ESM) {
expect(foo).toMatchInlineSnapshot(`
"import { shared } from "./359.js";
"import { shared } from "./994.js";
const foo = shared('foo');
export { foo };
"
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/minify/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ describe('minify config (mf)', () => {
const { mfExposeEntry } = await buildAndGetResults({ fixturePath });
// biome-ignore format: snapshot
expect(mfExposeEntry).toMatchInlineSnapshot(`
"/*! For license information please see __federation_expose_default_export.81c80bb4.js.LICENSE.txt */
"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",{})}}]);"
"/*! For license information please see __federation_expose_default_export.fd95b46e.js.LICENSE.txt */
"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",{})}}]);"
`);
});

Expand All @@ -86,7 +86,7 @@ describe('minify config (mf)', () => {
expect(mfExposeEntry).toMatchInlineSnapshot(`
""use strict";
(globalThis["disable_minify"] = globalThis["disable_minify"] || []).push([["525"], {
5: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
807: (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
Button: () => (Button),
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/output/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('output config', () => {
const esm0BaseNames = (files.esm0 ?? []).map((p) => basename(p));
const esm1BaseNames = (files.esm1 ?? []).map((p) => basename(p));

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

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

expect(
esm0BaseNames.some((n) => /^0~188\.\w+\.js$/.test(n)),
esm0BaseNames.some((n) => /^0~159\.\w+\.js$/.test(n)),
).toBeTruthy();
expect(
esm1BaseNames.some((n) => /^1~188\.\w+\.js$/.test(n)),
esm1BaseNames.some((n) => /^1~159\.\w+\.js$/.test(n)),
).toBeTruthy();
});

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

expect(
files.esm0!.some((n) => /static1\/js\/0~188\.js$/.test(n)),
files.esm0!.some((n) => /static1\/js\/0~159\.js$/.test(n)),
).toBeTruthy();
expect(
files.esm0!.some((n) => /static1\/js\/lib1\.js$/.test(n)),
).toBeTruthy();
expect(
files.esm0!.some((n) => /static2\/js\/1~188\.\w+\.js$/.test(n)),
files.esm0!.some((n) => /static2\/js\/1~159\.\w+\.js$/.test(n)),
).toBeTruthy();
expect(
files.esm0!.some((n) => /static2\/js\/lib2\.\w+\.js$/.test(n)),
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/resolve/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ test('resolve false', async () => {
expect(entries.esm).toMatchInlineSnapshot(`
"import { __webpack_require__ } from "./rslib-runtime.js";
__webpack_require__.add({
"?b5d4": function() {}
"?27ce": function() {}
});
const util_ignored_ = __webpack_require__("?b5d4");
const util_ignored_ = __webpack_require__("?27ce");
var util_ignored__default = /*#__PURE__*/ __webpack_require__.n(util_ignored_);
console.log('foo:', util_ignored__default());
console.log('bar: ', "bar");
Expand All @@ -34,7 +34,7 @@ test('resolve false', async () => {
} else {
expect(
entries.esm,
).toContain(`var util_ignored_ = __webpack_require__("?b5d4");
).toContain(`var util_ignored_ = __webpack_require__("?27ce");
var util_ignored_default = /*#__PURE__*/ __webpack_require__.n(util_ignored_);
console.log('foo:', util_ignored_default());
console.log('bar: ', "bar");`);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/shims/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ describe('CJS shims', () => {
const dynamicUrl = await dynamicImportMetaUrl();
const { content: dynamicContent } = queryContent(
contents.cjs!,
/cjs\/1~7\.cjs/,
/cjs\/1~368\.cjs/,
);

expect(importMetaUrl).toBe(fileUrl);
expect(dynamicUrl).toBe(fileUrl.replace('index.cjs', '1~7.cjs'));
expect(dynamicUrl).toBe(fileUrl.replace('index.cjs', '1~368.cjs'));
expect(requiredModule).toBe('ok');

for (const code of [cjsCode, dynamicContent]) {
Expand Down
Loading