From 677cad851689d0345ae7e8bf44f1406c352d8794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Oct 2017 19:21:32 +0200 Subject: [PATCH 1/4] chore(build): Babel MVP --- package.json | 20 +++++++++++++++++++- packages/core/.babelrc | 5 +++++ packages/core/.babelrc.js | 14 ++++++++++++++ packages/core/package.json | 11 ++++++++--- packages/core/rollup.config.js | 7 +++++-- packages/core/test/perf/chain.js | 2 +- packages/core/test/perf/concatMap.js | 2 +- packages/core/test/perf/filter-map-reduce.js | 2 +- packages/core/test/perf/merge-nested.js | 2 +- packages/core/test/perf/merge.js | 2 +- packages/core/test/perf/package.json | 2 +- packages/core/test/perf/scan.js | 2 +- packages/core/test/perf/skipRepeats.js | 2 +- packages/core/test/perf/slice.js | 2 +- packages/core/test/perf/switch.js | 2 +- packages/core/test/perf/zip.js | 2 +- packages/disposable/.babelrc | 5 +++++ packages/disposable/.babelrc.js | 17 +++++++++++++++++ packages/disposable/package.json | 12 +++++++++--- packages/disposable/rollup.config.js | 7 +++++-- packages/prelude/.babelrc | 5 +++++ packages/prelude/.babelrc.js | 14 ++++++++++++++ packages/prelude/package.json | 10 +++++++--- packages/prelude/rollup.config.js | 7 +++++-- packages/scheduler/.babelrc | 5 +++++ packages/scheduler/.babelrc.js | 14 ++++++++++++++ packages/scheduler/package.json | 11 ++++++++--- packages/scheduler/rollup.config.js | 7 +++++-- 28 files changed, 161 insertions(+), 32 deletions(-) create mode 100644 packages/core/.babelrc create mode 100644 packages/core/.babelrc.js create mode 100644 packages/disposable/.babelrc create mode 100644 packages/disposable/.babelrc.js create mode 100644 packages/prelude/.babelrc create mode 100644 packages/prelude/.babelrc.js create mode 100644 packages/scheduler/.babelrc create mode 100644 packages/scheduler/.babelrc.js diff --git a/package.json b/package.json index fd313f78..f086ba40 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,24 @@ "author": "brian@hovercraftstudios.com", "license": "MIT", "devDependencies": { - "lerna": "^2.5.1" + "@briancavalier/assert": "^3.2.0", + "babel-core": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-plugin-transform-builtin-extend": "^1.1.2", + "babel-preset-env": "^1.6.0", + "babel-register": "^6.26.0", + "cpy-cli": "^1.0.1", + "cross-env": "^5.0.5", + "flow-bin": "^0.57.3", + "lerna": "^2.5.1", + "mocha": "^3.4.2", + "nyc": "^11.0.2", + "rollup": "^0.50.0", + "rollup-plugin-babel": "^3.0.2", + "sinon": "^1.17.7", + "snazzy": "^7.0.0", + "standard": "^10.0.3", + "uglify-js": "^2.7.5" } } diff --git a/packages/core/.babelrc b/packages/core/.babelrc new file mode 100644 index 00000000..04d04f8f --- /dev/null +++ b/packages/core/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "./.babelrc.js" + ] +} diff --git a/packages/core/.babelrc.js b/packages/core/.babelrc.js new file mode 100644 index 00000000..c96711c1 --- /dev/null +++ b/packages/core/.babelrc.js @@ -0,0 +1,14 @@ +const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false + +module.exports = { + presets: [ + ['env', { + modules, + loose: true, + forceAllTransforms: true + }] + ], + plugins: [ + 'annotate-pure-calls' + ] +} diff --git a/packages/core/package.json b/packages/core/package.json index 5b334c40..a34cc290 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -11,7 +11,7 @@ ], "scripts": { "test": "npm run test:lint && npm run test:unit && npm run test:flow", - "test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot --recursive 'test/**/*-test.js'", + "test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot --recursive 'test/**/*-test.js'", "test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy", "test:flow": "flow check", "build": "npm run build:dist && npm run build:flow", @@ -39,13 +39,18 @@ "license": "MIT", "devDependencies": { "@briancavalier/assert": "^3.2.0", - "buba": "^4.0.2", + "babel-core": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.0", + "babel-register": "^6.26.0", "cpy-cli": "^1.0.1", + "cross-env": "^5.0.5", "flow-bin": "^0.57.3", "mocha": "^3.4.2", "nyc": "^11.0.2", "rollup": "^0.50.0", - "rollup-plugin-buble": "^0.16.0", + "rollup-plugin-babel": "^3.0.2", "sinon": "^1.17.7", "snazzy": "^7.0.0", "standard": "^10.0.3" diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index 306132c7..7071acf0 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -1,10 +1,13 @@ -import buble from 'rollup-plugin-buble' +import babel from 'rollup-plugin-babel' import pkg from './package.json' export default { input: 'src/index.js', plugins: [ - buble() + babel({ + exclude: 'node_modules/**', + plugins: ['external-helpers'] + }) ], external: [ '@most/scheduler', diff --git a/packages/core/test/perf/chain.js b/packages/core/test/perf/chain.js index cd4494b9..e3c2f709 100644 --- a/packages/core/test/perf/chain.js +++ b/packages/core/test/perf/chain.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {chain, fromArray} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/concatMap.js b/packages/core/test/perf/concatMap.js index 93fa146c..451c2f0b 100644 --- a/packages/core/test/perf/concatMap.js +++ b/packages/core/test/perf/concatMap.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, concatMap} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/filter-map-reduce.js b/packages/core/test/perf/filter-map-reduce.js index 796f07a6..53772d18 100644 --- a/packages/core/test/perf/filter-map-reduce.js +++ b/packages/core/test/perf/filter-map-reduce.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {map, filter, fromArray} = require('../../src/index'); const {reduce} = require('../../test/helper/reduce') diff --git a/packages/core/test/perf/merge-nested.js b/packages/core/test/perf/merge-nested.js index 4115d975..c4f3f810 100644 --- a/packages/core/test/perf/merge-nested.js +++ b/packages/core/test/perf/merge-nested.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, merge: _merge} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/merge.js b/packages/core/test/perf/merge.js index d1c270d7..9d0bcdc4 100644 --- a/packages/core/test/perf/merge.js +++ b/packages/core/test/perf/merge.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, mergeArray} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/package.json b/packages/core/test/perf/package.json index 1935cdfd..7f1cebc7 100644 --- a/packages/core/test/perf/package.json +++ b/packages/core/test/perf/package.json @@ -20,9 +20,9 @@ }, "dependencies": { "@reactivex/rxjs": "^5.0.1", + "babel-register": "^6.26.0", "baconjs": "^0.7.89", "benchmark": "github:bestiejs/benchmark.js#master", - "buba": "^4.0.1", "highland": "^2.10.1", "kefir": "^3.6.1", "rx": "^4.1.0", diff --git a/packages/core/test/perf/scan.js b/packages/core/test/perf/scan.js index 6df946c7..69f4b0b0 100644 --- a/packages/core/test/perf/scan.js +++ b/packages/core/test/perf/scan.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, scan} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/skipRepeats.js b/packages/core/test/perf/skipRepeats.js index ae7c1e08..166aa863 100644 --- a/packages/core/test/perf/skipRepeats.js +++ b/packages/core/test/perf/skipRepeats.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, skipRepeats} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/slice.js b/packages/core/test/perf/slice.js index 2fd0502b..1eb2c28b 100644 --- a/packages/core/test/perf/slice.js +++ b/packages/core/test/perf/slice.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, skip, take} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/switch.js b/packages/core/test/perf/switch.js index 10a63350..147f002a 100644 --- a/packages/core/test/perf/switch.js +++ b/packages/core/test/perf/switch.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, map, switchLatest} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/core/test/perf/zip.js b/packages/core/test/perf/zip.js index 2e63cc07..a2a6d225 100644 --- a/packages/core/test/perf/zip.js +++ b/packages/core/test/perf/zip.js @@ -1,4 +1,4 @@ -require('buba/register') +require('babel-register') const Benchmark = require('benchmark'); const {fromArray, zip} = require('.././index'); const {reduce} = require('.././combinator/reduce') diff --git a/packages/disposable/.babelrc b/packages/disposable/.babelrc new file mode 100644 index 00000000..04d04f8f --- /dev/null +++ b/packages/disposable/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "./.babelrc.js" + ] +} diff --git a/packages/disposable/.babelrc.js b/packages/disposable/.babelrc.js new file mode 100644 index 00000000..6d12d5aa --- /dev/null +++ b/packages/disposable/.babelrc.js @@ -0,0 +1,17 @@ +const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false + +module.exports = { + presets: [ + ['env', { + modules, + loose: true, + forceAllTransforms: true + }] + ], + plugins: [ + ['transform-builtin-extend', { + globals: ['Error'] + }], + 'annotate-pure-calls' + ] +} diff --git a/packages/disposable/package.json b/packages/disposable/package.json index 5d3c80ff..2e3ddd54 100644 --- a/packages/disposable/package.json +++ b/packages/disposable/package.json @@ -11,7 +11,7 @@ ], "scripts": { "test": "npm run test:lint && npm run test:unit && npm run test:flow", - "test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot --recursive 'test/**/*-test.js'", + "test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot --recursive 'test/**/*-test.js'", "test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy", "test:flow": "flow check", "build": "npm run build:dist && npm run build:flow", @@ -39,13 +39,19 @@ "license": "MIT", "devDependencies": { "@briancavalier/assert": "^3.2.0", - "buba": "^4.0.2", + "babel-core": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-plugin-transform-builtin-extend": "^1.1.2", + "babel-preset-env": "^1.6.0", + "babel-register": "^6.26.0", "cpy-cli": "^1.0.1", + "cross-env": "^5.0.5", "flow-bin": "^0.57.3", "mocha": "^3.4.2", "nyc": "^11.0.2", "rollup": "^0.50.0", - "rollup-plugin-buble": "^0.16.0", + "rollup-plugin-babel": "^3.0.2", "sinon": "^1.17.7", "snazzy": "^7.0.0", "standard": "^10.0.3" diff --git a/packages/disposable/rollup.config.js b/packages/disposable/rollup.config.js index e72347e2..99fe4885 100644 --- a/packages/disposable/rollup.config.js +++ b/packages/disposable/rollup.config.js @@ -1,10 +1,13 @@ -import buble from 'rollup-plugin-buble' +import babel from 'rollup-plugin-babel' import pkg from './package.json' export default { input: 'src/index.js', plugins: [ - buble() + babel({ + exclude: 'node_modules/**', + plugins: ['external-helpers'] + }) ], external: [ '@most/prelude' diff --git a/packages/prelude/.babelrc b/packages/prelude/.babelrc new file mode 100644 index 00000000..04d04f8f --- /dev/null +++ b/packages/prelude/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "./.babelrc.js" + ] +} diff --git a/packages/prelude/.babelrc.js b/packages/prelude/.babelrc.js new file mode 100644 index 00000000..c96711c1 --- /dev/null +++ b/packages/prelude/.babelrc.js @@ -0,0 +1,14 @@ +const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false + +module.exports = { + presets: [ + ['env', { + modules, + loose: true, + forceAllTransforms: true + }] + ], + plugins: [ + 'annotate-pure-calls' + ] +} diff --git a/packages/prelude/package.json b/packages/prelude/package.json index ce4b591b..5355c116 100644 --- a/packages/prelude/package.json +++ b/packages/prelude/package.json @@ -16,7 +16,7 @@ "prepare": "npm run build", "test": "npm run test:lint && npm run test:unit && npm run test:flow", "test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy", - "test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot", + "test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot", "test:flow": "flow check" }, "repository": { @@ -30,13 +30,17 @@ }, "homepage": "https://github.com/mostjs/prelude#readme", "devDependencies": { - "buba": "^4.0.2", + "babel-core": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.0", + "babel-register": "^6.26.0", "cpy-cli": "^1.0.1", + "cross-env": "^5.0.5", "flow-bin": "^0.57.3", "mocha": "^3.4.2", "nyc": "^11.0.2", "rollup": "^0.50.0", - "rollup-plugin-buble": "^0.16.0", "snazzy": "^7.0.0", "standard": "^10.0.3" }, diff --git a/packages/prelude/rollup.config.js b/packages/prelude/rollup.config.js index 46f766f8..aa026bf5 100644 --- a/packages/prelude/rollup.config.js +++ b/packages/prelude/rollup.config.js @@ -1,10 +1,13 @@ -import buble from 'rollup-plugin-buble' +import babel from 'rollup-plugin-babel' import pkg from './package.json' export default { input: 'src/index.js', plugins: [ - buble() + babel({ + exclude: 'node_modules/**', + plugins: ['external-helpers'] + }) ], output: [ { diff --git a/packages/scheduler/.babelrc b/packages/scheduler/.babelrc new file mode 100644 index 00000000..04d04f8f --- /dev/null +++ b/packages/scheduler/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "./.babelrc.js" + ] +} diff --git a/packages/scheduler/.babelrc.js b/packages/scheduler/.babelrc.js new file mode 100644 index 00000000..c96711c1 --- /dev/null +++ b/packages/scheduler/.babelrc.js @@ -0,0 +1,14 @@ +const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false + +module.exports = { + presets: [ + ['env', { + modules, + loose: true, + forceAllTransforms: true + }] + ], + plugins: [ + 'annotate-pure-calls' + ] +} diff --git a/packages/scheduler/package.json b/packages/scheduler/package.json index a1590d97..9a3d01de 100644 --- a/packages/scheduler/package.json +++ b/packages/scheduler/package.json @@ -11,7 +11,7 @@ ], "scripts": { "test": "npm run test:lint && npm run test:unit && npm run test:flow", - "test:unit": "nyc --reporter=text-summary mocha -r buba/register --reporter dot --recursive 'test/**/*-test.js'", + "test:unit": "cross-env NODE_ENV=test nyc --reporter=text-summary mocha -r babel-register --reporter dot --recursive 'test/**/*-test.js'", "test:lint": "standard --fix 'src/**/*.js' 'test/**/*.js' --verbose | snazzy", "test:flow": "flow check", "build": "npm run build:dist && npm run build:flow", @@ -39,13 +39,18 @@ "license": "MIT", "devDependencies": { "@briancavalier/assert": "^3.2.0", - "buba": "^4.0.2", + "babel-core": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-plugin-external-helpers": "^6.22.0", + "babel-preset-env": "^1.6.0", + "babel-register": "^6.26.0", "cpy-cli": "^1.0.1", + "cross-env": "^5.0.5", "flow-bin": "^0.57.3", "mocha": "^3.4.2", "nyc": "^11.0.2", "rollup": "^0.50.0", - "rollup-plugin-buble": "^0.16.0", + "rollup-plugin-babel": "^3.0.2", "sinon": "^1.17.7", "snazzy": "^7.0.0", "standard": "^10.0.3" diff --git a/packages/scheduler/rollup.config.js b/packages/scheduler/rollup.config.js index b21e7936..7c374b8c 100644 --- a/packages/scheduler/rollup.config.js +++ b/packages/scheduler/rollup.config.js @@ -1,10 +1,13 @@ -import buble from 'rollup-plugin-buble' +import babel from 'rollup-plugin-babel' import pkg from './package.json' export default { input: 'src/index.js', plugins: [ - buble() + babel({ + exclude: 'node_modules/**', + plugins: ['external-helpers'] + }) ], external: [ '@most/prelude' From 6ab4da31026240827bf8a59749e1296c6305ba84 Mon Sep 17 00:00:00 2001 From: Brian Cavalier Date: Tue, 28 Nov 2017 08:09:14 -0500 Subject: [PATCH 2/4] Add uglify to test PURE annotation tree-shaking --- examples/package-lock.json | 41 ++++++++++++++++++++++++++++++++++++++ examples/package.json | 5 ++++- examples/rollup.config.js | 5 ++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/examples/package-lock.json b/examples/package-lock.json index 5e485abb..c6e4c546 100644 --- a/examples/package-lock.json +++ b/examples/package-lock.json @@ -379,6 +379,12 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1766,6 +1772,15 @@ "resolve": "1.5.0" } }, + "rollup-plugin-uglify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-2.0.1.tgz", + "integrity": "sha1-Z7N60e/a+9g69MNrQMGJ7khmyWk=", + "dev": true, + "requires": { + "uglify-js": "3.2.0" + } + }, "rollup-pluginutils": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz", @@ -1826,6 +1841,12 @@ "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -2032,6 +2053,26 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "uglify-es": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.2.0.tgz", + "integrity": "sha512-eD4rjK4o6rzrvE1SMZJLQFEVMnWRUyIu6phJ0BXk5TIthMmP5B4QP0HI8o3bkQB5wf1N4WHA0leZAQyQBAd+Jg==", + "dev": true, + "requires": { + "commander": "2.12.2", + "source-map": "0.6.1" + } + }, + "uglify-js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.2.0.tgz", + "integrity": "sha512-L98DlTshoPGnZGF8pr3MoE+CCo6n9joktHNHMPkckeBV8xTVc4CWtC0kGGhQsIvnX2Ug4nXFTAeE7SpTrPX2tg==", + "dev": true, + "requires": { + "commander": "2.12.2", + "source-map": "0.6.1" + } + }, "uniq": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", diff --git a/examples/package.json b/examples/package.json index f038525b..d30f382c 100644 --- a/examples/package.json +++ b/examples/package.json @@ -21,7 +21,10 @@ "rollup": "^0.50.0", "rollup-plugin-flow": "^1.1.1", "rollup-plugin-node-resolve": "^3.0.0", - "standard": "^10.0.3" + "rollup-plugin-uglify": "^2.0.1", + "standard": "^10.0.3", + "uglify-es": "^3.2.0", + "uglify-js": "^3.2.0" }, "standard": { "parser": "babel-eslint", diff --git a/examples/rollup.config.js b/examples/rollup.config.js index bd2fe6c0..508bb975 100644 --- a/examples/rollup.config.js +++ b/examples/rollup.config.js @@ -1,10 +1,13 @@ import node from 'rollup-plugin-node-resolve' import flow from 'rollup-plugin-flow' +import uglify from 'rollup-plugin-uglify' +import { minify } from 'uglify-es' export default { plugins: [ flow(), - node() + node(), + uglify({}, minify) ], output: { format: 'iife', From 0023e3c248d8ab3981a7353b5fcec3cc2b3b63f8 Mon Sep 17 00:00:00 2001 From: Brian Cavalier Date: Thu, 30 Nov 2017 07:48:42 -0500 Subject: [PATCH 3/4] Use prototypal inheritance instead of extends for DisposeAllError --- packages/disposable/src/disposeAll.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/disposable/src/disposeAll.js b/packages/disposable/src/disposeAll.js index d61da308..1004d78d 100644 --- a/packages/disposable/src/disposeAll.js +++ b/packages/disposable/src/disposeAll.js @@ -40,25 +40,24 @@ const throwIfErrors = errors => { } } -// Aggregate Error type for DisposeAll -export class DisposeAllError extends Error { - constructor (message, errors) { - super(message) +export const DisposeAllError = (Error => { + function DisposeAllError (message, errors) { + Error.call(this, message) this.message = message - this.name = this.constructor.name + this.name = DisposeAllError.name this.errors = errors if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor) + Error.captureStackTrace(this, DisposeAllError) } this.stack = `${this.stack}${formatErrorStacks(this.errors)}` } - toString () { - return this.stack - } -} + DisposeAllError.prototype = Object.create(Error.prototype) + + return DisposeAllError +})(Error) const formatErrorStacks = errors => reduce(formatErrorStack, '', errors) From bd7bc1334c900484e2a347de22c62845880ddff7 Mon Sep 17 00:00:00 2001 From: Brian Cavalier Date: Sat, 2 Dec 2017 15:36:53 -0500 Subject: [PATCH 4/4] Remove now-unneeded babel builtin-extend plugin --- packages/disposable/.babelrc.js | 3 --- packages/disposable/package.json | 1 - 2 files changed, 4 deletions(-) diff --git a/packages/disposable/.babelrc.js b/packages/disposable/.babelrc.js index 6d12d5aa..c96711c1 100644 --- a/packages/disposable/.babelrc.js +++ b/packages/disposable/.babelrc.js @@ -9,9 +9,6 @@ module.exports = { }] ], plugins: [ - ['transform-builtin-extend', { - globals: ['Error'] - }], 'annotate-pure-calls' ] } diff --git a/packages/disposable/package.json b/packages/disposable/package.json index 2e3ddd54..68df4527 100644 --- a/packages/disposable/package.json +++ b/packages/disposable/package.json @@ -42,7 +42,6 @@ "babel-core": "^6.26.0", "babel-plugin-annotate-pure-calls": "^0.2.0", "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-transform-builtin-extend": "^1.1.2", "babel-preset-env": "^1.6.0", "babel-register": "^6.26.0", "cpy-cli": "^1.0.1",