Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Start rollup integration #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name" : "reason-react-example",
"reason" : { "react-jsx" : true},
"bs-dependencies": ["reason-react", "reason-js"],
"package-specs": ["es6", "commonjs"],
"sources": [
{
"dir": "src",
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"start": "bsb -make-world -w",
"build": "webpack -w",
"rollup": "node ./rollup",
"clean": "bsb -clean-world"
},
"keywords": [],
Expand All @@ -24,6 +25,12 @@
},
"devDependencies": {
"bs-platform": "^1.6.0",
"webpack": "^1.14.0"
"rollup": "^0.41.6",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-watch": "^3.2.2",
"webpack": "^2.3.2",
"webpack-dev-server": "^2.4.2"
}
}
72 changes: 72 additions & 0 deletions rollup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const rollup = require('rollup').rollup;
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const path = require('path');

const config = {
entry: {
simple: './lib/es6/src/simple/simpleRoot.js',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only simple and logo work out of the box. todomvc needs to do something about directors querystring and util dependencies. interop probably needs some configuraiton around commonjs modules.

logo: './lib/es6/src/logo/logoRoot.js',
// TODO: enable these
// todomvc: './lib/es6/src/todomvc/app.js',
// interop: './src/interop/interopRoot.js',
},
};
Object.keys(config.entry)
.forEach(key => {
const entry = config.entry[key];
rollup({
entry: entry, // 'lib/es6/src/' + entry + '.js',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
}),
nodeResolve({
jsnext: true,
main: true,
module: true,
}),

commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**',
// exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],

// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false,
preferBuiltins: true,

// if false then skip sourceMap generation for CommonJS modules
sourceMap: false,

// explicitly specify unresolvable named exports
// (see below for more details)
namedExports: {
'react': [
'createClass',
'createElement',
],
'react-dom': [
'render'
]
},

// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
// ignore: [ 'conditional-runtime-dependency' ]
}),
]
})
.then((result) => {
// const filename = last(entry.split('/'));
return result.write({
dest: path.join(__dirname, 'rollupOutputs', key + '.js'),
format: 'iife'
});
})
.catch(console.log);
});