-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
679 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2014, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const rollup = require('rollup').rollup; | ||
const rollupResolve = require('rollup-plugin-node-resolve'); | ||
const rollupCommonjs = require('rollup-plugin-commonjs'); | ||
const rollupBuiltins = require('rollup-plugin-node-builtins'); | ||
const rollupGlobals = require('rollup-plugin-node-globals'); | ||
const rollupJson = require('rollup-plugin-json'); | ||
const rollupBabel = require('rollup-plugin-babel'); | ||
const rollupFlow = require('rollup-plugin-flow'); | ||
|
||
const babelNodeOptions = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, '..', '.babelrc'), 'utf8') | ||
); | ||
const babelEs5Options = Object.assign({}, babelNodeOptions, { | ||
babelrc: false, | ||
exclude: 'node_modules/**', | ||
plugins: [ | ||
...babelNodeOptions.plugins, | ||
'external-helpers', | ||
'transform-runtime', | ||
], | ||
presets: [ | ||
[ | ||
'env', | ||
{ | ||
modules: false, | ||
}, | ||
], | ||
], | ||
runtimeHelpers: true, | ||
}); | ||
|
||
function browserBuild(entryPath, destination) { | ||
return rollup({ | ||
entry: entryPath, | ||
onwarn: () => {}, | ||
plugins: [ | ||
rollupFlow(), | ||
rollupJson(), | ||
rollupCommonjs(), | ||
rollupBabel(babelEs5Options), | ||
rollupGlobals(), | ||
rollupBuiltins(), | ||
rollupResolve(), | ||
], | ||
useStrict: false, | ||
}).then(bundle => { | ||
return bundle.write({ | ||
dest: destination, | ||
format: 'cjs', | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = browserBuild; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.