mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -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]
|
[boolean] [default: true]
|
||||||
--browser Use the browser module resolutions in package.json and adds
|
--browser Use the browser module resolutions in package.json and adds
|
||||||
'browser' to exportConditions if it is not present so browser
|
'browser' to exportConditions if it is not present so browser
|
||||||
conditionals in exports are applied.
|
conditionals in exports are applied.
|
||||||
[boolean] [default: false]
|
|
||||||
--inlineDynamicImports Inlines dynamic imports, allowing for code-splitting
|
|
||||||
regardless of format.
|
|
||||||
[boolean] [default: false]
|
[boolean] [default: false]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const config = ({
|
|||||||
mode = 'production',
|
mode = 'production',
|
||||||
format = 'umd',
|
format = 'umd',
|
||||||
cwd = process.cwd(),
|
cwd = process.cwd(),
|
||||||
argv = { sourcemap: true, inlineDynamicImports: false },
|
argv = { sourcemap: true, codeSplit: false },
|
||||||
core,
|
core,
|
||||||
behaviours: {
|
behaviours: {
|
||||||
getExternal = getExternalDefault,
|
getExternal = getExternalDefault,
|
||||||
@@ -113,6 +113,27 @@ const config = ({
|
|||||||
external.push('@nebula.js/stardust');
|
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 {
|
return {
|
||||||
input: {
|
input: {
|
||||||
onwarn(warning, warn) {
|
onwarn(warning, warn) {
|
||||||
@@ -172,17 +193,7 @@ const config = ({
|
|||||||
],
|
],
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
},
|
},
|
||||||
output: {
|
output: output(),
|
||||||
banner,
|
|
||||||
format,
|
|
||||||
inlineDynamicImports: argv.inlineDynamicImports,
|
|
||||||
file: path.resolve(dir, outputFile),
|
|
||||||
name: outputName,
|
|
||||||
sourcemap,
|
|
||||||
globals: {
|
|
||||||
'@nebula.js/stardust': 'stardust',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ const options = {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
inlineDynamicImports: {
|
codeSplit: {
|
||||||
description:
|
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',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user