rollup 1.30.1 → 1.32.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/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 1.32.1
4
+ *2020-03-06*
5
+
6
+ ### Bug Fixes
7
+ * Handle default export detection for AMD and IIFE externals that do not have a prototype (#3420)
8
+ * Handle missing whitespace when the else branch of an if-statement is simplified (#3421)
9
+ * Mention the importing module when reporting errors for missing named exports (#3401)
10
+ * Add code to warning for missing output.name of IIFE bundles (#3372)
11
+
12
+ ### Pull Requests
13
+ * [#3372](https://github.com/rollup/rollup/pull/3372): Add warning code for missing output.name of IIFE bundle that has export (@rail44)
14
+ * [#3401](https://github.com/rollup/rollup/pull/3401): Missing exports errors now print the importing module (@timiyay)
15
+ * [#3418](https://github.com/rollup/rollup/pull/3418): Structure lifecycle hooks, add links to build time hooks (@lukastaegert)
16
+ * [#3420](https://github.com/rollup/rollup/pull/3420): Update generated code of getInteropBlock() to work with null prototype objects (@jdalton)
17
+ * [#3421](https://github.com/rollup/rollup/pull/3421): Avoid invalid code when "else" branch is simplified (@lukastaegert)
18
+
19
+ ## 1.32.0
20
+ *2020-02-28*
21
+
22
+ ### Features
23
+ * Allow adding plugins on the command line via `--plugin <plugin>` (#3379)
24
+
25
+ ### Pull Requests
26
+ * [#3379](https://github.com/rollup/rollup/pull/3379): introduce CLI --plugin support (@kzc)
27
+ * [#3390](https://github.com/rollup/rollup/pull/3390): fix typo: this.addWatchfile (@mistlog)
28
+ * [#3392](https://github.com/rollup/rollup/pull/3392): Bump codecov from 3.6.1 to 3.6.5
29
+ * [#3404](https://github.com/rollup/rollup/pull/3404): Update resolveFileUrl docs (@jakearchibald)
30
+
31
+ ## 1.31.1
32
+ *2020-02-14*
33
+
34
+ ### Bug Fixes
35
+ * Make sure errored files are always re-evaluated in watch mode to avoid an issue in the typescript plugin (#3388)
36
+
37
+ ### Pull Requests
38
+ * [#3366](https://github.com/rollup/rollup/pull/3366): Correct spelling minifaction to minification (@VictorHom)
39
+ * [#3371](https://github.com/rollup/rollup/pull/3371): Adjust bug template to mention REPL.it (@lukastaegert)
40
+ * [#3388](https://github.com/rollup/rollup/pull/3388): Run transform hooks again in watch mode on files that errored (@lukastaegert)
41
+
42
+ ## 1.31.0
43
+ *2020-01-31*
44
+
45
+ ### Features
46
+ * Always disable tree-shaking for asm.js functions to maintain semantics (#3362)
47
+
48
+ ### Pull Requests
49
+ * [#3362](https://github.com/rollup/rollup/pull/3362): Preserve asm.js code (@lukastaegert)
50
+
3
51
  ## 1.30.1
4
52
  *2020-01-27*
5
53
 
@@ -8,7 +56,7 @@
8
56
  * Resolve a crash when chunking circular dynamic imports (#3357)
9
57
 
10
58
  ### Pull Requests
11
- * [#3357](https://github.com/rollup/rollup/pull/3357):Resolve issues with circular dynamic entries (@lukastaegert)
59
+ * [#3357](https://github.com/rollup/rollup/pull/3357): Resolve issues with circular dynamic entries (@lukastaegert)
12
60
 
13
61
  ## 1.30.0
14
62
  *2020-01-27*
package/dist/bin/rollup CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  /*
4
4
  @license
5
- Rollup.js v1.30.1
6
- Mon, 27 Jan 2020 17:00:21 GMT - commit a54155d97fc2e89eca0a2c9b553c2040fb59011c
5
+ Rollup.js v1.32.1
6
+ Fri, 06 Mar 2020 09:32:39 GMT - commit f458cbf6cb8cfcc1678593d8dc595e4b8757eb6d
7
7
 
8
8
 
9
9
  https://github.com/rollup/rollup
@@ -22,7 +22,7 @@ var events = require('events');
22
22
  require('module');
23
23
  var assert = require('assert');
24
24
 
25
- var 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, esm, iife, umd)\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-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.define <name> Function to use in place of `define`\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--dynamicImportFunction <name> Rename the dynamic `import()` function\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--footer <text> Code to insert at end of bundle (outside wrapper)\n--no-freeze Do not freeze namespace objects\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--namespaceToStringTag Create proper `.toString` methods for namespaces\n--noConflict Generate a noConflict method for UMD globals\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--preferConst Use `const` instead of `var` for exports\n--preserveModules Preserve module structure\n--preserveSymlinks Do not follow symlinks when resolving files\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--no-stdin do not read \"-\" from stdin\n--strictDeprecations Throw errors for deprecated features\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--no-treeshake.propertyReadSideEffects Ignore property access side-effects\n--treeshake.pureExternalModules Assume side-effect free externals\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";
25
+ var 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, esm, iife, umd)\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.define <name> Function to use in place of `define`\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--dynamicImportFunction <name> Rename the dynamic `import()` function\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--footer <text> Code to insert at end of bundle (outside wrapper)\n--no-freeze Do not freeze namespace objects\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--namespaceToStringTag Create proper `.toString` methods for namespaces\n--noConflict Generate a noConflict method for UMD globals\n--no-strict Don't emit `\"use strict\";` in the generated modules\n--outro <text> Code to insert at end of bundle (inside wrapper)\n--preferConst Use `const` instead of `var` for exports\n--preserveModules Preserve module structure\n--preserveSymlinks Do not follow symlinks when resolving files\n--shimMissingExports Create shim variables for missing exports\n--silent Don't print warnings\n--sourcemapExcludeSources Do not include source code in source maps\n--sourcemapFile <file> Specify bundle position for source maps\n--no-stdin do not read \"-\" from stdin\n--strictDeprecations Throw errors for deprecated features\n--no-treeshake Disable tree-shaking optimisations\n--no-treeshake.annotations Ignore pure call annotations\n--no-treeshake.propertyReadSideEffects Ignore property access side-effects\n--treeshake.pureExternalModules Assume side-effect free externals\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";
26
26
 
27
27
  var minimist = function (args, opts) {
28
28
  if (!opts)
@@ -738,9 +738,7 @@ function printTimings(timings) {
738
738
  function build(inputOptions, outputOptions, warnings, silent = false) {
739
739
  const useStdout = !outputOptions[0].file && !outputOptions[0].dir;
740
740
  const start = Date.now();
741
- const files = useStdout
742
- ? ['stdout']
743
- : outputOptions.map(t => rollup_js.relativeId(t.file || t.dir));
741
+ const files = useStdout ? ['stdout'] : outputOptions.map(t => rollup_js.relativeId(t.file || t.dir));
744
742
  if (!silent) {
745
743
  let inputFiles;
746
744
  if (typeof inputOptions.input === 'string') {
@@ -795,10 +793,6 @@ function build(inputOptions, outputOptions, warnings, silent = false) {
795
793
  printTimings(bundle.getTimings());
796
794
  }
797
795
  }
798
- })
799
- .catch((err) => {
800
- warnings.flush();
801
- handleError(err);
802
796
  });
803
797
  }
804
798
 
@@ -1353,22 +1347,94 @@ function execute(configFile, configs, command) {
1353
1347
  else {
1354
1348
  for (const config of configs) {
1355
1349
  const warnings = batchWarnings();
1356
- const { inputOptions, outputOptions, optionError } = rollup_js.mergeOptions({
1357
- command,
1358
- config,
1359
- defaultOnWarnHandler: warnings.add
1360
- });
1361
- if (optionError) {
1362
- inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: optionError });
1350
+ try {
1351
+ const { inputOptions, outputOptions, optionError } = rollup_js.mergeOptions({
1352
+ command,
1353
+ config,
1354
+ defaultOnWarnHandler: warnings.add
1355
+ });
1356
+ if (optionError) {
1357
+ inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: optionError });
1358
+ }
1359
+ if (command.stdin !== false) {
1360
+ inputOptions.plugins.push(stdinPlugin());
1361
+ }
1362
+ if (command.plugin) {
1363
+ const plugins = Array.isArray(command.plugin) ? command.plugin : [command.plugin];
1364
+ for (const plugin of plugins) {
1365
+ if (/[={}]/.test(plugin)) {
1366
+ // -p plugin=value
1367
+ // -p "{transform(c,i){...}}"
1368
+ loadAndRegisterPlugin(inputOptions, plugin);
1369
+ }
1370
+ else {
1371
+ // split out plugins joined by commas
1372
+ // -p node-resolve,commonjs,buble
1373
+ plugin
1374
+ .split(',')
1375
+ .forEach((plugin) => loadAndRegisterPlugin(inputOptions, plugin));
1376
+ }
1377
+ }
1378
+ }
1379
+ yield build(inputOptions, outputOptions, warnings, command.silent);
1363
1380
  }
1364
- if (command.stdin !== false) {
1365
- inputOptions.plugins.push(stdinPlugin());
1381
+ catch (err) {
1382
+ warnings.flush();
1383
+ handleError(err);
1366
1384
  }
1367
- yield build(inputOptions, outputOptions, warnings, command.silent);
1368
1385
  }
1369
1386
  }
1370
1387
  });
1371
1388
  }
1389
+ function loadAndRegisterPlugin(inputOptions, pluginText) {
1390
+ let plugin = null;
1391
+ let pluginArg = undefined;
1392
+ if (pluginText[0] === '{') {
1393
+ // -p "{transform(c,i){...}}"
1394
+ plugin = new Function('return ' + pluginText);
1395
+ }
1396
+ else {
1397
+ const match = pluginText.match(/^([@.\/\\\w|^{}|-]+)(=(.*))?$/);
1398
+ if (match) {
1399
+ // -p plugin
1400
+ // -p plugin=arg
1401
+ pluginText = match[1];
1402
+ pluginArg = new Function('return ' + match[3])();
1403
+ }
1404
+ else {
1405
+ throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`);
1406
+ }
1407
+ if (!/^\.|^rollup-plugin-|[@\/\\]/.test(pluginText)) {
1408
+ // Try using plugin prefix variations first if applicable.
1409
+ // Prefix order is significant - left has higher precedence.
1410
+ for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
1411
+ try {
1412
+ plugin = require(prefix + pluginText);
1413
+ break;
1414
+ }
1415
+ catch (ex) {
1416
+ // if this does not work, we try requiring the actual name below
1417
+ }
1418
+ }
1419
+ }
1420
+ if (!plugin) {
1421
+ try {
1422
+ if (pluginText[0] == '.')
1423
+ pluginText = path.resolve(pluginText);
1424
+ plugin = require(pluginText);
1425
+ }
1426
+ catch (ex) {
1427
+ throw new Error(`Cannot load plugin "${pluginText}"`);
1428
+ }
1429
+ }
1430
+ }
1431
+ if (typeof plugin === 'object' && pluginText in plugin) {
1432
+ // some plugins do not use `export default` for their entry point.
1433
+ // attempt to use the plugin name as the named import name.
1434
+ plugin = plugin[pluginText];
1435
+ }
1436
+ inputOptions.plugins.push(typeof plugin === 'function' ? plugin.call(plugin, pluginArg) : plugin);
1437
+ }
1372
1438
 
1373
1439
  const command = minimist(process.argv.slice(2), {
1374
1440
  alias: rollup_js.commandAliases