Skip to content

Commit e2aba19

Browse files
pshrmnmjackson
authored andcommitted
Switch react-router-config to rollup
1 parent 3b9a50e commit e2aba19

File tree

8 files changed

+85
-70
lines changed

8 files changed

+85
-70
lines changed

packages/react-router-config/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ es
22
node_modules
33
umd
44
/*.js
5-
!webpack.config.js
5+
!rollup.config.js
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
{
2-
"presets": [
3-
"../tools/es2015-preset",
4-
"stage-1",
5-
"react"
6-
],
7-
"env": {
8-
"production": {
9-
"plugins": [
10-
"dev-expression",
11-
"transform-react-remove-prop-types"
12-
]
13-
}
14-
}
2+
"presets": [ "../tools/babel-preset" ]
153
}

packages/react-router-config/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"babel-eslint": "^6.0.4",
3434
"babel-loader": "^6.2.10",
3535
"babel-plugin-dev-expression": "^0.2.1",
36+
"babel-plugin-external-helpers": "^6.22.0",
3637
"babel-plugin-transform-react-remove-prop-types": "^0.2.11",
3738
"babel-preset-es2015": "^6.14.0",
3839
"babel-preset-react": "^6.5.0",
@@ -47,8 +48,12 @@
4748
"react-addons-test-utils": "^15.4.2",
4849
"react-dom": "^15.3.0",
4950
"react-router": "^4.1.1",
50-
"webpack": "^1.13.1",
51-
"webpack-dev-server": "^1.14.1"
51+
"rollup": "^0.45.2",
52+
"rollup-plugin-babel": "^2.7.1",
53+
"rollup-plugin-commonjs": "^8.0.2",
54+
"rollup-plugin-node-resolve": "^3.0.0",
55+
"rollup-plugin-replace": "^1.1.1",
56+
"rollup-plugin-uglify": "^2.0.1"
5257
},
5358
"browserify": {
5459
"transform": [
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import babel from 'rollup-plugin-babel'
2+
import uglify from 'rollup-plugin-uglify'
3+
import replace from 'rollup-plugin-replace'
4+
import commonjs from 'rollup-plugin-commonjs'
5+
import resolve from 'rollup-plugin-node-resolve'
6+
7+
const config = {
8+
entry: 'modules/index.js',
9+
moduleName: 'ReactRouterConfig',
10+
globals: {
11+
react: 'React',
12+
'react-router/Switch': 'ReactRouter.Switch',
13+
'react-router/Router': 'ReactRouter.Router',
14+
'react-router/Route': 'ReactRouter.Route',
15+
'react-router/matchPath': 'ReactRouter.matchPath',
16+
},
17+
external: [
18+
'react',
19+
'react-router/Switch',
20+
'react-router/Router',
21+
'react-router/Route',
22+
'react-router/matchPath',
23+
],
24+
plugins: [
25+
babel({
26+
exclude: 'node_modules/**'
27+
}),
28+
resolve(),
29+
commonjs({
30+
include: /node_modules/
31+
}),
32+
replace({ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV) })
33+
]
34+
}
35+
36+
if (process.env.NODE_ENV === 'production') {
37+
config.plugins.push(uglify())
38+
}
39+
40+
export default config
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const BABEL_ENV = process.env.BABEL_ENV
2+
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs'
3+
4+
const plugins = []
5+
6+
if (BABEL_ENV === 'umd') {
7+
plugins.push('external-helpers')
8+
}
9+
10+
if (process.env.NODE_ENV === 'production') {
11+
plugins.push(
12+
'dev-expression',
13+
'transform-react-remove-prop-types'
14+
)
15+
}
16+
17+
module.exports = {
18+
presets: [
19+
[ 'es2015', {
20+
loose: true,
21+
modules: building ? false : 'commonjs'
22+
}],
23+
"stage-1",
24+
"react"
25+
],
26+
plugins: plugins
27+
}

packages/react-router-config/tools/build.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ exec('babel modules -d es --ignore __tests__', {
2323

2424
console.log('\nBuilding react-router-config.js ...')
2525

26-
exec('webpack modules/index.js umd/react-router-config.js', {
27-
NODE_ENV: 'development'
28-
})
26+
exec(
27+
'rollup -c -f umd -o umd/react-router-config.js',
28+
{ NODE_ENV: 'development', BABEL_ENV: 'umd' }
29+
)
2930

30-
console.log('\nBuilding react-router-config.min.js ...')
31+
console.log('\nBuilding react-router.min.js ...')
3132

32-
exec('webpack -p modules/index.js umd/react-router-config.min.js', {
33-
NODE_ENV: 'production'
34-
})
33+
exec(
34+
'rollup -c -f umd -o umd/react-router-config.min.js',
35+
{ NODE_ENV: 'production', BABEL_ENV: 'umd' }
36+
)
3537

3638
const size = gzipSize.sync(
3739
fs.readFileSync('umd/react-router-config.min.js')

packages/react-router-config/tools/es2015-preset.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/react-router-config/webpack.config.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)