mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 09:48:18 -05:00
feat: add option codeSplit to allow for code-splitting (#1476)
* feat: add option codeSplit to allow for code-splitting * fix: review comments * fix: remove documentation for experimental feature
This commit is contained in:
@@ -30,10 +30,7 @@ Options:
|
||||
[boolean] [default: true]
|
||||
--browser Use the browser module resolutions in package.json and adds
|
||||
'browser' to exportConditions if it is not present so browser
|
||||
conditionals in exports are applied.
|
||||
[boolean] [default: false]
|
||||
--inlineDynamicImports Inlines dynamic imports, allowing for code-splitting
|
||||
regardless of format.
|
||||
conditionals in exports are applied.
|
||||
[boolean] [default: false]
|
||||
```
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const config = ({
|
||||
mode = 'production',
|
||||
format = 'umd',
|
||||
cwd = process.cwd(),
|
||||
argv = { sourcemap: true, inlineDynamicImports: false },
|
||||
argv = { sourcemap: true, codeSplit: false },
|
||||
core,
|
||||
behaviours: {
|
||||
getExternal = getExternalDefault,
|
||||
@@ -113,6 +113,27 @@ const config = ({
|
||||
external.push('@nebula.js/stardust');
|
||||
}
|
||||
|
||||
const output = () => {
|
||||
const outputConfig = {
|
||||
banner,
|
||||
format,
|
||||
name: outputName,
|
||||
sourcemap,
|
||||
globals: {
|
||||
'@nebula.js/stardust': 'stardust',
|
||||
},
|
||||
};
|
||||
if (!argv.codeSplit || format === 'umd') {
|
||||
outputConfig.file = path.resolve(dir, outputFile);
|
||||
} else {
|
||||
outputConfig.dir = path.resolve(dir, outputFile.split('/')[0]);
|
||||
}
|
||||
if (argv.codeSplit && format === 'umd') {
|
||||
outputConfig.inlineDynamicImports = true;
|
||||
}
|
||||
return outputConfig;
|
||||
};
|
||||
|
||||
return {
|
||||
input: {
|
||||
onwarn(warning, warn) {
|
||||
@@ -172,17 +193,7 @@ const config = ({
|
||||
],
|
||||
].filter(Boolean),
|
||||
},
|
||||
output: {
|
||||
banner,
|
||||
format,
|
||||
inlineDynamicImports: argv.inlineDynamicImports,
|
||||
file: path.resolve(dir, outputFile),
|
||||
name: outputName,
|
||||
sourcemap,
|
||||
globals: {
|
||||
'@nebula.js/stardust': 'stardust',
|
||||
},
|
||||
},
|
||||
output: output(),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ const options = {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
inlineDynamicImports: {
|
||||
codeSplit: {
|
||||
description:
|
||||
'In Rollup, inlineDynamicImports option is a configuration option that allows code-splitting while still creating a single bundle.',
|
||||
'Sets output.dir instead of output.file for code-splitting builds. Sets inlineDynamicImports for umd builds to avoid throwing errors.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user