From 39c8d91f3559aa3ab3ad6480d04721136f053609 Mon Sep 17 00:00:00 2001 From: Ben Styles Date: Wed, 18 Apr 2018 16:32:16 +0100 Subject: [PATCH] Use babel in es6 build also, to transform class properties (which are not spec yet) --- .babelrc | 79 ++++++++++++++++++++++++++++++++-------------------- package.json | 7 +++-- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/.babelrc b/.babelrc index 2fb9edf..4ae5c01 100644 --- a/.babelrc +++ b/.babelrc @@ -1,32 +1,51 @@ { - "presets": [ - [ - "env", - { - "targets": { - "browsers": [ - "Chrome >= 36", - "Edge >= 12", - "Firefox >= 6", - "Explorer >= 11", - "Opera >= 23", - "Safari >= 8", - "Android >= 36", - "ChromeAndroid >= 36", - "FirefoxAndroid >= 6", - "ExplorerMobile >= 11", - "OperaMobile >= 23", - "iOS >= 8" - ], - "node": "6" - } - } - ], - "react" - ], - "plugins": [ - "transform-flow-strip-types", - "transform-class-properties", - "add-module-exports" - ] + "env": { + "es5": { + "presets": [ + [ + "env", + { + "targets": { + "browsers": [ + "Chrome >= 36", + "Edge >= 12", + "Firefox >= 6", + "Explorer >= 11", + "Opera >= 23", + "Safari >= 8", + "Android >= 36", + "ChromeAndroid >= 36", + "FirefoxAndroid >= 6", + "ExplorerMobile >= 11", + "OperaMobile >= 23", + "iOS >= 8" + ], + "node": "6" + } + } + ], + "react" + ], + "plugins": [ + "transform-flow-strip-types", + "transform-class-properties", + "add-module-exports" + ] + }, + "es6": { + "presets": [ + [ + "env", + { + "targets": { + "node": "9" + }, + "modules": false + } + ], + "react" + ], + "plugins": ["transform-flow-strip-types", "transform-class-properties"] + } + } } diff --git a/package.json b/package.json index 5d90baf..a2820fc 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,11 @@ "test:lib": "jest --silent --config=\"{\\\"moduleNameMapper\\\":{\\\"^./set-future-state$\\\":\\\"/lib/set-future-state\\\"}}\"", "test": "jest --silent --coverage", "posttest": "jest-coverage-ratchet", - "test:all": "yarn lint && yarn run flow check && yarn test && yarn run test:lib", - "build": "babel src --out-dir lib --ignore src/set-future-state.test.js,src/set-future-state-unsupported.test.js,src/flow-tests.js && cp src/set-future-state.js.flow lib && flow-remove-types --pretty src/set-future-state.js > lib/set-future-state.esm.js", + "test:all": "export BABEL_ENV=es5 yarn lint && yarn run flow check && yarn test && yarn run test:lib", + "build:es5": "BABEL_ENV=es5 babel src/set-future-state.js --out-file lib/set-future-state.js", + "build:es6": "BABEL_ENV=es6 babel src/set-future-state.js --out-file lib/set-future-state.esm.js", + "build": "yarn build:es5 && yarn build:es6", + "postbuild": "cp src/set-future-state.js.flow lib", "prepare": "yarn build", "release": "release-it" },