Skip to content

Commit

Permalink
Output ESM build, and make module tree-shakeable (@unindented in supa…
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarfany committed Apr 30, 2019
1 parent 1b0663e commit 6fc1182
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 90 deletions.
22 changes: 15 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{
"presets": [
"es2015",
"react",
"stage-1"
"@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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
examples/*
esm/*
lib/*
umd/*
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@
2,
"never"
]
},
"settings": {
"react": {
"version": "16.0"
}
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.log
*.swp
node_modules
esm
lib
umd
.idea
.idea
package-lock.json
File renamed without changes.
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
"version": "5.0.1",
"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",
"test": "jest --config ./.jestrc.json",
"test:watch": "npm run test -- --watch",
"posttest": "npm run lint"
},
Expand All @@ -35,25 +39,25 @@
"redux": "^3.6.0 || ^4.0.0"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/preset-env": "^7.1.5",
"@babel/preset-react": "^7.0.0",
"@types/history": "^4.5.0",
"@types/react": "*",
"babel-cli": "^6.18.0",
"babel-core": "^6.20.0",
"babel-eslint": "^7.1.1",
"babel-jest": "^17.0.2",
"babel-loader": "^6.3.1",
"babel-plugin-rewire": "^1.0.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-1": "^6.16.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-rewire": "^1.2.0",
"babel-template": "^6.2.0",
"babel-types": "^6.2.0",
"enzyme": "3.1.1",
"enzyme-adapter-react-16": "^1.0.4",
"eslint": "^3.12.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.8.0",
"jest": "^17.0.2",
"eslint": "^5.9.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"jest": "^23.6.0",
"prop-types": "^15.5.8",
"raf": "^3.4.0",
"react": "^16.0.0",
Expand Down
15 changes: 0 additions & 15 deletions src/createAll.js

This file was deleted.

26 changes: 9 additions & 17 deletions src/immutable.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 6fc1182

Please sign in to comment.