rollup 0.41.5 → 0.43.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,37 @@
1
1
  # rollup changelog
2
2
 
3
+ ## 0.43.1
4
+
5
+ * Fix memory leak on incremental rebuilds ([#883](https://github.com/rollup/rollup/issues/883))
6
+ * Allow `this.warn` and `this.error` to accept a `{line, column}` object as an alternative to a character index ([#1265](https://github.com/rollup/rollup/issues/1265))
7
+ * Print more useful error if entry module is 'external' ([#1264](https://github.com/rollup/rollup/issues/1264))
8
+ * Catch errors in `bundle.generate` options ([#1463](https://github.com/rollup/rollup/pull/1463))
9
+ * Fix magic-string deprecation warning ([#1445](https://github.com/rollup/rollup/pull/1445))
10
+
11
+ ## 0.43.0
12
+
13
+ * Allow config files to import JSON ([#1426](https://github.com/rollup/rollup/issues/1426))
14
+ * Allow undefined imports in interop block ([#1341](https://github.com/rollup/rollup/issues/1341))
15
+ * Add `process.env.ROLLUP_WATCH = 'true'` in watch mode ([#1429](https://github.com/rollup/rollup/issues/1429))
16
+ * Add `pureExternalModules` option ([#1352](https://github.com/rollup/rollup/issues/1352))
17
+ * Allow plugins to specify `options.entry` ([#1270](https://github.com/rollup/rollup/issues/1270))
18
+ * Update dependencies
19
+
20
+ ## 0.42.0
21
+
22
+ * Deprecate `options.moduleId` in favour of `options.amd.id` ([#1365](https://github.com/rollup/rollup/pull/1365))
23
+ * Add `options.amd.define` option to specify name of AMD `define` function ([#1365](https://github.com/rollup/rollup/pull/1365))
24
+ * Fix incorrect class removal with `treeshake: false` ([#1375](https://github.com/rollup/rollup/pull/1375))
25
+ * Deconflict module exports imported as namespaces ([#1384](https://github.com/rollup/rollup/issues/1384))
26
+ * Handle bare self-imports ([#1274](https://github.com/rollup/rollup/issues/1274))
27
+ * Allow config file to export an array of multiple configs ([#1389](https://github.com/rollup/rollup/pull/1389))
28
+ * Handle exponentiation operator, and fail gracefully on unknown operators ([#1416](https://github.com/rollup/rollup/issues/1416))
29
+ * Add `watch` option ([#1424](https://github.com/rollup/rollup/pull/1424))
30
+
31
+ ## 0.41.6
32
+
33
+ * Preserve `originalSourceMap` on incremental rebuilds for loaders with sourcemaps ([#1336](https://github.com/rollup/rollup/issues/1336))
34
+
3
35
  ## 0.41.5
4
36
 
5
37
  * Wrap ternary consequent/alternate sequences in parens ([#1273](https://github.com/rollup/rollup/issues/1273))
package/README.md CHANGED
@@ -28,16 +28,36 @@
28
28
 
29
29
  ## Overview
30
30
 
31
- Rollup is a module bundler for JavaScript which compiles small pieces of code into a something larger and more complex, such as a library or application. It uses the new standardized format for code modules included in the ES6 revision of JavaScript, instead of previous idiosyncratic solutions such as CommonJS and AMD.
31
+ Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application. It uses the new standardized format for code modules included in the ES6 revision of JavaScript, instead of previous idiosyncratic solutions such as CommonJS and AMD. ES6 modules let you freely and seamlessly combine the most useful individual functions from your favorite libraries. This will eventually be possible natively, but Rollup lets you do it today.
32
32
 
33
33
  ## Quick Start Guide
34
34
 
35
- Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://github.com/rollup/rollup/wiki/Command-Line-Interface) with an optional configuration file, or else through its [JavaScript API](https://github.com/rollup/rollup/wiki/JavaScript-API). After installing, run `rollup --help` to see the available options and parameters.
35
+ Install with `npm install --global rollup`. Rollup can be used either through a [command line interface](https://github.com/rollup/rollup/wiki/Command-Line-Interface) with an optional configuration file, or else through its [JavaScript API](https://github.com/rollup/rollup/wiki/JavaScript-API). Run `rollup --help` to see the available options and parameters. The [starter project template](https://github.com/rollup/rollup-starter-project) demonstrates common configuration options, and more detailed instructions are available throughout the [user guide](http://rollupjs.org/).
36
36
 
37
- - [user guide](http://rollupjs.org/)
38
- - [starter project template](https://github.com/rollup/rollup-starter-project)
39
- - step-by-step [tutorial video series](https://code.lengstorf.com/learn-rollup-js/), with accompanying written walkthrough
40
- - miscellaneous issues in the [wiki](https://github.com/rollup/rollup/wiki)
37
+ ### Commands
38
+
39
+ These commands assume the entry point to your application is named main.js, and that you'd like all imports compiled into a single file named bundle.js.
40
+
41
+ For browsers:
42
+
43
+ ```bash
44
+ # compile to a <script> containing a self-executing function
45
+ $ rollup main.js --format iife --output bundle.js
46
+ ```
47
+
48
+ For Node.js:
49
+
50
+ ```bash
51
+ # compile to a CommonJS module
52
+ $ rollup main.js --format cjs --output bundle.js
53
+ ```
54
+
55
+ For both browsers and Node.js:
56
+
57
+ ```bash
58
+ # UMD format requires a bundle name
59
+ $ rollup main.js --format umd --name "myBundle" --output bundle.js
60
+ ```
41
61
 
42
62
  ## Why
43
63
 
@@ -71,8 +91,6 @@ ajax( 'https://api.example.com?search=' + query ).then( handleResponse );
71
91
 
72
92
  Because Rollup includes the bare minimum, it results in lighter, faster, and less complicated libraries and applications. Since this approach is based on explicit `import` and `export` statements, it is vastly more effective than simply running an automated minifier to detect unused variables in the compiled output code.
73
93
 
74
- ES6 modules let you freely and seamlessly combine the most useful individual functions from your favorite libraries, without weighing down your project with all the other unused code. This will eventually be possible natively, but Rollup lets you do it today.
75
-
76
94
  ## Compatibility
77
95
 
78
96
  ### Importing CommonJS
@@ -83,6 +101,11 @@ Rollup can import existing CommonJS modules [through a plugin](https://github.co
83
101
 
84
102
  To make sure your ES6 modules are immediately usable by tools that work with CommonJS such as Node.js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the `main` property in your `package.json` file. If your `package.json` file also has a `module` field, ES6-aware tools like Rollup and [webpack 2](https://webpack.js.org/) will [import the ES6 module version](https://github.com/rollup/rollup/wiki/pkg.module) directly.
85
103
 
104
+ ## Links
105
+
106
+ - step-by-step [tutorial video series](https://code.lengstorf.com/learn-rollup-js/), with accompanying written walkthrough
107
+ - miscellaneous issues in the [wiki](https://github.com/rollup/rollup/wiki)
108
+
86
109
  ## License
87
110
 
88
- Released under the [MIT license](https://github.com/rollup/rollup/blob/master/LICENSE.md).
111
+ [MIT](https://github.com/rollup/rollup/blob/master/LICENSE.md)
package/bin/rollup CHANGED
@@ -3,15 +3,15 @@
3
3
 
4
4
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
5
5
 
6
- var fs = require('fs');
7
- var rollup = require('../dist/rollup.js');
8
6
  var path = require('path');
9
7
  var path__default = _interopDefault(path);
8
+ var fs = require('fs');
9
+ var rollup = require('../dist/rollup.js');
10
10
  var module$1 = _interopDefault(require('module'));
11
11
  var sourceMapSupport = require('source-map-support');
12
12
 
13
13
  var index$1 = function (args, opts) {
14
- if (!opts) opts = {};
14
+ if (!opts) { opts = {}; }
15
15
 
16
16
  var flags = { bools : {}, strings : {}, unknownFn: null };
17
17
 
@@ -65,7 +65,7 @@ var index$1 = function (args, opts) {
65
65
 
66
66
  function setArg (key, val, arg) {
67
67
  if (arg && flags.unknownFn && !argDefined(key, arg)) {
68
- if (flags.unknownFn(arg) === false) return;
68
+ if (flags.unknownFn(arg) === false) { return; }
69
69
  }
70
70
 
71
71
  var value = !flags.strings[key] && isNumber(val)
@@ -80,7 +80,7 @@ var index$1 = function (args, opts) {
80
80
  function setKey (obj, keys, value) {
81
81
  var o = obj;
82
82
  keys.slice(0,-1).forEach(function (key) {
83
- if (o[key] === undefined) o[key] = {};
83
+ if (o[key] === undefined) { o[key] = {}; }
84
84
  o = o[key];
85
85
  });
86
86
 
@@ -240,28 +240,25 @@ function hasKey (obj, keys) {
240
240
  }
241
241
 
242
242
  function isNumber (x) {
243
- if (typeof x === 'number') return true;
244
- if (/^0x[0-9a-f]+$/i.test(x)) return true;
243
+ if (typeof x === 'number') { return true; }
244
+ if (/^0x[0-9a-f]+$/i.test(x)) { return true; }
245
245
  return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
246
246
  }
247
247
 
248
248
  var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-v, --version Show version number\n-h, --help Show this help message\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-w, --watch Watch files in bundle and rebuild on changes\n-i, --input Input (alternative to <entry file>)\n-o, --output <output> Output (if absent, prints to stdout)\n-f, --format [es] Type of output (amd, cjs, es, iife, umd)\n-e, --external Comma-separate list of module IDs to exclude\n-g, --globals Comma-separate list of `module ID:Global` pairs\n Any module IDs defined here are added to external\n-n, --name Name for UMD export\n-u, --id ID for AMD module (default is anonymous)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--silent Don't print warnings\n--intro Content to insert at top of bundle (inside wrapper)\n--outro Content to insert at end of bundle (inside wrapper)\n--banner Content to insert at top of bundle (outside wrapper)\n--footer Content to insert at end of bundle (outside wrapper)\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 --output=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://github.com/rollup/rollup/wiki\n";
249
249
 
250
- var version = "0.41.5";
251
-
252
- var path$1 = path__default;
253
- var Module = module$1;
250
+ var version = "0.43.1";
254
251
 
255
252
  var modules = {};
256
253
 
257
254
  var getModule = function(dir) {
258
- var rootPath = dir ? path$1.resolve(dir) : process.cwd();
259
- var rootName = path$1.join(rootPath, '@root');
255
+ var rootPath = dir ? path__default.resolve(dir) : process.cwd();
256
+ var rootName = path__default.join(rootPath, '@root');
260
257
  var root = modules[rootName];
261
258
  if (!root) {
262
- root = new Module(rootName);
259
+ root = new module$1(rootName);
263
260
  root.filename = rootName;
264
- root.paths = Module._nodeModulePaths(rootPath);
261
+ root.paths = module$1._nodeModulePaths(rootPath);
265
262
  modules[rootName] = root;
266
263
  }
267
264
  return root;
@@ -274,7 +271,7 @@ var requireRelative = function(requested, relativeTo) {
274
271
 
275
272
  requireRelative.resolve = function(requested, relativeTo) {
276
273
  var root = getModule(relativeTo);
277
- return Module._resolveFilename(requested, root);
274
+ return module$1._resolveFilename(requested, root);
278
275
  };
279
276
 
280
277
  var index$2 = requireRelative;
@@ -371,8 +368,7 @@ var index$8 = function (str) {
371
368
  return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
372
369
  };
373
370
 
374
- var ansiRegex$1 = index$10;
375
- var re = new RegExp(ansiRegex$1().source); // remove the `g` flag
371
+ var re = new RegExp(index$10().source); // remove the `g` flag
376
372
  var index$12 = re.test.bind(re);
377
373
 
378
374
  var argv = process.argv;
@@ -425,29 +421,24 @@ var index$14 = (function () {
425
421
  return false;
426
422
  })();
427
423
 
428
- var escapeStringRegexp = index$4;
429
- var ansiStyles = index$6;
430
- var stripAnsi = index$8;
431
- var hasAnsi = index$12;
432
- var supportsColor = index$14;
433
424
  var defineProps = Object.defineProperties;
434
425
  var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
435
426
 
436
427
  function Chalk(options) {
437
428
  // detect mode if not set manually
438
- this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
429
+ this.enabled = !options || options.enabled === undefined ? index$14 : options.enabled;
439
430
  }
440
431
 
441
432
  // use bright blue on Windows as the normal blue color is illegible
442
433
  if (isSimpleWindowsTerm) {
443
- ansiStyles.blue.open = '\u001b[94m';
434
+ index$6.blue.open = '\u001b[94m';
444
435
  }
445
436
 
446
437
  var styles = (function () {
447
438
  var ret = {};
448
439
 
449
- Object.keys(ansiStyles).forEach(function (key) {
450
- ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
440
+ Object.keys(index$6).forEach(function (key) {
441
+ index$6[key].closeRe = new RegExp(index$4(index$6[key].close), 'g');
451
442
 
452
443
  ret[key] = {
453
444
  get: function () {
@@ -499,13 +490,13 @@ function applyStyle() {
499
490
  // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
500
491
  // see https://github.com/chalk/chalk/issues/58
501
492
  // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
502
- var originalDim = ansiStyles.dim.open;
493
+ var originalDim = index$6.dim.open;
503
494
  if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
504
- ansiStyles.dim.open = '';
495
+ index$6.dim.open = '';
505
496
  }
506
497
 
507
498
  while (i--) {
508
- var code = ansiStyles[nestedStyles[i]];
499
+ var code = index$6[nestedStyles[i]];
509
500
 
510
501
  // Replace any instances already present with a re-opening code
511
502
  // otherwise only the part of the string until said closing code
@@ -514,7 +505,7 @@ function applyStyle() {
514
505
  }
515
506
 
516
507
  // Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
517
- ansiStyles.dim.open = originalDim;
508
+ index$6.dim.open = originalDim;
518
509
 
519
510
  return str;
520
511
  }
@@ -536,10 +527,10 @@ function init() {
536
527
  defineProps(Chalk.prototype, init());
537
528
 
538
529
  var index$3 = new Chalk();
539
- var styles_1 = ansiStyles;
540
- var hasColor = hasAnsi;
541
- var stripColor = stripAnsi;
542
- var supportsColor_1 = supportsColor;
530
+ var styles_1 = index$6;
531
+ var hasColor = index$12;
532
+ var stripColor = index$8;
533
+ var supportsColor_1 = index$14;
543
534
 
544
535
  index$3.styles = styles_1;
545
536
  index$3.hasColor = hasColor;
@@ -554,11 +545,11 @@ function isAbsolute ( path$$1 ) {
554
545
  }
555
546
 
556
547
  function relativeId ( id ) {
557
- if ( typeof process === 'undefined' || !isAbsolute( id ) ) return id;
548
+ if ( typeof process === 'undefined' || !isAbsolute( id ) ) { return id; }
558
549
  return path.relative( process.cwd(), id );
559
550
  }
560
551
 
561
- if ( !process.stderr.isTTY ) index$3.enabled = false;
552
+ if ( !process.stderr.isTTY ) { index$3.enabled = false; }
562
553
  var warnSymbol = process.stderr.isTTY ? "⚠️ " : "Warning: ";
563
554
  var errorSymbol = process.stderr.isTTY ? "🚨 " : "Error: ";
564
555
 
@@ -566,16 +557,19 @@ var errorSymbol = process.stderr.isTTY ? "🚨 " : "Error: ";
566
557
  var stderr = console.error.bind( console ); // eslint-disable-line no-console
567
558
 
568
559
  function log ( object, symbol ) {
569
- var message = (object.plugin ? ("(" + (object.plugin) + " plugin) " + (object.message)) : object.message) || object;
560
+ var description = object.message || object;
561
+ if (object.name) { description = object.name + ': ' + description; }
562
+ var message = (object.plugin ? ("(" + (object.plugin) + " plugin) " + description) : description) || object;
570
563
 
571
564
  stderr( ("" + symbol + (index$3.bold( message ))) );
572
565
 
566
+ // TODO should this be "object.url || (object.file && object.loc.file) || object.id"?
573
567
  if ( object.url ) {
574
568
  stderr( index$3.cyan( object.url ) );
575
569
  }
576
570
 
577
571
  if ( object.loc ) {
578
- stderr( ((relativeId( object.loc.file )) + " (" + (object.loc.line) + ":" + (object.loc.column) + ")") );
572
+ stderr( ((relativeId( object.loc.file || object.id )) + " (" + (object.loc.line) + ":" + (object.loc.column) + ")") );
579
573
  } else if ( object.id ) {
580
574
  stderr( relativeId( object.id ) );
581
575
  }
@@ -593,7 +587,7 @@ function handleWarning ( warning ) {
593
587
 
594
588
  function handleError ( err, recover ) {
595
589
  log( err, errorSymbol );
596
- if ( !recover ) process.exit( 1 );
590
+ if ( !recover ) { process.exit( 1 ); }
597
591
  }
598
592
 
599
593
  var SOURCEMAPPING_URL = 'sourceMa';
@@ -661,10 +655,10 @@ function runRollup ( command ) {
661
655
 
662
656
  rollup.rollup({
663
657
  entry: config,
664
- onwarn: function (warning) {
665
- if ( warning.code === 'UNRESOLVED_IMPORT' ) return;
666
- handleWarning( warning );
667
- }
658
+ external: function (id) {
659
+ return (id[0] !== '.' && !path__default.isAbsolute(id)) || id.slice(-5,id.length) === '.json';
660
+ },
661
+ onwarn: handleWarning
668
662
  })
669
663
  .then( function (bundle) {
670
664
  var ref = bundle.generate({
@@ -672,6 +666,8 @@ function runRollup ( command ) {
672
666
  });
673
667
  var code = ref.code;
674
668
 
669
+ if ( command.watch ) { process.env.ROLLUP_WATCH = 'true'; }
670
+
675
671
  // temporarily override require
676
672
  var defaultLoader = require.extensions[ '.js' ];
677
673
  require.extensions[ '.js' ] = function ( m, filename ) {
@@ -682,15 +678,21 @@ function runRollup ( command ) {
682
678
  }
683
679
  };
684
680
 
685
- var options = require( config );
686
- if ( Object.keys( options ).length === 0 ) {
687
- handleError({
688
- code: 'MISSING_CONFIG',
689
- message: 'Config file must export an options object',
690
- url: 'https://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file'
691
- });
692
- }
693
- execute( options, command );
681
+ var configs = require( config );
682
+ var normalized = Array.isArray( configs ) ? configs : [configs];
683
+
684
+ normalized.forEach(function (options) {
685
+ if ( Object.keys( options ).length === 0 ) {
686
+ handleError({
687
+ code: 'MISSING_CONFIG',
688
+ message: 'Config file must export an options object',
689
+ url: 'https://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file'
690
+ });
691
+ }
692
+
693
+ execute( options, command );
694
+ });
695
+
694
696
  require.extensions[ '.js' ] = defaultLoader;
695
697
  })
696
698
  .catch( handleError );
@@ -757,7 +759,7 @@ function execute ( options, command ) {
757
759
  options.onwarn = function (warning) {
758
760
  var str = warning.toString();
759
761
 
760
- if ( seen.has( str ) ) return;
762
+ if ( seen.has( str ) ) { return; }
761
763
  seen.add( str );
762
764
 
763
765
  handleWarning( warning );
@@ -834,13 +836,6 @@ function assign ( target, source ) {
834
836
  }
835
837
 
836
838
  function bundle ( options ) {
837
- if ( !options.entry ) {
838
- handleError({
839
- code: 'MISSING_INPUT_OPTION',
840
- message: 'You must specify an --input (-i) option'
841
- });
842
- }
843
-
844
839
  return rollup.rollup( options )
845
840
  .then( function (bundle) {
846
841
  if ( options.dest ) {