diff --git a/.babelrc b/.babelrc index 534233b..be773d9 100644 --- a/.babelrc +++ b/.babelrc @@ -1,29 +1,46 @@ { "presets": [ - ["@babel/preset-env", { - "shippedProposals": true, - "targets": { - "node": "8" + [ + "@babel/preset-env", { + "modules": false, + "shippedProposals": true, + "targets": { + "node": 8 + } } - }], + ], "@babel/preset-react", "@babel/preset-flow" ], "plugins": [ "@babel/plugin-proposal-class-properties", - "@babel/plugin-syntax-dynamic-import" + [ + "module-resolver", + { + "cwd": "babelrc", + "alias": { + "^(flowtip-core|flowtip-react-dom)/(lib|es|src)($|/.*$)": + "./packages/\\1/src/\\3", + "^(flowtip-core|flowtip-react-dom)$": "./packages/\\1/src", + } + } + ] ], "env": { "test": { "plugins": [ - ["module-resolver", { - "alias": { - "flowtip-core/lib": "./packages/flowtip-core/src", - "flowtip-core": "./packages/flowtip-core/src", - "flowtip-react-dom/lib": "./packages/flowtip-react-dom/src", - "flowtip-react-dom": "./packages/flowtip-react-dom/src", - } - }] + "@babel/plugin-transform-modules-commonjs" + ] + }, + "lib": { + "plugins": [ + "@babel/plugin-transform-modules-commonjs", + ["module-resolver", {}] + ] + }, + "es": { + "plugins": [ + ["module-resolver", {}] ] } } diff --git a/.eslintignore b/.eslintignore index 71525f4..e19b550 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ node_modules coverage dist +es lib flow-typed diff --git a/.flowconfig b/.flowconfig index 68ebb65..9f5b4f6 100644 --- a/.flowconfig +++ b/.flowconfig @@ -20,5 +20,5 @@ suppress_comment=\\(.\\|\n\\)*\\$ExpectError # Map requests to `lib` folder in each package to `src`. This makes flow # reference the src files and prevents the need for running the prepare script # when flow-checking changes across packages. -module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)/lib\($\|/.*$\)' -> '/packages/\1/src\2' +module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)/\(lib\|es\|src\)\($\|/.*$\)' -> '/packages/\1/src\3' module.name_mapper='^\(flowtip-core\|flowtip-react-dom\)$' -> '/packages/\1/src' diff --git a/.gitignore b/.gitignore index c080518..6eb174b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules *.log coverage +es lib dist diff --git a/.prettierignore b/.prettierignore index 71525f4..e19b550 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,6 @@ node_modules coverage dist +es lib flow-typed diff --git a/package-lock.json b/package-lock.json index 24fda3f..588c69c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,4 +1,5 @@ { + "name": "flowtip-packages", "requires": true, "lockfileVersion": 1, "dependencies": { @@ -646,14 +647,115 @@ } }, "@babel/plugin-transform-modules-commonjs": { - "version": "7.0.0-beta.41", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.0.0-beta.41.tgz", - "integrity": "sha512-9BCB9faifDb0jM1lRhqXW3pBzQJr0hLJLOL9YlePBESHkt/ZK1dgtVepu6LUl8YKJYGqU9qofwu7n3JeOQVZww==", + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.0.0-beta.42.tgz", + "integrity": "sha512-tCN0FFdTHaXpuJokvW8iWtbDpjKDNDO2dIyb8rr0GMQxsA62914e8oclcDUPEbC5iF5SCDEF0CmVHXbxnvANfQ==", "dev": true, "requires": { - "@babel/helper-module-transforms": "7.0.0-beta.41", - "@babel/helper-plugin-utils": "7.0.0-beta.41", - "@babel/helper-simple-access": "7.0.0-beta.41" + "@babel/helper-module-transforms": "7.0.0-beta.42", + "@babel/helper-plugin-utils": "7.0.0-beta.42", + "@babel/helper-simple-access": "7.0.0-beta.42" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.42.tgz", + "integrity": "sha512-L8i94FLSyaLQpRfDo/qqSm8Ndb44zMtXParXo0MebJICG1zoCCL4+GkzUOlB4BNTRSXXQdb3feam/qw7bKPipQ==", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.42" + } + }, + "@babel/helper-module-imports": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.42.tgz", + "integrity": "sha512-0kTX0cjuVKUKDJmHjmAb504kNrwae0Ja32hGii7zSHDKm0tVZvvpT8Cc1yYHo6UsIkUmzEvfGwIrNYemx1jTtQ==", + "dev": true, + "requires": { + "@babel/types": "7.0.0-beta.42", + "lodash": "4.17.5" + } + }, + "@babel/helper-module-transforms": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.0.0-beta.42.tgz", + "integrity": "sha512-XfCGsf6ijExiXw+oKL1Cp7VJttvgq8qalTGRqz4pviVNEjHU89Pfjsi1K/shdy5x4x+PiTSqn4zZ2PKfVp+vgg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "7.0.0-beta.42", + "@babel/helper-simple-access": "7.0.0-beta.42", + "@babel/helper-split-export-declaration": "7.0.0-beta.42", + "@babel/template": "7.0.0-beta.42", + "@babel/types": "7.0.0-beta.42", + "lodash": "4.17.5" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0-beta.42.tgz", + "integrity": "sha512-hZLw8Iz9/YOxI9mgWyPOP1S84OcdQo1WFkZrS1sSf45g16sEb4dVslds2uvZgmx9BiG94PoWyABGf48Py6D6CA==", + "dev": true + }, + "@babel/helper-simple-access": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.0.0-beta.42.tgz", + "integrity": "sha512-SK1nb/sx+Q/0N8USPR+/5G1D1U9tCo82MzJknmK7X4yexDacHmDHtqNP7xqUlSSo3xfMfyHgT7mAH17Cwik/gA==", + "dev": true, + "requires": { + "@babel/template": "7.0.0-beta.42", + "@babel/types": "7.0.0-beta.42", + "lodash": "4.17.5" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.42.tgz", + "integrity": "sha512-2r8pZG6SAJTTaI2OhxCmz5PKlMUPY5adOHrHtb1gM3ibJPDOzPAeOQNzItdxNnM33jjRakEGitXX6iYg7Sz73w==", + "dev": true, + "requires": { + "@babel/types": "7.0.0-beta.42" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.42.tgz", + "integrity": "sha512-X3Ur/A/lIbbP8W0pmwgqtDXIxhQmxPaiwY9SKP7kF9wvZfjZRwMvbJE92ozUhF3UDK3DCKaV7oGqmI1rP/zqWA==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, + "@babel/template": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.42.tgz", + "integrity": "sha512-EK7YdTe47j4VxlwNvz5bnlk5Jx/wWublnqfgOY2IuSNdxCQgXrLD34PfTnabGxywNSkJkcSo6jwr2JGT+S48dA==", + "dev": true, + "requires": { + "@babel/code-frame": "7.0.0-beta.42", + "@babel/types": "7.0.0-beta.42", + "babylon": "7.0.0-beta.42", + "lodash": "4.17.5" + } + }, + "@babel/types": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.42.tgz", + "integrity": "sha512-+pmpISmTHQqMMpHHtDLxcvtRhmn53bAxy8goJfHipS/uy/r3PLcuSdPizLW7DhtBWbtgIKZufLObfnIMoyMNsw==", + "dev": true, + "requires": { + "esutils": "2.0.2", + "lodash": "4.17.5", + "to-fast-properties": "2.0.0" + } + }, + "babylon": { + "version": "7.0.0-beta.42", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.42.tgz", + "integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==", + "dev": true + } } }, "@babel/plugin-transform-modules-systemjs": { @@ -913,6 +1015,17 @@ "semver": "5.5.0" }, "dependencies": { + "@babel/plugin-transform-modules-commonjs": { + "version": "7.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.0.0-beta.41.tgz", + "integrity": "sha512-9BCB9faifDb0jM1lRhqXW3pBzQJr0hLJLOL9YlePBESHkt/ZK1dgtVepu6LUl8YKJYGqU9qofwu7n3JeOQVZww==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "7.0.0-beta.41", + "@babel/helper-plugin-utils": "7.0.0-beta.41", + "@babel/helper-simple-access": "7.0.0-beta.41" + } + }, "browserslist": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.1.2.tgz", diff --git a/package.json b/package.json index 17062ec..76576a6 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,17 @@ { "private": true, + "name": "flowtip-packages", "scripts": { - "flow": "./node_modules/.bin/flow", - "format": "./node_modules/.bin/prettier --write '**/*.js'", - "lerna": "./node_modules/.bin/lerna", - "lint": "./node_modules/.bin/eslint .", - "prepare": "./node_modules/.bin/lerna bootstrap", - "spec": "./node_modules/.bin/jest --runInBand=${SPEC_SERIAL:-$CI} --coverage=${SPEC_COVERAGE:-$CI}", + "build": "npm run clean && npm run build:flow && npm run build:es && npm run build:lib", + "build:es": "BABEL_ENV=es npx babel --copy-files -s --relative -d ../es packages/*/src", + "build:flow": "npx lerna exec ncp src es && npx lerna exec ncp src lib && npx renamer --regex --find '$' --replace '.flow' 'packages/*/@(es|lib)/**/*.js'", + "build:lib": "BABEL_ENV=lib npx babel --copy-files -s --relative -d ../lib packages/*/src", + "clean": "npx lerna exec rimraf lib es", + "flow": "npx flow", + "format": "npx prettier --write '**/*.js'", + "lint": "npx eslint .", + "prepare": "npx lerna bootstrap && npm run build", + "spec": "npx jest --runInBand=${SPEC_SERIAL:-$CI} --coverage=${SPEC_COVERAGE:-$CI}", "spec:watch": "npm run spec -- --watch", "test": "npm run flow --silent && npm run lint --slient && npm run spec --silent" }, @@ -14,6 +19,7 @@ "@babel/cli": "^7.0.0-beta.40", "@babel/core": "^7.0.0-beta.40", "@babel/plugin-proposal-class-properties": "^7.0.0-beta.40", + "@babel/plugin-transform-modules-commonjs": "^7.0.0-beta.42", "@babel/preset-env": "^7.0.0-beta.40", "@babel/preset-flow": "^7.0.0-beta.40", "@babel/preset-react": "^7.0.0-beta.40", diff --git a/packages/flowtip-core/package.json b/packages/flowtip-core/package.json index 15c1a4c..cb0055c 100644 --- a/packages/flowtip-core/package.json +++ b/packages/flowtip-core/package.json @@ -4,6 +4,12 @@ "version": "5.1.0", "author": "Neal Granger ", "main": "./lib", + "module": "./es", + "sideEffects": false, + "files": [ + "lib", + "es" + ], "repository": { "type": "git", "url": "https://github.com/metalabdesign/flowtip.git" @@ -19,13 +25,5 @@ "url": "https://github.com/qiushihe/metalabdesign/issues" }, "homepage": "https://github.com/metalabdesign/flowtip/tree/master/packages/flowtip-react-dom", - "files": [ - "lib" - ], - "scripts": { - "clean": "../../node_modules/.bin/rimraf lib", - "build": "../../node_modules/.bin/babel --copy-files -s -d lib src", - "copy": "../../node_modules/.bin/ncp src lib && ../../node_modules/.bin/renamer --regex --find '$' --replace '.flow' 'lib/**/*.js'", - "prepare": "npm run clean && npm run copy && npm run build" - } + "sideEffects": false } diff --git a/packages/flowtip-react-dom/package.json b/packages/flowtip-react-dom/package.json index 05888cf..e89ca75 100644 --- a/packages/flowtip-react-dom/package.json +++ b/packages/flowtip-react-dom/package.json @@ -4,6 +4,13 @@ "version": "5.1.0", "author": "Neal Granger ", "main": "./lib", + "module": "./es", + "sideEffects": false, + "files": [ + "README.md", + "lib", + "es" + ], "repository": { "type": "git", "url": "https://github.com/metalabdesign/flowtip.git" @@ -19,15 +26,6 @@ "url": "https://github.com/qiushihe/metalabdesign/issues" }, "homepage": "https://github.com/metalabdesign/flowtip/tree/master/packages/flowtip-react-dom", - "files": [ - "lib" - ], - "scripts": { - "clean": "../../node_modules/.bin/rimraf lib", - "build": "../../node_modules/.bin/babel --copy-files -s -d lib src", - "copy": "../../node_modules/.bin/ncp src lib && ../../node_modules/.bin/renamer --regex --find '$' --replace '.flow' 'lib/**/*.js'", - "prepare": "npm run clean && npm run copy && npm run build" - }, "dependencies": { "flowtip-core": "^5.1.0", "react-resize-observer": "^0.2.1"