Skip to content

Commit

Permalink
Output ESM build, and make module tree-shakeable (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
unindented authored and supasate committed Dec 15, 2018
1 parent 68cf17a commit 87ed567
Show file tree
Hide file tree
Showing 9 changed files with 499 additions and 557 deletions.
15 changes: 12 additions & 3 deletions .babelrc
Expand Up @@ -3,7 +3,16 @@
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"rewire"
]
"env": {
"esm": {
"presets": [
["@babel/preset-env", { "modules": false }]
]
},
"test": {
"plugins": [
"rewire"
]
}
}
}
1 change: 1 addition & 0 deletions .eslintignore
@@ -1,3 +1,4 @@
examples/*
esm/*
lib/*
umd/*
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,5 +2,6 @@
*.log
*.swp
node_modules
esm
lib
umd
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -3,21 +3,25 @@
"version": "6.0.0",
"description": "A Redux binding for React Router v4",
"main": "lib/index.js",
"module": "esm/index.js",
"types": "./index.d.ts",
"sideEffects": false,
"author": "Supasate Choochaisri",
"license": "MIT",
"files": [
"*.md",
"*.js",
"*.ts",
"esm",
"lib",
"umd"
],
"scripts": {
"build:esm": "BABEL_ENV=esm babel src --out-dir esm",
"build:commonjs": "BABEL_ENV=commonjs babel src --out-dir lib",
"build:umd": "NODE_ENV=development webpack src/index.js umd/ConnectedReactRouter.js",
"build:umd:min": "NODE_ENV=production webpack -p src/index.js umd/ConnectedReactRouter.min.js",
"build": "npm run build:commonjs & npm run build:umd & npm run build:umd:min",
"build": "npm run build:esm & npm run build:commonjs & npm run build:umd & npm run build:umd:min",
"lint": "eslint .",
"test": "jest --config ./.jestrc.json",
"test:watch": "npm run test -- --watch",
Expand Down
15 changes: 0 additions & 15 deletions src/createAll.js

This file was deleted.

26 changes: 9 additions & 17 deletions src/immutable.js
@@ -1,19 +1,11 @@
import createAll from './createAll'
import createConnectedRouter from "./ConnectedRouter"
import createConnectRouter from "./reducer"
import createSelectors from "./selectors"
import immutableStructure from './structure/immutable'

export const {
LOCATION_CHANGE,
CALL_HISTORY_METHOD,
push,
replace,
go,
goBack,
goForward,
routerActions,
ConnectedRouter,
connectRouter,
routerMiddleware,
getLocation,
getAction,
createMatchSelector,
} = createAll(immutableStructure)
export { LOCATION_CHANGE, CALL_HISTORY_METHOD, push, replace, go, goBack, goForward, routerActions } from "./actions"
export { default as routerMiddleware } from "./middleware"

export const ConnectedRouter = /*#__PURE__*/ createConnectedRouter(immutableStructure)
export const connectRouter = /*#__PURE__*/ createConnectRouter(immutableStructure)
export const { getLocation, getAction, createMatchSelector } = /*#__PURE__*/ createSelectors(immutableStructure)
28 changes: 10 additions & 18 deletions src/index.js
@@ -1,19 +1,11 @@
import createAll from './createAll'
import plainStructure from './structure/plain'
import createConnectedRouter from "./ConnectedRouter"
import createConnectRouter from "./reducer"
import createSelectors from "./selectors"
import plainStructure from "./structure/plain"

export const {
LOCATION_CHANGE,
CALL_HISTORY_METHOD,
push,
replace,
go,
goBack,
goForward,
routerActions,
ConnectedRouter,
connectRouter,
routerMiddleware,
getLocation,
getAction,
createMatchSelector,
} = createAll(plainStructure)
export { LOCATION_CHANGE, CALL_HISTORY_METHOD, push, replace, go, goBack, goForward, routerActions } from "./actions"
export { default as routerMiddleware } from "./middleware"

export const ConnectedRouter = /*#__PURE__*/ createConnectedRouter(plainStructure)
export const connectRouter = /*#__PURE__*/ createConnectRouter(plainStructure)
export const { getLocation, getAction, createMatchSelector } = /*#__PURE__*/ createSelectors(plainStructure)
26 changes: 9 additions & 17 deletions src/seamless-immutable.js
@@ -1,19 +1,11 @@
import createAll from './createAll'
import createConnectedRouter from "./ConnectedRouter"
import createConnectRouter from "./reducer"
import createSelectors from "./selectors"
import immutableStructure from './structure/seamless-immutable'

export const {
LOCATION_CHANGE,
CALL_HISTORY_METHOD,
push,
replace,
go,
goBack,
goForward,
routerActions,
ConnectedRouter,
connectRouter,
routerMiddleware,
getLocation,
getAction,
createMatchSelector,
} = createAll(immutableStructure)
export { LOCATION_CHANGE, CALL_HISTORY_METHOD, push, replace, go, goBack, goForward, routerActions } from "./actions"
export { default as routerMiddleware } from "./middleware"

export const ConnectedRouter = /*#__PURE__*/ createConnectedRouter(immutableStructure)
export const connectRouter = /*#__PURE__*/ createConnectRouter(immutableStructure)
export const { getLocation, getAction, createMatchSelector } = /*#__PURE__*/ createSelectors(immutableStructure)

0 comments on commit 87ed567

Please sign in to comment.