From 39f472bec54d9bc55e96364c8782f98a379e6011 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 3 Jun 2018 22:14:33 +0100 Subject: [PATCH 1/3] Add async, await and yield support --- package.json | 3 +++ yarn.lock | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index df4456a45..f38fbef40 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "@babel/plugin-proposal-class-properties": "^7.0.0-beta.49", "@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.49", "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.49", + "@babel/plugin-transform-destructuring": "^7.0.0-beta.49", + "@babel/plugin-transform-regenerator": "^7.0.0-beta.49", + "@babel/plugin-transform-runtime": "^7.0.0-beta.49", "@babel/polyfill": "^7.0.0-beta.49", "@babel/preset-env": "^7.0.0-beta.49", "babel-core": "^7.0.0-bridge", diff --git a/yarn.lock b/yarn.lock index fa78976d7..92a5fa39d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -328,7 +328,7 @@ dependencies: "@babel/helper-plugin-utils" "7.0.0-beta.49" -"@babel/plugin-transform-destructuring@7.0.0-beta.49": +"@babel/plugin-transform-destructuring@7.0.0-beta.49", "@babel/plugin-transform-destructuring@^7.0.0-beta.49": version "7.0.0-beta.49" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.0.0-beta.49.tgz#4366392c9c82d1231056c1d0029438a60d362b82" dependencies: @@ -424,12 +424,19 @@ "@babel/helper-get-function-arity" "7.0.0-beta.49" "@babel/helper-plugin-utils" "7.0.0-beta.49" -"@babel/plugin-transform-regenerator@7.0.0-beta.49": +"@babel/plugin-transform-regenerator@7.0.0-beta.49", "@babel/plugin-transform-regenerator@^7.0.0-beta.49": version "7.0.0-beta.49" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.0.0-beta.49.tgz#d4ed7967033f4f5b49363c203503899b8357cae2" dependencies: regenerator-transform "^0.12.3" +"@babel/plugin-transform-runtime@^7.0.0-beta.49": + version "7.0.0-beta.49" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.0.0-beta.49.tgz#65a30ec0bc36f4249325dbc2438f97f563b41f1a" + dependencies: + "@babel/helper-module-imports" "7.0.0-beta.49" + "@babel/helper-plugin-utils" "7.0.0-beta.49" + "@babel/plugin-transform-shorthand-properties@7.0.0-beta.49": version "7.0.0-beta.49" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.0.0-beta.49.tgz#49f134dbde4f655834c21524e9e61a58d4e17900" From 50c176f43371d7afbc92b6281d8e72a16a20bdb6 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 3 Jun 2018 22:14:55 +0100 Subject: [PATCH 2/3] Update babelrc --- lib/install/config/.babelrc | 26 ++++++++++++++++++++--- lib/install/examples/react/.babelrc | 33 +++++++++++++++++++++++++---- lib/install/react.rb | 5 +++-- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/lib/install/config/.babelrc b/lib/install/config/.babelrc index 5b59b3608..cd6bf289b 100644 --- a/lib/install/config/.babelrc +++ b/lib/install/config/.babelrc @@ -7,17 +7,37 @@ "targets": { "forceAllTransforms": true }, - "useBuiltIns": "usage" + "useBuiltIns": "entry" } ] ], "plugins": [ + "@babel/plugin-transform-destructuring", "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-proposal-object-rest-spread", + [ + "@babel/plugin-proposal-object-rest-spread", + { + "useBuiltIns": true + } + ], + [ + "@babel/plugin-transform-runtime", + { + "helpers": false, + "polyfill": false, + "regenerator": true + } + ], + [ + "@babel/plugin-transform-regenerator", + { + "async": false + } + ], [ "@babel/plugin-proposal-class-properties", { - "spec": true + "loose": true } ] ] diff --git a/lib/install/examples/react/.babelrc b/lib/install/examples/react/.babelrc index bbd68f39c..5af5b4ffa 100644 --- a/lib/install/examples/react/.babelrc +++ b/lib/install/examples/react/.babelrc @@ -7,18 +7,43 @@ "targets": { "forceAllTransforms": true }, - "useBuiltIns": "usage" + "useBuiltIns": "entry" } ], - "@babel/preset-react" + [ + "@babel/preset-react", + { + "useBuiltIns": true + } + ] ], "plugins": [ + "@babel/plugin-transform-destructuring", "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-proposal-object-rest-spread", + [ + "@babel/plugin-proposal-object-rest-spread", + { + "useBuiltIns": true + } + ], + [ + "@babel/plugin-transform-runtime", + { + "helpers": false, + "polyfill": false, + "regenerator": true + } + ], + [ + "@babel/plugin-transform-regenerator", + { + "async": false + } + ], [ "@babel/plugin-proposal-class-properties", { - "spec": true + "loose": true } ] ] diff --git a/lib/install/react.rb b/lib/install/react.rb index 2fdf5981d..46210741a 100644 --- a/lib/install/react.rb +++ b/lib/install/react.rb @@ -1,13 +1,14 @@ require "webpacker/configuration" babelrc = Rails.root.join(".babelrc") +babel_react_preset = ["@babel/preset-react", { "useBuiltIns": true }] if File.exist?(babelrc) react_babelrc = JSON.parse(File.read(babelrc)) react_babelrc["presets"] ||= [] - unless react_babelrc["presets"].include?("react") - react_babelrc["presets"].push("@babel/preset-react") + unless react_babelrc["presets"].flatten.include?("@babel/preset-react") + react_babelrc["presets"].push(babel_react_preset) say "Copying react preset to your .babelrc file" File.open(babelrc, "w") do |f| From f1359db3745272bd64d770d438c7894b6cf7c657 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Sun, 10 Jun 2018 18:20:55 +0100 Subject: [PATCH 3/3] Add babel-runtime --- package.json | 2 +- yarn.lock | 40 ++++++++++------------------------------ 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index f38fbef40..f087753d4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "yarn": ">=0.25.2" }, "dependencies": { - "@babel/cli": "^7.0.0-beta.49", "@babel/core": "^7.0.0-beta.49", "@babel/plugin-proposal-class-properties": "^7.0.0-beta.49", "@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.49", @@ -22,6 +21,7 @@ "@babel/plugin-transform-runtime": "^7.0.0-beta.49", "@babel/polyfill": "^7.0.0-beta.49", "@babel/preset-env": "^7.0.0-beta.49", + "@babel/runtime": "^7.0.0-beta.49", "babel-core": "^7.0.0-bridge", "babel-loader": "^8.0.0-beta", "case-sensitive-paths-webpack-plugin": "^2.1.2", diff --git a/yarn.lock b/yarn.lock index 92a5fa39d..871f7f5ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,21 +2,6 @@ # yarn lockfile v1 -"@babel/cli@^7.0.0-beta.49": - version "7.0.0-beta.49" - resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.0.0-beta.49.tgz#c8c3135f7bc48428436faf5e3f274227a99ef2a8" - dependencies: - commander "^2.8.1" - convert-source-map "^1.1.0" - fs-readdir-recursive "^1.0.0" - glob "^7.0.0" - lodash "^4.17.5" - output-file-sync "^2.0.0" - slash "^1.0.0" - source-map "^0.5.0" - optionalDependencies: - chokidar "^2.0.3" - "@babel/code-frame@7.0.0-beta.49", "@babel/code-frame@^7.0.0-beta.35": version "7.0.0-beta.49" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.49.tgz#becd805482734440c9d137e46d77340e64d7f51b" @@ -528,6 +513,13 @@ invariant "^2.2.2" semver "^5.3.0" +"@babel/runtime@^7.0.0-beta.49": + version "7.0.0-beta.49" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0-beta.49.tgz#03b3bf07eb982072c8e851dd2ddd5110282e61bf" + dependencies: + core-js "^2.5.6" + regenerator-runtime "^0.11.1" + "@babel/template@7.0.0-beta.49": version "7.0.0-beta.49" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.49.tgz#e38abe8217cb9793f461a5306d7ad745d83e1d27" @@ -1483,7 +1475,7 @@ chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" -chokidar@^2.0.2, chokidar@^2.0.3: +chokidar@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.3.tgz#dcbd4f6cbb2a55b4799ba8a840ac527e5f4b1176" dependencies: @@ -1663,7 +1655,7 @@ combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: dependencies: delayed-stream "~1.0.0" -commander@^2.11.0, commander@^2.8.1, commander@^2.9.0: +commander@^2.11.0, commander@^2.9.0: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" @@ -2686,10 +2678,6 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.2.1" -fs-readdir-recursive@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" - fs-write-stream-atomic@^1.0.8: version "1.0.10" resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" @@ -3356,7 +3344,7 @@ is-path-inside@^1.0.0: dependencies: path-is-inside "^1.0.1" -is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: +is-plain-obj@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -4669,14 +4657,6 @@ osenv@0, osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-2.0.1.tgz#f53118282f5f553c2799541792b723a4c71430c0" - dependencies: - graceful-fs "^4.1.11" - is-plain-obj "^1.1.0" - mkdirp "^0.5.1" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"