Browse Source

Merge pull request #231 from rollup/0.20.2

0.20.2
better-aggressive
Rich Harris 9 years ago
parent
commit
15151753e8
  1. 3
      .babelrc
  2. 6
      CHANGELOG.md
  3. 7
      bin/runRollup.js
  4. 57
      gobblefile.js
  5. 15
      package.json
  6. 12
      rollup.config.browser.js
  7. 43
      rollup.config.js
  8. 4
      src/Bundle.js

3
.babelrc

@ -15,5 +15,6 @@
"es6.classes",
"es6.destructuring"
],
"compact": false
"compact": false,
"sourceMap": true
}

6
CHANGELOG.md

@ -1,5 +1,11 @@
# rollup changelog
## 0.20.2
* Handle errors in build config file
* More robust deconflicting, in cases where e.g. `foo$1` already exists
* Use Rollup CLI for own build process
## 0.20.1
* Support `--config` file to enable plugins with CLI ([#226](https://github.com/rollup/rollup/pulls/226))

7
bin/runRollup.js

@ -40,7 +40,12 @@ module.exports = function ( command ) {
}
};
const options = require( path.resolve( config ) );
try {
var options = require( path.resolve( config ) );
} catch ( err ) {
handleError( err );
}
execute( options, command );
require.extensions[ '.js' ] = defaultLoader;

57
gobblefile.js

@ -1,57 +0,0 @@
var gobble = require( 'gobble' );
var fs = require( 'fs' );
var version = require( './package.json' ).version;
var commitHash = (function () {
try {
return fs.readFileSync( '.commithash', 'utf-8' );
} catch ( err ) {
return 'unknown';
}
})();
var banner = fs.readFileSync( 'src/banner.js' ).toString()
.replace( '${version}', version )
.replace( '${time}', new Date() )
.replace( '${commitHash}', commitHash );
var src = gobble( 'src' );
var node = src
.transform( 'rollup-babel', {
entry: 'rollup.js',
dest: 'rollup.js',
format: 'cjs',
external: [ 'fs' ],
sourceMap: true,
banner: banner,
load: function ( id ) {
if ( ~id.indexOf( 'rollup.js' ) ) {
return fs.readFileSync( 'src/rollup.js', 'utf-8' ).replace( /<@VERSION@>/, version );
}
}
});
var browserPlaceholders = {
fs: fs.readFileSync( 'browser/fs.js' ).toString(),
promise: fs.readFileSync( 'browser/promise.js' ).toString()
};
var browser = src
.transform( 'rollup-babel', {
entry: 'rollup.js',
dest: 'rollup.browser.js',
format: 'umd',
moduleName: 'rollup',
sourceMap: true,
banner: banner,
load: function ( id ) {
if ( ~id.indexOf( 'rollup.js' ) ) {
return fs.readFileSync( 'src/rollup.js', 'utf-8' ).replace( /<@VERSION@>/, version );
}
if ( ~id.indexOf( 'fs.js' ) ) return browserPlaceholders.fs;
if ( ~id.indexOf( 'es6-promise' ) ) return browserPlaceholders.promise;
}
});
module.exports = gobble([ node, browser ]);

15
package.json

@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "0.20.1",
"version": "0.20.2",
"description": "Next-generation ES6 module bundler",
"main": "dist/rollup.js",
"jsnext:main": "src/rollup.js",
@ -14,8 +14,9 @@
"test-coverage": "rm -rf coverage/* && istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/test.js",
"posttest-coverage": "remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.lcov -t lcovonly -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped -t html -b dist",
"ci": "npm run test-coverage && codecov < coverage/coverage-remapped.lcov",
"build": "git rev-parse HEAD > .commithash && gobble build -f dist",
"prepublish": "npm test",
"build": "git rev-parse HEAD > .commithash && rollup -c -o dist/rollup.js",
"build:browser": "git rev-parse HEAD > .commithash && rollup -c rollup.config.browser.js -o dist/rollup.browser.js",
"prepublish": "npm test && npm run build:browser",
"lint": "eslint src"
},
"repository": {
@ -46,15 +47,13 @@
"es6-promise": "^3.0.2",
"eslint": "^1.7.1",
"estree-walker": "^0.2.0",
"gobble": "^0.10.1",
"gobble-babel": "^5.5.8",
"gobble-cli": "^0.6.0",
"gobble-rollup": "^0.10.0",
"gobble-rollup-babel": "^0.6.1",
"istanbul": "^0.4.0",
"magic-string": "^0.8.0",
"mocha": "^2.3.3",
"remap-istanbul": "^0.3.1",
"rollup": "^0.20.1",
"rollup-plugin-babel": "^1.0.0",
"rollup-plugin-npm": "^1.0.0",
"rollup-plugin-replace": "^1.0.1",
"sander": "^0.4.0",
"source-map": "^0.5.3",

12
rollup.config.browser.js

@ -0,0 +1,12 @@
import config from './rollup.config.js';
config.plugins.push({
load: function ( id ) {
if ( ~id.indexOf( 'fs.js' ) ) return readFileSync( 'browser/fs.js' ).toString();
if ( ~id.indexOf( 'es6-promise' ) ) return readFileSync( 'browser/promise.js' ).toString();
}
});
config.format = 'umd';
export default config;

43
rollup.config.js

@ -0,0 +1,43 @@
import { readFileSync } from 'fs';
import babel from 'rollup-plugin-babel';
import npm from 'rollup-plugin-npm';
import replace from 'rollup-plugin-replace';
var pkg = JSON.parse( readFileSync( 'package.json', 'utf-8' ) );
var commitHash = (function () {
try {
return readFileSync( '.commithash', 'utf-8' );
} catch ( err ) {
return 'unknown';
}
})();
var banner = readFileSync( 'src/banner.js', 'utf-8' )
.replace( '${version}', pkg.version )
.replace( '${time}', new Date() )
.replace( '${commitHash}', commitHash );
export default {
entry: 'src/rollup.js',
format: 'cjs',
plugins: [
babel({
//include: [ 'src/**', 'node_modules/acorn/**' ]
}),
npm({
jsnext: true
}),
replace({
include: 'src/rollup.js',
delimiters: [ '<@', '@>' ],
sourceMap: true,
values: { 'VERSION': pkg.version }
})
],
external: [ 'fs' ],
banner: banner,
sourceMap: true
};

4
src/Bundle.js

@ -93,8 +93,8 @@ export default class Bundle {
keys( this.assumedGlobals ).forEach( name => used[ name ] = 1 );
function getSafeName ( name ) {
if ( used[ name ] ) {
return `${name}$${used[name]++}`;
while ( used[ name ] ) {
name += `$${used[name]++}`;
}
used[ name ] = 1;

Loading…
Cancel
Save