Browse Source

Merge pull request #165 from rollup/lean

0.18.1
better-aggressive
Rich Harris 9 years ago
parent
commit
5533c3f277
  1. 3
      .babelrc
  2. 4
      CHANGELOG.md
  3. 5
      browser/fs.js
  4. 1
      browser/promise.js
  5. 17
      browser/sander.js
  6. 19
      gobblefile.js
  7. 26
      package.json
  8. 2
      src/Bundle.js
  9. 2
      src/Module.js
  10. 2
      src/rollup.js
  11. 30
      src/utils/fs.js
  12. 4
      src/utils/load.js
  13. 4
      src/utils/resolveId.js

3
.babelrc

@ -14,5 +14,6 @@
"loose": [ "loose": [
"es6.classes", "es6.classes",
"es6.destructuring" "es6.destructuring"
] ],
"compact": false
} }

4
CHANGELOG.md

@ -1,5 +1,9 @@
# rollup changelog # rollup changelog
## 0.18.1
* Include `acorn.parse` in bundle, remove `sander` from dependencies, simplify build
## 0.18.0 ## 0.18.0
* Internal rewrite * Internal rewrite

5
browser/fs.js

@ -0,0 +1,5 @@
const nope = method => `Cannot use fs.${method} inside browser`;
export const readdirSync = nope( 'readdirSync' );
export const readFileSync = nope( 'readFileSync' );
export const writeFile = nope( 'writeFile' );

1
browser/promise.js

@ -0,0 +1 @@
export default window.Promise;

17
browser/sander.js

@ -1,17 +0,0 @@
export function readdirSync () {
throw new Error( 'Cannot use sander.readdirSync inside browser' );
}
export function readFile () {
throw new Error( 'Cannot use sander.readFile inside browser' );
}
export function readFileSync () {
throw new Error( 'Cannot use sander.readFileSync inside browser' );
}
export function writeFile () {
throw new Error( 'Cannot use sander.writeFile inside browser' );
}
export const Promise = window.Promise;

19
gobblefile.js

@ -8,30 +8,27 @@ var node = src
entry: 'rollup.js', entry: 'rollup.js',
dest: 'rollup.js', dest: 'rollup.js',
format: 'cjs', format: 'cjs',
external: [ 'sander', 'acorn' ], external: [ 'fs' ],
sourceMap: true sourceMap: true
}) })
.transform( 'babel' ); .transform( 'babel' );
var browserPlaceholders = { var browserPlaceholders = {
sander: fs.readFileSync( 'browser/sander.js' ).toString() fs: fs.readFileSync( 'browser/fs.js' ).toString(),
promise: fs.readFileSync( 'browser/promise.js' ).toString()
}; };
var browser = src var browser = src
.transform( 'rollup-babel', { .transform( 'rollup-babel', {
entry: 'rollup.js', entry: 'rollup.js',
dest: 'rollup.browser.js', dest: 'rollup.browser.js',
format: 'cjs', format: 'umd',
moduleName: 'rollup',
load: function ( id ) { load: function ( id ) {
if ( ~id.indexOf( 'sander.js' ) ) return browserPlaceholders.sander; if ( ~id.indexOf( 'fs.js' ) ) return browserPlaceholders.fs;
if ( ~id.indexOf( 'es6-promise' ) ) return browserPlaceholders.promise;
return fs.readFileSync( id ).toString(); return fs.readFileSync( id ).toString();
}, }
external: [ 'acorn' ]
})
.transform( 'browserify', {
entries: [ './rollup.browser' ],
dest: 'rollup.browser.js',
standalone: 'rollup'
}); });
module.exports = gobble([ node, browser ]); module.exports = gobble([ node, browser ]);

26
package.json

