diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..6df029f
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+test/*
+!test/test.js
diff --git a/.eslintrc b/.eslintrc
index 0f98dff..d9150f9 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -7,17 +7,38 @@
"space-before-blocks": [ 2, "always" ],
"space-before-function-paren": [ 2, "always" ],
"no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ],
- "no-cond-assign": [ 0 ]
+ "no-cond-assign": 0,
+ "no-unused-vars": 2,
+ "object-shorthand": [ 2, "always" ],
+ "no-const-assign": 2,
+ "no-class-assign": 2,
+ "no-this-before-super": 2,
+ "no-var": 2,
+ "no-unreachable": 2,
+ "valid-typeof": 2,
+ "quote-props": [ 2, "as-needed" ],
+ "one-var": [ 2, "never" ],
+ "prefer-arrow-callback": 2,
+ "prefer-const": [ 2, { "destructuring": "all" } ],
+ "arrow-spacing": 2
},
"env": {
"es6": true,
"browser": true,
- "mocha": true,
"node": true
},
- "extends": "eslint:recommended",
+ "extends": [
+ "eslint:recommended",
+ "plugin:import/errors",
+ "plugin:import/warnings"
+ ],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
+ },
+ "settings": {
+ "import/ignore": [ 0, [
+ "\\.path.js$"
+ ] ]
}
}
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..4e2b499
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,18 @@
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..d2882ac
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,7 @@
+
diff --git a/.gitignore b/.gitignore
index 55804cb..f5abf8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,9 @@
.DS_Store
-node_modules
-!test/node_modules
+/node_modules
.gobble*
dist
_actual
coverage
.commithash
.idea
+bin/rollup
diff --git a/.travis.yml b/.travis.yml
index 9a040ed..83d1bca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,7 @@ language: node_js
node_js:
- "0.12"
- "4"
+ - "6"
env:
global:
- BUILD_TIMEOUT=10000
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03d0f1a..ef52701 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,261 @@
# rollup changelog
+## 0.37.0
+
+* [BREAKING] Default exports are not included in reified namespaces ([#1028](https://github.com/rollup/rollup/issues/1028))
+* Parentheses do not defeat tree-shaking ([#1101](https://github.com/rollup/rollup/issues/1101), [#1128](https://github.com/rollup/rollup/issues/1128))
+* More `legacy` fixes: do not create getters ([#1069](https://github.com/rollup/rollup/pull/1069)), do not include `__esModule` ([#1068](https://github.com/rollup/rollup/pull/1068)), quote reserved property names ([#1057](https://github.com/rollup/rollup/pull/1057))
+* Fix missing namespace member warnings ([#1045](https://github.com/rollup/rollup/issues/1045))
+* Fix TypeError in arrow function without braces returning a function ([#1062](https://github.com/rollup/rollup/pull/1062))
+
+## 0.36.4
+
+* Only depend on program-level call expressions ([#977](https://github.com/rollup/rollup/issues/977))
+
+## 0.36.3
+
+* Add `legacy` option for IE8 support ([#989](https://github.com/rollup/rollup/pull/989))
+
+## 0.36.2
+
+* Insert semicolons where necessary to fix broken code ([#1004](https://github.com/rollup/rollup/issues/1004))
+* Include module ID and location when warning about top-level `this` ([#1012](https://github.com/rollup/rollup/pull/1012))
+* More informative error for missing exports ([#1033](https://github.com/rollup/rollup/issues/1033))
+* `options.moduleContext` for per-module context overrides ([#1023](https://github.com/rollup/rollup/pull/1023))
+
+## 0.36.1
+
+* Include naked block statements ([#981](https://github.com/rollup/rollup/issues/981))
+* Correctly include falsy alternate statements in optimised if blocks ([#973](https://github.com/rollup/rollup/issues/973))
+* Prevent omission of default exports that are only used by the exporting module ([#967](https://github.com/rollup/rollup/pull/967))
+* Prevent warning on `auto` exports with ES output ([#966](https://github.com/rollup/rollup/pull/966))
+
+## 0.36.0
+
+* `export { foo as default }` no longer creates a live binding ([#860](https://github.com/rollup/rollup/issues/860))
+
+## 0.35.15
+
+* Warn on missing unused imports in deshadowing phase ([#928](https://github.com/rollup/rollup/issues/928))
+* Always add a newline to the end of bundles ([#958](https://github.com/rollup/rollup/issues/958))
+
+## 0.35.14
+
+* Include all parent statements of expression with effects, up to function boundary ([#930](https://github.com/rollup/rollup/issues/930))
+
+## 0.35.13
+
+* Include superclasses when including their subclasses ([#932](https://github.com/rollup/rollup/issues/932))
+
+## 0.35.12
+
+* Add `interop: false` option to disable unwrapping of external imports ([#939](https://github.com/rollup/rollup/issues/939))
+
+## 0.35.11
+
+* Deconflict reified namespaces with other declarations ([#910](https://github.com/rollup/rollup/issues/910))
+
+## 0.35.10
+
+* Only remove EmptyStatement nodes directly inside blocks ([#913](https://github.com/rollup/rollup/issues/931))
+
+## 0.35.9
+
+* Support Node 0.12 ([#909](https://github.com/rollup/rollup/issues/909))
+
+## 0.35.8
+
+* Correctly deshadow re-assigned module functions ([#910](https://github.com/rollup/rollup/issues/910))
+
+## 0.35.7
+
+* Refactor `flushTime.js` ([#922](https://github.com/rollup/rollup/pull/922))
+
+## 0.35.6
+
+* Fix browser build
+
+## 0.35.5
+
+* Allow empty for loop heads ([#919](https://github.com/rollup/rollup/issues/919))
+
+## 0.35.4
+
+* Preserve effects in for-of and for-in loops ([#870](https://github.com/rollup/rollup/issues/870))
+* Remove empty statements ([#918](https://github.com/rollup/rollup/pull/918))
+
+## 0.35.3
+
+* Render identifiers inside template literals
+
+## 0.35.2
+
+* Fix broken build caused by out of date locally installed dependencies
+
+## 0.35.1
+
+* Rewrite deconflicted class identifiers ([#915](https://github.com/rollup/rollup/pull/915))
+* Include `dependencies` in `bundle.modules` objects ([#903](https://github.com/rollup/rollup/issues/903))
+* Update to Acorn 4 ([#914](https://github.com/rollup/rollup/pull/914))
+
+## 0.35.0
+
+* Rewrite analysis/tree-shaking code ([#902](https://github.com/rollup/rollup/pull/902))
+* Include conditional mutations of global objects ([#901](https://github.com/rollup/rollup/issues/901))
+* Only reify namespaces if necessary ([#898](https://github.com/rollup/rollup/issues/898))
+* Track mutations of aliased globals ([#893](https://github.com/rollup/rollup/issues/893))
+* Include duplicated var declarations ([#716](https://github.com/rollup/rollup/issues/716))
+
+## 0.34.13
+
+* Pass `{ format }` through to `transformBundle` ([#867](https://github.com/rollup/rollup/issues/867))
+
+## 0.34.12
+
+* Fix `rollup --watch` ([#887](https://github.com/rollup/rollup/issues/887))
+* Case-sensitive paths ([#862](https://github.com/rollup/rollup/issues/862))
+
+## 0.34.11
+
+* Prevent leaky state when `bundle` is reused ([#875](https://github.com/rollup/rollup/issues/875))
+* Ensure `intro` appears before interop block ([#880](https://github.com/rollup/rollup/issues/880))
+
+## 0.34.10
+
+* Allow custom `options.context` to replace top-level `this` ([#851](https://github.com/rollup/rollup/issues/851))
+* Fix `noConflict` when used via `rollup --config` ([#846](https://github.com/rollup/rollup/issues/846))
+* Place `outro` block *after* export block ([#852](https://github.com/rollup/rollup/issues/852))
+
+## 0.34.9
+
+* Disable indentation by default, for faster bundle generation ([#812](https://github.com/rollup/rollup/pull/812))
+* More helpful error on missing entry file ([#802](https://github.com/rollup/rollup/issues/802))
+* Preserve comments before import declarations ([#815](https://github.com/rollup/rollup/pull/815))
+
+## 0.34.8
+
+* Wrap UMD factory function in parens to avoid lazy parsing ([#774](https://github.com/rollup/rollup/pull/774))
+
+## 0.34.7
+
+* Leave it up to resolveId to normalize the entry path ([#835](https://github.com/rollup/rollup/pull/835))
+* Cache decoded mappings ([#834](https://github.com/rollup/rollup/pull/834))
+
+## 0.34.5
+
+* Fix circular export ([#813](https://github.com/rollup/rollup/issues/813))
+
+## 0.34.4
+
+* Module render performance tweak ([#823](https://github.com/rollup/rollup/pull/823))
+
+## 0.34.3
+
+* Avoid infinite recursion in `Bundle.sort()` ([#800](https://github.com/rollup/rollup/pull/800))
+
+## 0.34.2
+
+* resolveId calls are cached now to improve incremental build
+* Fixed error message recursion in plugins
+
+## 0.34.1
+
+* Support `paths` config ([#754](https://github.com/rollup/rollup/issues/754))
+* Allow `export *` from external module, internally
+
+## 0.34.0
+
+* Use resolved IDs for relative imports that are also external modules, to allow `options.globals` to work with them ([#763](https://github.com/rollup/rollup/issues/763))
+* Ensure reassigned exports are declared in an ES bundle, and remove empty `exports.foo;` statements ([#755](https://github.com/rollup/rollup/issues/755))
+* Add newline after sourcemap comment ([#756](https://github.com/rollup/rollup/issues/756))
+
+## 0.33.2
+
+* Add `bundle` as second argument to `ongenerate` and `onwrite` hooks ([#773](https://github.com/rollup/rollup/pull/773))
+* Warn on top-level `this` ([#770](https://github.com/rollup/rollup/issues/770))
+
+## 0.33.1
+
+* Fix `--no-strict` option ([#751](https://github.com/rollup/rollup/pull/751))
+* Fix Windows edge case with case-sensitive paths ([#760](https://github.com/rollup/rollup/pull/760))
+
+## 0.33.0
+
+* Downgrade missing transformer sourcemap to a warning, not an error, and print the name of the offending plugin if possible ([#746](https://github.com/rollup/rollup/issues/746))
+* Warn if same name is re-exported from two modules ([#722](https://github.com/rollup/rollup/issues/722))
+
+## 0.32.4
+
+* Add `ongenerate` and `onwrite` plugin hooks ([#742](https://github.com/rollup/rollup/pull/742))
+
+## 0.32.3
+
+* Generated correct sourcemaps with reified namespaces ([#668](https://github.com/rollup/rollup/issues/668))
+* Exclude plugin helper modules from sourcemaps ([#747](https://github.com/rollup/rollup/pull/747))
+
+## 0.32.2
+
+* Allow `--globals` to work with `--external` or `options.external` in whatever configuration ([#743](https://github.com/rollup/rollup/issues/743))
+
+## 0.32.1
+
+* Preserve side-effects to default exports that coincide with used named exports ([#733](https://github.com/rollup/rollup/issues/733))
+* Support `rollup -c node:pkgname` ([#736](https://github.com/rollup/rollup/issues/736))
+
+## 0.32.0
+
+* Deprecate `es6` format in favour of `es` ([#468](https://github.com/rollup/rollup/issues/468))
+* Add correct `jsnext:main` build ([#726](https://github.com/rollup/rollup/pull/726))
+
+## 0.31.2
+
+* Allow `load` plugins to provide sourcemap ([#715](https://github.com/rollup/rollup/pull/715))
+* Allow `sourceMapFile` in config options ([#717](https://github.com/rollup/rollup/issues/717))
+
+## 0.31.1
+
+* Logging for errors emitted by `rollup-watch` ([#712](https://github.com/rollup/rollup/issues/712))
+
+## 0.31.0
+
+* Rewrite top-level `this` as `undefined` ([#707](https://github.com/rollup/rollup/pull/707))
+* Pass `options.acorn` to Acorn ([#564](https://github.com/rollup/rollup/issues/564))
+
+## 0.30.0
+
+* Bundle CLI ([#700](https://github.com/rollup/rollup/issues/700))
+* Ensure absolute paths are normalised ([#704](https://github.com/rollup/rollup/issues/704))
+* Allow `rollup --watch` to work with targets
+
+## 0.29.1
+
+* Merge `target` options with main options ([#701](https://github.com/rollup/rollup/issues/701))
+* Update magic-string ([#690](https://github.com/rollup/rollup/issues/690))
+
+## 0.29.0
+
+* `rollup --watch` ([#284](https://github.com/rollup/rollup/issues/284))
+
+## 0.28.0
+
+* Experimental support for incremental rebuilds ([#658](https://github.com/rollup/rollup/pull/658))
+
+## 0.27.1
+
+* Ensure names exported from a module are not replaced with reserved words ([#696](https://github.com/rollup/rollup/pull/696))
+* Revert ([#692](https://github.com/rollup/rollup/pull/692)) – resolved IDs must be strings
+
+## 0.27.0
+
+* Use native promises instead of `es6-promise` ([#689](https://github.com/rollup/rollup/issues/689))
+* Support multiple targets in config files ([#655](https://github.com/rollup/rollup/issues/655))
+* Allow `resolveId` plugin functions to return non-strings ([#692](https://github.com/rollup/rollup/pull/692))
+
+## 0.26.7
+
+* Distinguish between default and namespace imports of external module ([#637](https://github.com/rollup/rollup/issues/637))
+* Add `__esModule` property to named exports in AMD, CJS and UMD modes ([#650](https://github.com/rollup/rollup/issues/650))
+
## 0.26.6
* Deconflict named imports from external modules in ES bundles ([#659](https://github.com/rollup/rollup/issues/659))
diff --git a/LICENSE.md b/LICENSE.md
index ae037ce..ec3180a 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015 [these people](https://github.com/rollup/rollup/graphs/contributors)
+Copyright (c) 2016 [these people](https://github.com/rollup/rollup/graphs/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 6e02e51..25d1958 100644
--- a/README.md
+++ b/README.md
@@ -14,11 +14,11 @@
alt="license">
-
-
+
bundle.js` from breaking
-var log = console.error.bind(console);
-
-module.exports = function ( command ) {
- if ( command._.length > 1 ) {
- handleError({ code: 'ONE_AT_A_TIME' });
- }
-
- if ( command._.length === 1 ) {
- if ( command.input ) {
- handleError({ code: 'DUPLICATE_IMPORT_OPTIONS' });
- }
-
- command.input = command._[0];
- }
-
- if ( command.environment ) {
- command.environment.split( ',' ).forEach( function ( pair ) {
- var index = pair.indexOf( ':' );
- if ( ~index ) {
- process.env[ pair.slice( 0, index ) ] = pair.slice( index + 1 );
- } else {
- process.env[ pair ] = true;
- }
- });
- }
-
- var config = command.config === true ? 'rollup.config.js' : command.config;
-
- if ( config ) {
- config = path.resolve( config );
-
- rollup.rollup({
- entry: config,
- onwarn: function ( message ) {
- if ( /Treating .+ as external dependency/.test( message ) ) return;
- log( message );
- }
- }).then( function ( bundle ) {
- var code = bundle.generate({
- format: 'cjs'
- }).code;
-
- // temporarily override require
- var defaultLoader = require.extensions[ '.js' ];
- require.extensions[ '.js' ] = function ( m, filename ) {
- if ( filename === config ) {
- m._compile( code, filename );
- } else {
- defaultLoader( m, filename );
- }
- };
-
- try {
- var options = require( path.resolve( config ) );
- if ( Object.keys( options ).length === 0 ) {
- handleError({ code: 'MISSING_CONFIG' });
- }
- } catch ( err ) {
- handleError( err );
- }
-
- execute( options, command );
-
- require.extensions[ '.js' ] = defaultLoader;
- })
- .catch(log);
- } else {
- execute( {}, command );
- }
-};
-
-var equivalents = {
- banner: 'banner',
- footer: 'footer',
- format: 'format',
- globals: 'globals',
- id: 'moduleId',
- indent: 'indent',
- input: 'entry',
- intro: 'intro',
- name: 'moduleName',
- output: 'dest',
- outro: 'outro',
- sourcemap: 'sourceMap',
- treeshake: 'treeshake'
-};
-
-function execute ( options, command ) {
- var external = ( options.external || [] )
- .concat( command.external ? command.external.split( ',' ) : [] );
-
- if ( command.globals ) {
- var globals = Object.create( null );
-
- command.globals.split( ',' ).forEach(function ( str ) {
- var names = str.split( ':' );
- globals[ names[0] ] = names[1];
-
- // Add missing Module IDs to external.
- if ( external.indexOf( names[0] ) === -1 ) {
- external.push( names[0] );
- }
- });
-
- command.globals = globals;
- }
-
- options.onwarn = options.onwarn || log;
-
- options.external = external;
-
- options.noConflict = command.conflict === false;
- delete command.conflict;
-
- // Use any options passed through the CLI as overrides.
- Object.keys( equivalents ).forEach( function ( cliOption ) {
- if ( command.hasOwnProperty( cliOption ) ) {
- options[ equivalents[ cliOption ] ] = command[ cliOption ];
- }
- });
-
- try {
- bundle( options ).catch( handleError );
- } catch ( err ) {
- handleError( err );
- }
-}
-
-function bundle ( options ) {
- if ( !options.entry ) {
- handleError({ code: 'MISSING_INPUT_OPTION' });
- }
-
- return rollup.rollup( options ).then( function ( bundle ) {
- if ( options.dest ) {
- return bundle.write( options );
- }
-
- if ( options.sourceMap && options.sourceMap !== 'inline' ) {
- handleError({ code: 'MISSING_OUTPUT_OPTION' });
- }
-
- var result = bundle.generate( options );
-
- var code = result.code,
- map = result.map;
-
- if ( options.sourceMap === 'inline' ) {
- code += '\n//# sourceMappingURL=' + map.toUrl();
- }
-
- process.stdout.write( code );
- });
-}
diff --git a/bin/showHelp.js b/bin/showHelp.js
deleted file mode 100644
index 1cc19b6..0000000
--- a/bin/showHelp.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var fs = require( 'fs' );
-var path = require( 'path' );
-
-module.exports = function () {
- fs.readFile( path.join( __dirname, 'help.md' ), function ( err, result ) {
- var help;
-
- if ( err ) throw err;
-
- help = result.toString().replace( '<%= version %>', require( '../package.json' ).version );
- console.log( '\n' + help + '\n' );
- });
-};
diff --git a/bin/src/handleError.js b/bin/src/handleError.js
new file mode 100644
index 0000000..80892fd
--- /dev/null
+++ b/bin/src/handleError.js
@@ -0,0 +1,65 @@
+import * as chalk from 'chalk';
+
+function stderr ( msg ) {
+ console.error( msg ); // eslint-disable-line no-console
+}
+
+const handlers = {
+ MISSING_CONFIG: () => {
+ stderr( chalk.red( 'Config file must export an options object. See https://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file' ) );
+ },
+
+ MISSING_EXTERNAL_CONFIG: err => {
+ stderr( chalk.red( `Could not resolve config file ${err.config}` ) );
+ },
+
+ MISSING_INPUT_OPTION: () => {
+ stderr( chalk.red( 'You must specify an --input (-i) option' ) );
+ },
+
+ MISSING_OUTPUT_OPTION: () => {
+ stderr( chalk.red( 'You must specify an --output (-o) option when creating a file with a sourcemap' ) );
+ },
+
+ MISSING_NAME: () => {
+ stderr( chalk.red( 'You must supply a name for UMD exports (e.g. `--name myModule`)' ) );
+ },
+
+ PARSE_ERROR: err => {
+ stderr( chalk.red( `Error parsing ${err.file}: ${err.message}` ) );
+ },
+
+ ONE_AT_A_TIME: () => {
+ stderr( chalk.red( 'rollup can only bundle one file at a time' ) );
+ },
+
+ DUPLICATE_IMPORT_OPTIONS: () => {
+ stderr( chalk.red( 'use --input, or pass input path as argument' ) );
+ },
+
+ ROLLUP_WATCH_NOT_INSTALLED: () => {
+ stderr( chalk.red( 'rollup --watch depends on the rollup-watch package, which could not be found. You can install it globally (recommended) with ' ) + chalk.cyan( 'npm install -g rollup-watch' ) );
+ },
+
+ WATCHER_MISSING_INPUT_OR_OUTPUT: () => {
+ stderr( chalk.red( 'must specify --input and --output when using rollup --watch' ) );
+ }
+};
+
+export default function handleError ( err, recover ) {
+ const handler = handlers[ err && err.code ];
+
+ if ( handler ) {
+ handler( err );
+ } else {
+ stderr( chalk.red( err.message || err ) );
+
+ if ( err.stack ) {
+ stderr( chalk.grey( err.stack ) );
+ }
+ }
+
+ stderr( `Type ${chalk.cyan( 'rollup --help' )} for help, or visit https://github.com/rollup/rollup/wiki` );
+
+ if ( !recover ) process.exit( 1 );
+}
diff --git a/bin/help.md b/bin/src/help.md
similarity index 92%
rename from bin/help.md
rename to bin/src/help.md
index 46886c7..58482d5 100644
--- a/bin/help.md
+++ b/bin/src/help.md
@@ -1,4 +1,4 @@
-rollup version <%= version %>
+rollup version __VERSION__
=====================================
Usage: rollup [options]
@@ -9,9 +9,10 @@ Basic options:
-h, --help Show this help message
-c, --config Use this config file (if argument is used but value
is unspecified, defaults to rollup.config.js)
+-w, --watch Watch files in bundle and rebuild on changes
-i, --input Input (alternative to )
-o, --output