|
1 | 1 | const copy = require('rollup-plugin-copy');
|
2 | 2 |
|
| 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 | + |
3 | 28 | module.exports = (rollupConfig, projectOptions) => {
|
4 | 29 | rollupConfig.external = [/@module-federation/];
|
| 30 | + |
5 | 31 | if (Array.isArray(rollupConfig.output)) {
|
6 | 32 | rollupConfig.output = rollupConfig.output.map((c) => ({
|
7 | 33 | ...c,
|
8 |
| - manualChunks: (id) => { |
9 |
| - debugger; |
10 |
| - if (id.includes('@swc/helpers')) { |
11 |
| - return 'polyfills'; |
12 |
| - } |
13 |
| - }, |
| 34 | + manualChunks: (id) => manualChunks(id, projectOptions), |
| 35 | + hoistTransitiveImports: false, |
14 | 36 | }));
|
15 | 37 | } else {
|
16 | 38 | rollupConfig.output = {
|
17 | 39 | ...rollupConfig.output,
|
18 |
| - manualChunks: (id) => { |
19 |
| - debugger; |
20 |
| - if (id.includes('@swc/helpers')) { |
21 |
| - return 'polyfills'; |
22 |
| - } |
23 |
| - }, |
| 40 | + manualChunks: (id) => manualChunks(id, projectOptions), |
| 41 | + hoistTransitiveImports: false, |
24 | 42 | };
|
25 | 43 | }
|
26 | 44 |
|
|
0 commit comments