@ -1,6 +1,6 @@
{ {
"name": "rollup", "name": "rollup",
"version": "0.18.0", "version": "0.18.1",
"description": "Next-generation ES6 module bundler", "description": "Next-generation ES6 module bundler",
"main": "dist/rollup.js", "main": "dist/rollup.js",
"jsnext:main": "src/rollup.js", "jsnext:main": "src/rollup.js",
@ -39,32 +39,30 @@
}, },
"homepage": "https://github.com/rollup/rollup", "homepage": "https://github.com/rollup/rollup",
"devDependencies": { "devDependencies": {
"babel": "^5.8.21", "acorn": "^2.3.0",
"babel-core": "^5.5.8", "babel-core": "^5.5.8",
"chalk": "^1.0.0",
"codecov.io": "^0.1.6", "codecov.io": "^0.1.6",
"console-group": "^0.1.2", "console-group": "^0.1.2",
"es6-promise": "^3.0.2",
"eslint": "^1.1.0", "eslint": "^1.1.0",
"estree-walker": "^0.1.3",
"gobble": "^0.10.1", "gobble": "^0.10.1",
"gobble-babel": "^5.5.8", "gobble-babel": "^5.5.8",
"gobble-browserify": "^0.6.1",
"gobble-cli": "^0.4.2", "gobble-cli": "^0.4.2",
"gobble-esperanto-bundle": "^0.2.0", "gobble-rollup": "^0.10.0",
"gobble-rollup": "^0.8.0", "gobble-rollup-babel": "^0.4.0",
"gobble-rollup-babel": "^0.1.0",
"istanbul": "^0.3.20", "istanbul": "^0.3.20",
"magic-string": "^0.7.0",
"mocha": "^2.2.4", "mocha": "^2.2.4",
"remap-istanbul": "^0.2.0", "remap-istanbul": "^0.2.0",
"source-map": "^0.4.4"
},
"dependencies": {
"acorn": "^2.3.0",
"chalk": "^1.0.0",
"estree-walker": "^0.1.3",
"magic-string": "^0.7.0",
"minimist": "^1.1.1",
"sander": "^0.3.3", "sander": "^0.3.3",
"source-map": "^0.4.4",
"source-map-support": "^0.3.1" "source-map-support": "^0.3.1"
}, },
"dependencies": {
"minimist": "^1.1.1"
},
"files": [ "files": [
"src", "src",
"dist", "dist",

2
src/Bundle.js

@ -1,4 +1,4 @@
import { Promise } from 'sander'; import Promise from 'es6-promise/lib/es6-promise/promise';
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { blank, keys } from './utils/object'; import { blank, keys } from './utils/object';
import Module from './Module'; import Module from './Module';

2
src/Module.js

@ -1,4 +1,4 @@
import { parse } from 'acorn'; import { parse } from 'acorn/src/index';
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import Statement from './Statement'; import Statement from './Statement';

2
src/rollup.js

@ -1,5 +1,5 @@
import { basename } from './utils/path'; import { basename } from './utils/path';
import { writeFile } from 'sander'; import { writeFile } from './utils/fs';
import { keys } from './utils/object'; import { keys } from './utils/object';
import SOURCEMAPPING_URL from './utils/sourceMappingURL'; import SOURCEMAPPING_URL from './utils/sourceMappingURL';
import Bundle from './Bundle'; import Bundle from './Bundle';

30
src/utils/fs.js

@ -0,0 +1,30 @@
import Promise from 'es6-promise/lib/es6-promise/promise';
import * as fs from 'fs';
import { dirname } from './path';
function mkdirpath ( path ) {
const dir = dirname( path );
try {
fs.readdirSync( dir );
} catch ( err ) {
mkdirpath( dir );
fs.mkdirSync( dir );
}
}
export function writeFile ( dest, data ) {
return new Promise( ( fulfil, reject ) => {
mkdirpath( dest );
fs.writeFile( dest, data, err => {
if ( err ) {
reject( err );
} else {
fulfil();
}
});
});
}
export const readdirSync = fs.readdirSync;
export const readFileSync = fs.readFileSync;

4
src/utils/load.js

@ -1,8 +1,8 @@
import { readFileSync } from 'sander'; import { readFileSync } from './fs';
export function defaultLoader ( id, options ) { export function defaultLoader ( id, options ) {
// TODO support plugins e.g. !css and !json? // TODO support plugins e.g. !css and !json?
const source = readFileSync( id, { encoding: 'utf-8' }); const source = readFileSync( id, 'utf-8' );
return options.transform.reduce( ( source, transformer ) => { return options.transform.reduce( ( source, transformer ) => {
return transformer( source, id ); return transformer( source, id );

4
src/utils/resolveId.js

@ -1,5 +1,5 @@
import { absolutePath, dirname, isAbsolute, resolve } from './path'; import { absolutePath, dirname, isAbsolute, resolve } from './path';
import { readdirSync, readFileSync } from 'sander'; import { readdirSync, readFileSync } from './fs';
function dirExists ( dir ) { function dirExists ( dir ) {
try { try {
@ -58,7 +58,7 @@ export function defaultExternalResolver ( id, importer ) {
let pkg; let pkg;
try { try {
pkg = JSON.parse( readFileSync( pkgPath ).toString() ); pkg = JSON.parse( readFileSync( pkgPath, 'utf-8' ) );
} catch ( err ) { } catch ( err ) {
throw new Error( `Missing or malformed package.json: ${modulePath}` ); throw new Error( `Missing or malformed package.json: ${modulePath}` );
} }

Loading…
Cancel
Save