rollup 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +41 -39
- package/dist/es/rollup.js +3 -2
- package/dist/es/shared/rollup.js +1254 -867
- package/dist/es/shared/watch.js +21 -177
- package/dist/loadConfigFile.js +4 -5
- package/dist/rollup.d.ts +20 -13
- package/dist/rollup.js +3 -2
- package/dist/shared/index.js +6 -6
- package/dist/shared/loadConfigFile.js +68 -229
- package/dist/shared/rollup.js +1288 -878
- package/dist/shared/watch-cli.js +32 -32
- package/dist/shared/watch.js +16 -14
- package/package.json +2 -1
- package/dist/shared/mergeOptions.js +0 -182
package/dist/bin/rollup
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
@license
|
|
5
|
-
Rollup.js v3.1
|
|
6
|
-
|
|
5
|
+
Rollup.js v3.2.1
|
|
6
|
+
Sun, 16 Oct 2022 04:44:52 GMT - commit 46e1eaaaf05e0c2efa0ed395d7a3cfa99ef25fb5
|
|
7
7
|
|
|
8
8
|
https://github.com/rollup/rollup
|
|
9
9
|
|
|
@@ -18,15 +18,14 @@ const rollup = require('../shared/rollup.js');
|
|
|
18
18
|
const require$$2 = require('util');
|
|
19
19
|
const require$$0 = require('path');
|
|
20
20
|
const require$$0$1 = require('fs');
|
|
21
|
-
const mergeOptions = require('../shared/mergeOptions.js');
|
|
22
|
-
const loadConfigFile_js = require('../shared/loadConfigFile.js');
|
|
23
21
|
const node_fs = require('node:fs');
|
|
24
22
|
const node_path = require('node:path');
|
|
23
|
+
const loadConfigFile_js = require('../shared/loadConfigFile.js');
|
|
25
24
|
require('node:perf_hooks');
|
|
26
25
|
require('node:crypto');
|
|
27
26
|
require('node:events');
|
|
28
|
-
require('node:url');
|
|
29
27
|
require('tty');
|
|
28
|
+
require('node:url');
|
|
30
29
|
|
|
31
30
|
const help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-c, --config <filename> Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-d, --dir <dirname> Directory for chunks (if absent, prints to stdout)\n-e, --external <ids> Comma-separate list of module IDs to exclude\n-f, --format <format> Type of output (amd, cjs, es, iife, umd, system)\n-g, --globals <pairs> Comma-separate list of `moduleID:Global` pairs\n-h, --help Show this help message\n-i, --input <filename> Input (alternative to <entry file>)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n-n, --name <name> Name for UMD export\n-o, --file <output> Single output file (if absent, prints to stdout)\n-p, --plugin <plugin> Use the plugin specified (may be repeated)\n-v, --version Show version number\n-w, --watch Watch files in bundle and rebuild on changes\n--amd.id <id> ID for AMD module (default is anonymous)\n--amd.autoId Generate the AMD ID based off the chunk name\n--amd.basePath <prefix> Path to prepend to auto generated AMD ID\n--amd.define <name> Function to use in place of `define`\n--amd.forceJsExtensionForImports Use `.js` extension in AMD imports\n--assetFileNames <pattern> Name pattern for emitted assets\n--banner <text> Code to insert at top of bundle (outside wrapper)\n--chunkFileNames <pattern> Name pattern for emitted secondary chunks\n--compact Minify wrapper code\n--context <variable> Specify top-level `this` value\n--no-dynamicImportInCjs Write external dynamic CommonJS imports as require\n--entryFileNames <pattern> Name pattern for emitted entry chunks\n--environment <values> Settings passed to config file (see example)\n--no-esModule Do not add __esModule property\n--exports <mode> Specify export mode (auto, default, named, none)\n--extend Extend global variable defined by --name\n--no-externalLiveBindings Do not generate code to support live bindings\n--no-externalImportAssertions Omit import assertions in \"es\" output\n--failAfterWarnings Exit with an error if the build produced warnings\n--footer <text> Code to insert at end of bundle (outside wrapper)\n--no-freeze Do not freeze namespace objects\n--generatedCode <preset> Which code features to use (es5/es2015)\n--no-hoistTransitiveImports Do not hoist transitive imports into entry chunks\n--no-indent Don't indent result\n--no-interop Do not include interop block\n--inlineDynamicImports Create single bundle when using dynamic imports\n--intro <text> Code to insert at top of bundle (inside wrapper)\n--no-makeAbsoluteExternalsRelative Prevent normalization of external imports\n--maxParallelFileOps <value> How many files to read in parallel\n--minifyInternalExports Force or disable minification of internal exports\n--noConflict Generate a noConflict method for UMD globals\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--perf Display performance timings\n--no-preserveEntrySignatures Avoid facade chunks for entry points\n--preserveModules Preserve module structure\n--preserveModulesRoot Put preserved modules under this path at root level\n--preserveSymlinks Do not follow symlinks when resolving files\n--no-sanitizeFileName Do not replace invalid characters in file names\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapBaseUrl <url> Emit absolute sourcemap URLs with given base\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--stdin=ext Specify file extension used for stdin input\n--no-stdin Do not read \"-\" from stdin\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--strictDeprecations Throw errors for deprecated features\n--no-systemNullSetters Do not replace empty SystemJS setters with `null`\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--no-treeshake.moduleSideEffects Assume modules have no side effects\n--no-treeshake.propertyReadSideEffects Ignore property access side effects\n--no-treeshake.tryCatchDeoptimization Do not turn off try-catch-tree-shaking\n--no-treeshake.unknownGlobalSideEffects Assume unknown globals do not throw\n--waitForBundleInput Wait for bundle input files\n--watch.buildDelay <number> Throttle watch rebuilds\n--no-watch.clearScreen Do not clear the screen when rebuilding\n--watch.skipWrite Do not write files to disk when watching\n--watch.exclude <files> Exclude files from being watched\n--watch.include <files> Limit watching to specified files\n--watch.onStart <cmd> Shell command to run on `\"START\"` event\n--watch.onBundleStart <cmd> Shell command to run on `\"BUNDLE_START\"` event\n--watch.onBundleEnd <cmd> Shell command to run on `\"BUNDLE_END\"` event\n--watch.onEnd <cmd> Shell command to run on `\"END\"` event\n--watch.onError <cmd> Shell command to run on `\"ERROR\"` event\n--validate Validate output\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --file=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://rollupjs.org\n";
|
|
32
31
|
|
|
@@ -1510,11 +1509,11 @@ function prettyBytes(number, options) {
|
|
|
1510
1509
|
}
|
|
1511
1510
|
|
|
1512
1511
|
function printTimings(timings) {
|
|
1513
|
-
|
|
1514
|
-
const appliedColor = label[0] === '#' ? (label[1] !== '#' ?
|
|
1512
|
+
for (const [label, [time, memory, total]] of Object.entries(timings)) {
|
|
1513
|
+
const appliedColor = label[0] === '#' ? (label[1] !== '#' ? rollup.underline : rollup.bold) : (text) => text;
|
|
1515
1514
|
const row = `${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)} / ${prettyBytes(total)}`;
|
|
1516
1515
|
console.info(appliedColor(row));
|
|
1517
|
-
}
|
|
1516
|
+
}
|
|
1518
1517
|
}
|
|
1519
1518
|
|
|
1520
1519
|
async function build(inputOptions, warnings, silent = false) {
|
|
@@ -1527,24 +1526,24 @@ async function build(inputOptions, warnings, silent = false) {
|
|
|
1527
1526
|
if (typeof inputOptions.input === 'string') {
|
|
1528
1527
|
inputFiles = inputOptions.input;
|
|
1529
1528
|
}
|
|
1530
|
-
else if (inputOptions.input
|
|
1529
|
+
else if (Array.isArray(inputOptions.input)) {
|
|
1531
1530
|
inputFiles = inputOptions.input.join(', ');
|
|
1532
1531
|
}
|
|
1533
1532
|
else if (typeof inputOptions.input === 'object' && inputOptions.input !== null) {
|
|
1534
1533
|
inputFiles = Object.values(inputOptions.input).join(', ');
|
|
1535
1534
|
}
|
|
1536
|
-
|
|
1535
|
+
rollup.stderr(rollup.cyan(`\n${rollup.bold(inputFiles)} → ${rollup.bold(files.join(', '))}...`));
|
|
1537
1536
|
}
|
|
1538
1537
|
const bundle = await rollup.rollup(inputOptions);
|
|
1539
1538
|
if (useStdout) {
|
|
1540
1539
|
const output = outputOptions[0];
|
|
1541
1540
|
if (output.sourcemap && output.sourcemap !== 'inline') {
|
|
1542
|
-
|
|
1541
|
+
rollup.handleError(rollup.errorOnlyInlineSourcemapsForStdout());
|
|
1543
1542
|
}
|
|
1544
1543
|
const { output: outputs } = await bundle.generate(output);
|
|
1545
1544
|
for (const file of outputs) {
|
|
1546
1545
|
if (outputs.length > 1)
|
|
1547
|
-
process$1.stdout.write(`\n${
|
|
1546
|
+
process$1.stdout.write(`\n${rollup.cyan(rollup.bold(`//→ ${file.fileName}:`))}\n`);
|
|
1548
1547
|
process$1.stdout.write(file.type === 'asset' ? file.source : file.code);
|
|
1549
1548
|
}
|
|
1550
1549
|
if (!silent) {
|
|
@@ -1556,7 +1555,7 @@ async function build(inputOptions, warnings, silent = false) {
|
|
|
1556
1555
|
await bundle.close();
|
|
1557
1556
|
if (!silent) {
|
|
1558
1557
|
warnings.flush();
|
|
1559
|
-
|
|
1558
|
+
rollup.stderr(rollup.green(`created ${rollup.bold(files.join(', '))} in ${rollup.bold(prettyMilliseconds(Date.now() - start))}`));
|
|
1560
1559
|
if (bundle && bundle.getTimings) {
|
|
1561
1560
|
printTimings(bundle.getTimings());
|
|
1562
1561
|
}
|
|
@@ -1569,29 +1568,31 @@ async function getConfigPath(commandConfig) {
|
|
|
1569
1568
|
return node_path.resolve(await findConfigFileNameInCwd());
|
|
1570
1569
|
}
|
|
1571
1570
|
if (commandConfig.slice(0, 5) === 'node:') {
|
|
1572
|
-
const
|
|
1571
|
+
const packageName = commandConfig.slice(5);
|
|
1573
1572
|
try {
|
|
1574
|
-
|
|
1573
|
+
// eslint-disable-next-line unicorn/prefer-module
|
|
1574
|
+
return require.resolve(`rollup-config-${packageName}`, { paths: [process$1.cwd()] });
|
|
1575
1575
|
}
|
|
1576
1576
|
catch {
|
|
1577
1577
|
try {
|
|
1578
|
-
|
|
1578
|
+
// eslint-disable-next-line unicorn/prefer-module
|
|
1579
|
+
return require.resolve(packageName, { paths: [process$1.cwd()] });
|
|
1579
1580
|
}
|
|
1580
|
-
catch (
|
|
1581
|
-
if (
|
|
1582
|
-
|
|
1581
|
+
catch (error) {
|
|
1582
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
1583
|
+
rollup.handleError(rollup.errorMissingExternalConfig(commandConfig));
|
|
1583
1584
|
}
|
|
1584
|
-
throw
|
|
1585
|
+
throw error;
|
|
1585
1586
|
}
|
|
1586
1587
|
}
|
|
1587
1588
|
}
|
|
1588
1589
|
return node_path.resolve(commandConfig);
|
|
1589
1590
|
}
|
|
1590
1591
|
async function findConfigFileNameInCwd() {
|
|
1591
|
-
const
|
|
1592
|
+
const filesInWorkingDirectory = new Set(await node_fs.promises.readdir(process$1.cwd()));
|
|
1592
1593
|
for (const extension of ['mjs', 'cjs', 'ts']) {
|
|
1593
1594
|
const fileName = `${DEFAULT_CONFIG_BASE}.${extension}`;
|
|
1594
|
-
if (
|
|
1595
|
+
if (filesInWorkingDirectory.has(fileName))
|
|
1595
1596
|
return fileName;
|
|
1596
1597
|
}
|
|
1597
1598
|
return `${DEFAULT_CONFIG_BASE}.js`;
|
|
@@ -1602,7 +1603,7 @@ async function loadConfigFromCommand(command) {
|
|
|
1602
1603
|
if (!command.input && (command.stdin || !process$1.stdin.isTTY)) {
|
|
1603
1604
|
command.input = loadConfigFile_js.stdinName;
|
|
1604
1605
|
}
|
|
1605
|
-
const options =
|
|
1606
|
+
const options = await rollup.mergeOptions({ input: [] }, command, warnings.add);
|
|
1606
1607
|
await loadConfigFile_js.addCommandPluginsToInputOptions(options, command);
|
|
1607
1608
|
return { options: [options], warnings };
|
|
1608
1609
|
}
|
|
@@ -1611,7 +1612,7 @@ async function runRollup(command) {
|
|
|
1611
1612
|
let inputSource;
|
|
1612
1613
|
if (command._.length > 0) {
|
|
1613
1614
|
if (command.input) {
|
|
1614
|
-
|
|
1615
|
+
rollup.handleError(rollup.errorDuplicateImportOptions());
|
|
1615
1616
|
}
|
|
1616
1617
|
inputSource = command._;
|
|
1617
1618
|
}
|
|
@@ -1624,12 +1625,12 @@ async function runRollup(command) {
|
|
|
1624
1625
|
if (inputSource && inputSource.length > 0) {
|
|
1625
1626
|
if (inputSource.some((input) => input.includes('='))) {
|
|
1626
1627
|
command.input = {};
|
|
1627
|
-
|
|
1628
|
+
for (const input of inputSource) {
|
|
1628
1629
|
const equalsIndex = input.indexOf('=');
|
|
1629
|
-
const value = input.
|
|
1630
|
-
const key = input.
|
|
1630
|
+
const value = input.slice(Math.max(0, equalsIndex + 1));
|
|
1631
|
+
const key = input.slice(0, Math.max(0, equalsIndex)) || rollup.getAliasName(input);
|
|
1631
1632
|
command.input[key] = value;
|
|
1632
|
-
}
|
|
1633
|
+
}
|
|
1633
1634
|
}
|
|
1634
1635
|
else {
|
|
1635
1636
|
command.input = inputSource;
|
|
@@ -1639,14 +1640,14 @@ async function runRollup(command) {
|
|
|
1639
1640
|
const environment = Array.isArray(command.environment)
|
|
1640
1641
|
? command.environment
|
|
1641
1642
|
: [command.environment];
|
|
1642
|
-
environment
|
|
1643
|
-
|
|
1643
|
+
for (const argument of environment) {
|
|
1644
|
+
for (const pair of argument.split(',')) {
|
|
1644
1645
|
const [key, ...value] = pair.split(':');
|
|
1645
1646
|
process$1.env[key] = value.length === 0 ? String(true) : value.join(':');
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1648
1649
|
}
|
|
1649
|
-
if (
|
|
1650
|
+
if (rollup.isWatchEnabled(command.watch)) {
|
|
1650
1651
|
await rollup.loadFsEvents();
|
|
1651
1652
|
const { watch } = await Promise.resolve().then(() => require('../shared/watch-cli.js'));
|
|
1652
1653
|
watch(command);
|
|
@@ -1660,16 +1661,16 @@ async function runRollup(command) {
|
|
|
1660
1661
|
}
|
|
1661
1662
|
if (command.failAfterWarnings && warnings.warningOccurred) {
|
|
1662
1663
|
warnings.flush();
|
|
1663
|
-
|
|
1664
|
+
rollup.handleError(rollup.errorFailAfterWarnings());
|
|
1664
1665
|
}
|
|
1665
1666
|
}
|
|
1666
|
-
catch (
|
|
1667
|
+
catch (error) {
|
|
1667
1668
|
warnings.flush();
|
|
1668
|
-
|
|
1669
|
+
rollup.handleError(error);
|
|
1669
1670
|
}
|
|
1670
1671
|
}
|
|
1671
|
-
catch (
|
|
1672
|
-
|
|
1672
|
+
catch (error) {
|
|
1673
|
+
rollup.handleError(error);
|
|
1673
1674
|
}
|
|
1674
1675
|
}
|
|
1675
1676
|
}
|
|
@@ -1683,7 +1684,7 @@ async function getConfigs(command) {
|
|
|
1683
1684
|
}
|
|
1684
1685
|
|
|
1685
1686
|
const command = argParser(process$1.argv.slice(2), {
|
|
1686
|
-
alias:
|
|
1687
|
+
alias: rollup.commandAliases,
|
|
1687
1688
|
configuration: { 'camel-case-expansion': false }
|
|
1688
1689
|
});
|
|
1689
1690
|
if (command.help || (process$1.argv.length <= 2 && process$1.stdin.isTTY)) {
|
|
@@ -1694,6 +1695,7 @@ else if (command.version) {
|
|
|
1694
1695
|
}
|
|
1695
1696
|
else {
|
|
1696
1697
|
try {
|
|
1698
|
+
// eslint-disable-next-line unicorn/prefer-module
|
|
1697
1699
|
require('source-map-support').install();
|
|
1698
1700
|
}
|
|
1699
1701
|
catch {
|
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v3.1
|
|
4
|
-
|
|
3
|
+
Rollup.js v3.2.1
|
|
4
|
+
Sun, 16 Oct 2022 04:44:52 GMT - commit 46e1eaaaf05e0c2efa0ed395d7a3cfa99ef25fb5
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -15,3 +15,4 @@ import 'node:perf_hooks';
|
|
|
15
15
|
import 'node:crypto';
|
|
16
16
|
import 'node:fs';
|
|
17
17
|
import 'node:events';
|
|
18
|
+
import 'tty';
|