Skip to content

Commit 2580dd7

Browse files
authored
perf(webpack-bundler-runtime): bundle sdk into output to help treeshake (#3519)
1 parent 35d925b commit 2580dd7

File tree

9 files changed

+258
-290
lines changed

9 files changed

+258
-290
lines changed

.changeset/loud-papayas-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/webpack-bundler-runtime': patch
3+
---
4+
5+
perf(webpack-bundler-runtime): bundle sdk into output to help treeshake

packages/dts-plugin/src/server/utils/log.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createLogger } from '@module-federation/sdk';
22
import * as log4js from 'log4js';
3-
import chalk from 'chalk';
43
import { MF_SERVER_IDENTIFIER } from '../constant';
54
import { ActionKind } from '../message/Action';
65

packages/sdk/src/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
SEPARATOR,
77
MANIFEST_EXT,
88
} from './constant';
9-
import { logger } from './logger';
109
import { getProcessEnv } from './env';
1110

1211
const LOG_CATEGORY = '[ Federation Runtime ]';
@@ -233,7 +232,6 @@ function isRequiredVersion(str: string): boolean {
233232

234233
export {
235234
parseEntry,
236-
logger,
237235
decodeName,
238236
encodeName,
239237
composeKeyWithSeparator,

packages/webpack-bundler-runtime/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
"import": "./dist/constant.esm.mjs",
3838
"require": "./dist/constant.cjs.js"
3939
},
40-
"./container": {
41-
"import": "./dist/container.esm.mjs",
42-
"require": "./dist/container.cjs.js"
43-
},
4440
"./*": "./*"
4541
},
4642
"typesVersions": {

packages/webpack-bundler-runtime/project.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
"tsConfig": "packages/webpack-bundler-runtime/tsconfig.lib.json",
1616
"assets": [],
1717
"project": "packages/webpack-bundler-runtime/package.json",
18-
"compiler": "swc",
18+
"compiler": "tsc",
1919
"format": ["cjs", "esm"],
2020
"additionalEntryPoints": [
21-
"packages/webpack-bundler-runtime/src/constant.ts",
22-
"packages/webpack-bundler-runtime/src/container.ts"
21+
"packages/webpack-bundler-runtime/src/constant.ts"
2322
],
2423
"generatePackageJson": false,
2524
"rollupConfig": "packages/webpack-bundler-runtime/rollup.config.js"

packages/webpack-bundler-runtime/rollup.config.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
11
const copy = require('rollup-plugin-copy');
22

3-
function manualChunks(id, projectOptions) {
4-
// if (id.includes(projectOptions.main)) {
5-
// return;
6-
// }
7-
// if (
8-
// projectOptions.additionalEntryPoints.some((entryPoint) => {
9-
// return id.includes(entryPoint);
10-
// })
11-
// ) {
12-
// return;
13-
// }
14-
if (id.includes('@swc/helpers')) {
15-
return 'polyfills';
16-
}
17-
// if (!id.includes('webpack-bundler-runtime')) {
18-
// return;
19-
// }
20-
// if (id.endsWith('types.ts')) {
21-
// return;
22-
// }
23-
// if (id.endsWith('.d.ts')) return;
24-
// const cName = id.split('src/')[1].replace('/', '_').replace('.ts', '');
25-
// return cName;
26-
}
27-
283
module.exports = (rollupConfig, projectOptions) => {
29-
rollupConfig.external = [/@module-federation/];
4+
rollupConfig.external = [/@module-federation\/runtime/];
305

316
if (Array.isArray(rollupConfig.output)) {
327
rollupConfig.output = rollupConfig.output.map((c) => ({
338
...c,
34-
manualChunks: (id) => manualChunks(id, projectOptions),
359
hoistTransitiveImports: false,
3610
entryFileNames:
3711
c.format === 'esm'
@@ -45,7 +19,6 @@ module.exports = (rollupConfig, projectOptions) => {
4519
} else {
4620
rollupConfig.output = {
4721
...rollupConfig.output,
48-
manualChunks: (id) => manualChunks(id, projectOptions),
4922
hoistTransitiveImports: false,
5023
entryFileNames:
5124
rollupConfig.output.format === 'esm'
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
export const FEDERATION_SUPPORTED_TYPES = ['script'];
2-
3-
export { ENCODE_NAME_PREFIX } from '@module-federation/sdk';

0 commit comments

Comments
 (0)