From 9f2e3f309aa62fffd62da2530d1e6491c500cdf0 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Mon, 7 May 2018 15:52:38 -0400 Subject: [PATCH] add es build --- .babelrc.js | 10 +++++++++- .gitignore | 1 + package.json | 15 +++++++-------- src/index.cjs.js | 3 +++ src/index.js | 4 ++-- yarn.lock | 16 ++++++++++++++++ 6 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/index.cjs.js diff --git a/.babelrc.js b/.babelrc.js index 34e0f37..4ccd08b 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -1,3 +1,11 @@ module.exports = { - "presets": [["jason", { "runtime": false }]] + presets: [ + [ + 'jason', + { + runtime: false, + modules: process.env.BABEL_ENV === 'esm' ? false : 'commonjs', + }, + ], + ], } diff --git a/.gitignore b/.gitignore index cd87cc9..4e9b706 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /lib +/es # Logs logs diff --git a/package.json b/package.json index 19bccd4..d934094 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "react-formal", "version": "0.27.0", "description": "Classy HTML form management for React", - "main": "lib/index.js", + "main": "lib/index.cjs.js", + "modules": "es/index.js", "author": { "name": "Jason Quense", "email": "monastic.panic@gmail.com" @@ -13,9 +14,7 @@ "url": "https://github.com/jquense/react-formal" }, "license": "MIT", - "files": [ - "lib" - ], + "files": ["lib", "es"], "keywords": [ "react-formal", "react", @@ -29,9 +28,7 @@ "yup" ], "jest": { - "roots": [ - "/test" - ], + "roots": ["/test"], "setupTestFrameworkScriptFile": "./test/index.js" }, "scripts": { @@ -40,7 +37,8 @@ "lint": "eslint src", "docs": "webpack --config docs/webpack.config.js --progress", "docs:watch": "webpack-dev-server --config docs/webpack.config.js", - "build": " babel src --out-dir lib --copy-files", + "build:esm": "BABEL_ENV=esm babel src --out-dir es --copy-files", + "build": " babel src --out-dir lib --copy-files && npm run build:esm", "release": "release" }, "peerDependencies": { @@ -89,6 +87,7 @@ "react-bootstrap": "^0.32.1", "react-component-metadata": "^3.0.0", "react-dom": "^16.3.2", + "react-formal": "^0.27.0", "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "release-script": "^1.0.2", diff --git a/src/index.cjs.js b/src/index.cjs.js new file mode 100644 index 0000000..f7fff0a --- /dev/null +++ b/src/index.cjs.js @@ -0,0 +1,3 @@ +const ReactFormal = require('./index.js') + +module.exports = ReactFormal.default diff --git a/src/index.js b/src/index.js index beda7c2..a38bc9d 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,7 @@ const statics = { Object.assign(Form, statics) +Form.statics = statics + export { statics } export default Form - -module.exports = Form diff --git a/yarn.lock b/yarn.lock index c67d1f0..3d411d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6633,6 +6633,22 @@ react-dom@^16.3.2: object-assign "^4.1.1" prop-types "^15.6.0" +react-formal@^0.27.0: + version "0.27.0" + resolved "https://registry.yarnpkg.com/react-formal/-/react-formal-0.27.0.tgz#16ed6423eab27cbe005418f46d55b4f530b8b0d8" + dependencies: + chain-function "^1.0.0" + classnames "^2.2.5" + invariant "^2.2.4" + lodash "^4.17.10" + prop-types "^15.6.1" + property-expr "^1.4.0" + react-lifecycles-compat "^3.0.2" + topeka "^3.0.0" + uncontrollable "^6.0.0" + warning "^3.0.0" + yup "^0.24.1" + react-is@^16.3.2: version "16.3.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.3.2.tgz#f4d3d0e2f5fbb6ac46450641eb2e25bf05d36b22"