Skip to content

Commit b7cc0ab

Browse files
authored
Merge pull request #64 from metalabdesign/es-modules
Add es module build
2 parents 51c995e + 208beba commit b7cc0ab

File tree

9 files changed

+180
-45
lines changed

9 files changed

+180
-45
lines changed

.babelrc

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
{
22
"presets": [
3-
["@babel/preset-env", {
4-
"shippedProposals": true,
5-
"targets": {
6-
"node": "8"
3+
[
4+
"@babel/preset-env", {
5+
"modules": false,
6+
"shippedProposals": true,
7+
"targets": {
8+
"node": 8
9+
}
710
}
8-
}],
11+
],
912
"@babel/preset-react",
1013
"@babel/preset-flow"
1114
],
1215
"plugins": [
1316
"@babel/plugin-proposal-class-properties",
14-
"@babel/plugin-syntax-dynamic-import"
17+
[
18+
"module-resolver",
19+
{
20+
"cwd": "babelrc",
21+
"alias": {
22+
"^(flowtip-core|flowtip-react-dom)/(lib|es|src)($|/.*$)":
23+
"./packages/\\1/src/\\3",
24+
"^(flowtip-core|flowtip-react-dom)$": "./packages/\\1/src",
25+
}
26+
}
27+
]
1528
],
1629
"env": {
1730
"test": {
1831
"plugins": [
19-
["module-resolver", {
20-
"alias": {
21-
"flowtip-core/lib": "./packages/flowtip-core/src",
22-
"flowtip-core": "./packages/flowtip-core/src",
23-
"flowtip-react-dom/lib": "./packages/flowtip-react-dom/src",
24-
"flowtip-react-dom": "./packages/flowtip-react-dom/src",
25-
}
26-
}]
32+
"@babel/plugin-transform-modules-commonjs"
33+
]
34+
},
35+
"lib": {
36+
"plugins": [
37+
"@babel/plugin-transform-modules-commonjs",
38+
["module-resolver", {}]
39+
]
40+
},
41+
"es": {
42+
"plugins": [
43+
["module-resolver", {}]
2744
]
2845
}
2946
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
coverage
33
dist
4+
es
45
lib
56
flow-typed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ suppress_comment=\\(.\\|\n\\)*\\$ExpectError
2020
# Map requests to `lib` folder in each package to `src`. This makes flow
2121
# reference the src files and prevents the need for running the prepare script
2222
# when flow-checking changes across packages.
23-
module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)/lib\($\|/.*$\)' -> '<PROJECT_ROOT>/packages/\1/src\2'
23+
module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)/\(lib\|es\|src\)\($\|/.*$\)' -> '<PROJECT_ROOT>/packages/\1/src\3'
2424
module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)$' -> '<PROJECT_ROOT>/packages/\1/src'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
*.log
33
coverage
4+
es
45
lib
56
dist

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules
22
coverage
33
dist
4+
es
45
lib
56
flow-typed

package-lock.json

Lines changed: 119 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
{
22
"private": true,
3+
"name": "flowtip-packages",
34
"scripts": {
4-
"flow": "./node_modules/.bin/flow",
5-
"format": "./node_modules/.bin/prettier --write '**/*.js'",
6-
"lerna": "./node_modules/.bin/lerna",
7-
"lint": "./node_modules/.bin/eslint .",
8-
"prepare": "./node_modules/.bin/lerna bootstrap",
9-
"spec": "./node_modules/.bin/jest --runInBand=${SPEC_SERIAL:-$CI} --coverage=${SPEC_COVERAGE:-$CI}",
5+
"build": "npm run clean && npm run build:flow && npm run build:es && npm run build:lib",
6+
"build:es": "BABEL_ENV=es npx babel --copy-files -s --relative -d ../es packages/*/src",
7+
"build:flow": "npx lerna exec ncp src es && npx lerna exec ncp src lib && npx renamer --regex --find '$' --replace '.flow' 'packages/*/@(es|lib)/**/*.js'",
8+
"build:lib": "BABEL_ENV=lib npx babel --copy-files -s --relative -d ../lib packages/*/src",
9+
"clean": "npx lerna exec rimraf lib es",
10+
"flow": "npx flow",
11+
"format": "npx prettier --write '**/*.js'",
12+
"lint": "npx eslint .",
13+
"prepare": "npx lerna bootstrap && npm run build",
14+
"spec": "npx jest --runInBand=${SPEC_SERIAL:-$CI} --coverage=${SPEC_COVERAGE:-$CI}",
1015
"spec:watch": "npm run spec -- --watch",
1116
"test": "npm run flow --silent && npm run lint --slient && npm run spec --silent"
1217
},
1318
"devDependencies": {
1419
"@babel/cli": "^7.0.0-beta.40",
1520
"@babel/core": "^7.0.0-beta.40",
1621
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.40",
22+
"@babel/plugin-transform-modules-commonjs": "^7.0.0-beta.42",
1723
"@babel/preset-env": "^7.0.0-beta.40",
1824
"@babel/preset-flow": "^7.0.0-beta.40",
1925
"@babel/preset-react": "^7.0.0-beta.40",

packages/flowtip-core/package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"version": "5.1.0",
55
"author": "Neal Granger <[email protected]>",
66
"main": "./lib",
7+
"module": "./es",
8+
"sideEffects": false,
9+
"files": [
10+
"lib",
11+
"es"
12+
],
713
"repository": {
814
"type": "git",
915
"url": "https://github.com/metalabdesign/flowtip.git"
@@ -19,13 +25,5 @@
1925
"url": "https://github.com/qiushihe/metalabdesign/issues"
2026
},
2127
"homepage": "https://github.com/metalabdesign/flowtip/tree/master/packages/flowtip-react-dom",
22-
"files": [
23-
"lib"
24-
],
25-
"scripts": {
26-
"clean": "../../node_modules/.bin/rimraf lib",
27-
"build": "../../node_modules/.bin/babel --copy-files -s -d lib src",
28-
"copy": "../../node_modules/.bin/ncp src lib && ../../node_modules/.bin/renamer --regex --find '$' --replace '.flow' 'lib/**/*.js'",
29-
"prepare": "npm run clean && npm run copy && npm run build"
30-
}
28+
"sideEffects": false
3129
}

packages/flowtip-react-dom/package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
"version": "5.1.0",
55
"author": "Neal Granger <[email protected]>",
66
"main": "./lib",
7+
"module": "./es",
8+
"sideEffects": false,
9+
"files": [
10+
"README.md",
11+
"lib",
12+
"es"
13+
],
714
"repository": {
815
"type": "git",
916
"url": "https://github.com/metalabdesign/flowtip.git"
@@ -19,15 +26,6 @@
1926
"url": "https://github.com/qiushihe/metalabdesign/issues"
2027
},
2128
"homepage": "https://github.com/metalabdesign/flowtip/tree/master/packages/flowtip-react-dom",
22-
"files": [
23-
"lib"
24-
],
25-
"scripts": {
26-
"clean": "../../node_modules/.bin/rimraf lib",
27-
"build": "../../node_modules/.bin/babel --copy-files -s -d lib src",
28-
"copy": "../../node_modules/.bin/ncp src lib && ../../node_modules/.bin/renamer --regex --find '$' --replace '.flow' 'lib/**/*.js'",
29-
"prepare": "npm run clean && npm run copy && npm run build"
30-
},
3129
"dependencies": {
3230
"flowtip-core": "^5.1.0",
3331
"react-resize-observer": "^0.2.1"

0 commit comments

Comments
 (0)