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
5 changes: 5 additions & 0 deletions .changeset/smooth-parents-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rslib/core': patch
---

fix: the moduleIds should be deterministic if the env is production and format is mf
1 change: 1 addition & 0 deletions packages/core/src/cli/mf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function changeEnvToDev(rsbuildConfig: RsbuildConfig) {
rspack: {
optimization: {
nodeEnv: 'development',
moduleIds: 'named',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ const composeFormatConfig = ({
},
// can not set nodeEnv to false, because mf format should build shared module.
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
optimization: {
nodeEnv: 'production',
moduleIds: 'deterministic',
},
},
},
Expand Down
1 change: 1 addition & 0 deletions scripts/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ vnode
watchpack
webm
webp
unstubAllEnvs
33 changes: 16 additions & 17 deletions tests/integration/minify/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,28 @@ test('minify is enabled by default in mf format, bar and baz should be minified'
const fixturePath = join(__dirname, 'mf/default');
const { mfExposeEntry } = await buildAndGetResults({ fixturePath });
// biome-ignore format: snapshot
expect(mfExposeEntry).toMatchInlineSnapshot(`""use strict";(globalThis["default_minify"]=globalThis["default_minify"]||[]).push([["249"],{"../../__fixtures__/src/index.ts":function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{foo:function(){return foo}});const foo=()=>{}}}]);"`);
expect(mfExposeEntry).toMatchInlineSnapshot(`""use strict";(globalThis["default_minify"]=globalThis["default_minify"]||[]).push([["249"],{163:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{foo:function(){return foo}});const foo=()=>{}}}]);"`);
});

test('minify is disabled by the user, bar and baz should not be minified', async () => {
const fixturePath = join(__dirname, 'mf/config');
const { mfExposeEntry } = await buildAndGetResults({ fixturePath });
expect(mfExposeEntry).toMatchInlineSnapshot(`
""use strict";
(globalThis['disable_minify'] = globalThis['disable_minify'] || []).push([["249"], {
"../../__fixtures__/src/index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
foo: function() { return foo; }
});
const foo = ()=>{};
const bar = ()=>{};
const baz = ()=>{
return bar();
};

expect(mfExposeEntry).toMatchInlineSnapshot(`""use strict";
(globalThis['disable_minify'] = globalThis['disable_minify'] || []).push([["249"], {
"163": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
foo: function() { return foo; }
});
const foo = ()=>{};
const bar = ()=>{};
const baz = ()=>{
return bar();
};


}),
}),

}]);"
`);
}]);"`);
});
Loading