Skip to content

Commit cae7002

Browse files
authored
fix(command): Remove core-js dependency (#39)
The previous configuration depended on `core-js` for everything ES6+. Instead now, it assumes that the destination library will provide any necessary polyfills. The only gotcha was the `async`/`await` code. The default Babel transform adds in global `regneratorRuntime` which didn't exist. Making use of [`@babel/plugin-transform-runtime`](https://babeljs.io/docs/en/babel-plugin-transform-runtime) which references `@babel/runtime` module to avoid duplication across compiled output. NOTE: Also re-enabling Node 12 in the test suite now that `node-gyp` that was failing has been fixed. Fixes #33
1 parent bc18bdf commit cae7002

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22
node_js:
3-
# - 'node'
3+
- 'node'
4+
- '12'
45
- '10'
56
- '8'
67
cache: yarn

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
"@babel/plugin-external-helpers": "^7.2.0",
3939
"@babel/plugin-proposal-class-properties": "^7.2.0",
4040
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
41+
"@babel/plugin-transform-runtime": "^7.4.4",
4142
"@babel/preset-env": "^7.2.0",
4243
"@babel/preset-typescript": "^7.1.0",
44+
"@babel/runtime": "^7.4.5",
4345
"@types/jest": "^24.0.11",
4446
"@typescript-eslint/eslint-plugin": "^1.8.0",
4547
"@typescript-eslint/parser": "^1.7.0",
@@ -56,7 +58,6 @@
5658
"jest-runner-tsc": "^1.3.2",
5759
"jest-watch-typeahead": "^0.3.0",
5860
"lodash": "^4.17.11",
59-
"regenerator-runtime": "^0.13.2",
6061
"typescript": "^3.2.1",
6162
"yargs": "^13.1.0"
6263
},

src/commands/build/babel-config-utils.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ const getBabelConfig = (moduleType) => ({
99
{
1010
targets: 'last 2 versions',
1111
modules: moduleType === 'esm' ? false : moduleType,
12-
useBuiltIns: 'usage',
13-
corejs: {
14-
version: 3,
15-
}
1612
},
1713
],
1814
'@babel/preset-typescript',
1915
],
2016
plugins: [
2117
['@babel/plugin-proposal-class-properties', {loose: true}],
2218
'@babel/plugin-proposal-object-rest-spread',
19+
['@babel/plugin-transform-runtime', {
20+
corejs: false,
21+
helpers: true,
22+
regenerator: true,
23+
24+
// NOTE: May need to point this to a specific one, see
25+
// https://github.com/facebook/create-react-app/blob/695ca7576a6d27912bcf9d992b00ef7316232555/packages/babel-preset-react-app/create.js#L181
26+
absoluteRuntime: false,
27+
}]
2328
],
2429
})
2530

yarn.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,16 @@
586586
dependencies:
587587
"@babel/helper-plugin-utils" "^7.0.0"
588588

589+
"@babel/plugin-transform-runtime@^7.4.4":
590+
version "7.4.4"
591+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.4.4.tgz#a50f5d16e9c3a4ac18a1a9f9803c107c380bce08"
592+
integrity sha512-aMVojEjPszvau3NRg+TIH14ynZLvPewH4xhlCW1w6A3rkxTS1m4uwzRclYR9oS+rl/dr+kT+pzbfHuAWP/lc7Q==
593+
dependencies:
594+
"@babel/helper-module-imports" "^7.0.0"
595+
"@babel/helper-plugin-utils" "^7.0.0"
596+
resolve "^1.8.1"
597+
semver "^5.5.1"
598+
589599
"@babel/plugin-transform-shorthand-properties@^7.2.0":
590600
version "7.2.0"
591601
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0"
@@ -702,6 +712,13 @@
702712
"@babel/helper-plugin-utils" "^7.0.0"
703713
"@babel/plugin-transform-typescript" "^7.3.2"
704714

715+
"@babel/runtime@^7.4.5":
716+
version "7.4.5"
717+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
718+
integrity sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==
719+
dependencies:
720+
regenerator-runtime "^0.13.2"
721+
705722
706723
version "7.0.0-beta.44"
707724
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f"
@@ -4599,6 +4616,13 @@ resolve@^1.5.0:
45994616
dependencies:
46004617
path-parse "^1.0.5"
46014618

4619+
resolve@^1.8.1:
4620+
version "1.11.0"
4621+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.0.tgz#4014870ba296176b86343d50b60f3b50609ce232"
4622+
integrity sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==
4623+
dependencies:
4624+
path-parse "^1.0.6"
4625+
46024626
restore-cursor@^2.0.0:
46034627
version "2.0.0"
46044628
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"

0 commit comments

Comments
 (0)