Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle cjs and es formats #2358

Merged
merged 4 commits into from
Nov 3, 2017
Merged
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
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "redux",
"version": "3.7.2",
"description": "Predictable state container for JavaScript apps",
"main": "lib/index.js",
"module": "es/index.js",
"main": "lib/redux.js",
"module": "es/redux.js",
"typings": "./index.d.ts",
"files": [
"dist",
Expand All @@ -15,13 +15,14 @@
"scripts": {
"clean": "rimraf lib dist es coverage",
"lint": "eslint src test build",
"pretest": "npm run build:commonjs",
"test": "cross-env BABEL_ENV=commonjs jest",
"test:watch": "npm test -- --watch",
"test:cov": "npm test -- --coverage",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -i src/index.js -o dist/redux.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -i src/index.js -o dist/redux.min.js",
"build:commonjs": "cross-env NODE_ENV=cjs rollup -c -o lib/redux.js",
"build:es": "cross-env BABEL_ENV=es NODE_ENV=es rollup -c -o es/redux.js",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -c -o dist/redux.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -c -o dist/redux.min.js",
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"prepare": "npm run clean && npm run lint && npm test && npm run build",
"examples:lint": "eslint examples",
Expand Down
31 changes: 23 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@ import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import uglify from 'rollup-plugin-uglify'

var env = process.env.NODE_ENV
var config = {
output: {
format: 'umd',
name: 'Redux'
},
plugins: [
const env = process.env.NODE_ENV
const config = {
input: 'src/index.js',
plugins: []
}

if (env === 'es' || env === 'cjs') {
config.output = { format: env }
config.external = [
'lodash/isPlainObject',
'lodash-es/isPlainObject',
'symbol-observable'
];
config.plugins.push(
babel()
)
}

if (env === 'development' || env === 'production') {
config.output = { format: 'umd' }
config.name = 'Redux'
config.plugins.push(
nodeResolve({
jsnext: true
}),
Expand All @@ -19,7 +34,7 @@ var config = {
replace({
'process.env.NODE_ENV': JSON.stringify(env)
})
]
)
}

if (env === 'production') {
Expand Down
2 changes: 1 addition & 1 deletion test/applyMiddleware.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStore, applyMiddleware } from '../src/index'
import { createStore, applyMiddleware } from '../'
import * as reducers from './helpers/reducers'
import { addTodo, addTodoAsync, addTodoIfEmpty } from './helpers/actionCreators'
import { thunk } from './helpers/middleware'
Expand Down
2 changes: 1 addition & 1 deletion test/bindActionCreators.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bindActionCreators, createStore } from '../src'
import { bindActionCreators, createStore } from '../'
import { todos } from './helpers/reducers'
import * as actionCreators from './helpers/actionCreators'

Expand Down
3 changes: 1 addition & 2 deletions test/combineReducers.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-console */
import { combineReducers } from '../src'
import createStore from '../src/createStore'
import { createStore, combineReducers } from '../'
import ActionTypes from '../src/utils/actionTypes'

describe('Utils', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/compose.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose } from '../src'
import { compose } from '../'

describe('Utils', () => {
describe('compose', () => {
Expand Down
12 changes: 6 additions & 6 deletions test/createStore.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createStore, combineReducers } from '../src/index'
import {
addTodo,
dispatchInMiddle,
import { createStore, combineReducers } from '../'
import {
addTodo,
dispatchInMiddle,
getStateInMiddle,
subscribeInMiddle,
unsubscribeInMiddle,
throwError,
unknownAction
throwError,
unknownAction
} from './helpers/actionCreators'
import * as reducers from './helpers/reducers'
import * as Rx from 'rxjs'
Expand Down