mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
5 changed files with 49 additions and 65 deletions
@ -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 ]); |
|
@ -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; |
@ -0,0 +1,32 @@ |
|||||
|
import { readFileSync } from 'fs'; |
||||
|
import babel from 'rollup-plugins-babel'; |
||||
|
import replace from 'rollup-plugins-replace'; |
||||
|
|
||||
|
var pkg = JSON.parse( readFileSync( 'package.json', 'utf-8' ) ); |
||||
|
var version = JSON.parse( pkg.version ); |
||||
|
var commitHash = (function () { |
||||
|
try { |
||||
|
return readFileSync( '.commithash', 'utf-8' ); |
||||
|
} catch ( err ) { |
||||
|
return 'unknown'; |
||||
|
} |
||||
|
})(); |
||||
|
|
||||
|
var banner = readFileSync( 'src/banner.js', 'utf-8' ) |
||||
|
.replace( '${version}', version ) |
||||
|
.replace( '${time}', new Date() ) |
||||
|
.replace( '${commitHash}', commitHash ); |
||||
|
|
||||
|
export default { |
||||
|
entry: 'src/rollup.js', |
||||
|
format: 'cjs', |
||||
|
plugins: [ |
||||
|
babel(), |
||||
|
replace({ |
||||
|
'VERSION': pkg.version |
||||
|
}) |
||||
|
], |
||||
|
external: [ 'fs' ], |
||||
|
banner: banner, |
||||
|
sourceMap: true |
||||
|
}; |
Loading…
Reference in new issue