diff --git a/broccoli/transforms/inject-babel-helpers.js b/broccoli/transforms/inject-babel-helpers.js deleted file mode 100644 index 7e7e212164e..00000000000 --- a/broccoli/transforms/inject-babel-helpers.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const { addNamed } = require('@babel/helper-module-imports'); - -function injectBabelHelpers() { - return { - pre(file) { - file.set('helperGenerator', function(name) { - if (name === 'extends') { - return addNamed(file.path, 'assign', '@ember/polyfills'); - } - return addNamed(file.path, name, 'ember-babel'); - }); - }, - }; -} - -injectBabelHelpers.baseDir = function() { - return 'babel-core'; -}; - -module.exports = injectBabelHelpers; diff --git a/lib/index.js b/lib/index.js index b9ab147c8ee..72d0203cc54 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,6 +7,7 @@ const resolve = require('resolve'); const concatBundle = require('./concat-bundle'); const buildDebugMacroPlugin = require('./build-debug-macro-plugin'); const buildStripClassCallcheckPlugin = require('./build-strip-class-callcheck-plugin'); +const injectBabelHelpers = require('./transforms/inject-babel-helpers'); const isProduction = process.env.EMBER_ENV === 'production'; @@ -71,6 +72,10 @@ module.exports = { let appOptions = this.app && this.app.options; let babelOptions = (parentOptions || appOptions || {}).babel; + // We want to enable async/generator helpers if we are developing locally, + // but not for any other project. + let isEmberSource = this.project.name() === 'ember-source'; + let options = { 'ember-cli-babel': { disableDebugTooling: true, @@ -79,6 +84,7 @@ module.exports = { babel: Object.assign({}, babelOptions, { loose: true, plugins: [ + injectBabelHelpers(isEmberSource), buildDebugMacroPlugin(!isProduction), [ require.resolve('@babel/plugin-transform-block-scoping'), @@ -157,6 +163,11 @@ module.exports = { files: ['jquery.js'], }); + let templateCompiler = new Funnel(tree, { + destDir: 'ember', + include: ['ember-template-compiler.js', 'ember-template-compiler.map'], + }); + let ember; let targets = (this.project && this.project.targets && this.project.targets.browsers) || []; @@ -174,6 +185,6 @@ module.exports = { }); } - return new MergeTrees([ember, jquery]); + return new MergeTrees([ember, templateCompiler, jquery]); }, }; diff --git a/lib/transforms/inject-babel-helpers.js b/lib/transforms/inject-babel-helpers.js new file mode 100644 index 00000000000..18cc33ed212 --- /dev/null +++ b/lib/transforms/inject-babel-helpers.js @@ -0,0 +1,31 @@ +'use strict'; + +const { addNamed } = require('@babel/helper-module-imports'); + +function injectBabelHelpers(isEmberSource = false) { + function injectBabelHelpersPlugin() { + return { + pre(file) { + file.set('helperGenerator', function(name) { + if (name === 'extends') { + return addNamed(file.path, 'assign', '@ember/polyfills'); + } else if (isEmberSource && name === 'asyncToGenerator') { + // Returning a falsy value will cause the helper to be inlined, + // which is fine for local tests + return false; + } + + return addNamed(file.path, name, 'ember-babel'); + }); + }, + }; + } + + injectBabelHelpersPlugin.baseDir = function() { + return 'babel-core'; + }; + + return injectBabelHelpersPlugin; +} + +module.exports = injectBabelHelpers; diff --git a/package.json b/package.json index f1256821c6f..fd86e790407 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "test:browserstack": "node bin/run-browserstack-tests.js" }, "dependencies": { + "@babel/helper-module-imports": "^7.0.0", "@babel/plugin-transform-block-scoping": "^7.4.4", "@babel/plugin-transform-object-assign": "^7.2.0", "babel-plugin-debug-macros": "^0.3.2", @@ -70,7 +71,6 @@ "silent-error": "^1.1.1" }, "devDependencies": { - "@babel/helper-module-imports": "^7.0.0", "@babel/preset-env": "^7.5.5", "@glimmer/compiler": "0.38.5-alpha.2", "@glimmer/env": "^0.1.7",