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
9 changes: 9 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ const composeFormatConfig = ({
}

const config: EnvironmentConfig = {
output: {
minify: {
jsOptions: {
minimizerOptions: {
module: true,
},
},
},
},
tools: {
rspack: {
module: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
"mangle": false,
"minify": false,
"module": true,
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/iife/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ test('iife', async () => {
});

globalThis.globalHelper = { helperName: 'HELPER_NAME' };
require(entryFiles.iife);
expect(globalThis.addPrefix('ok')).toBe('production: HELPER_NAMEok');
await import(entryFiles.iife);
expect(globalThis.addPrefix('ok')).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/iife/dist/iife/index.mjs - production: HELPER_NAMEok"`,
);
delete process.env.NODE_ENV;
delete globalThis.globalHelper;

Expand All @@ -24,7 +26,7 @@ test('iife', async () => {
"(()=>{
"use strict";
const external_globalHelper_namespaceObject = globalThis.globalHelper;
const addPrefix = (prefix, str, env)=>\`\${env}: \${prefix}\${str}\`;
const addPrefix = (prefix, str, env)=>\`\${import.meta.url} - \${env}: \${prefix}\${str}\`;
globalThis.addPrefix = (str)=>addPrefix(external_globalHelper_namespaceObject.helperName, str, "production");
})();
"
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/iife/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default defineConfig({
generateBundleIifeConfig({
output: {
externals: ['globalHelper'],
filename: {
js: '[name].mjs',
},
},
}),
],
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/iife/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const addPrefix = (prefix: string, str: string, env: string) =>
`${env}: ${prefix}${str}`;
const addPrefix = (prefix: string, str: string, env: string): string => {
return `${import.meta.url} - ${env}: ${prefix}${str}`;
};

export { addPrefix };
Loading