You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

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 ]);