diff --git a/bin/run-tests.js b/bin/run-tests.js index c30c8004186..74f23337f52 100755 --- a/bin/run-tests.js +++ b/bin/run-tests.js @@ -84,15 +84,11 @@ function generateEachPackageTests() { .forEach(generateTestsFor); } -function generateBuiltTests(ie) { +function generateBuiltTests() { // Container isn't publicly available. // ember-testing and @ember/debug are stripped from prod/min. var common = 'skipPackage=container,ember-testing,@ember/debug'; - if (ie) { - common += '&ie=true'; - } - testFunctions.push(function() { return run(common + '&nolint=true'); }); @@ -105,6 +101,18 @@ function generateBuiltTests(ie) { testFunctions.push(function() { return run(common + '&enableoptionalfeatures=true&dist=prod&prod=true'); }); + testFunctions.push(function() { + return run(common + '&ie=true&nolint=true'); + }); + testFunctions.push(function() { + return run(common + '&ie=true&dist=min&prod=true'); + }); + testFunctions.push(function() { + return run(common + '&ie=true&dist=prod&prod=true'); + }); + testFunctions.push(function() { + return run(common + '&ie=true&enableoptionalfeatures=true&dist=prod&prod=true'); + }); } function generateOldJQueryTests() { @@ -184,7 +192,6 @@ switch (process.env.TEST_SUITE) { case 'built-tests': console.log('suite: built-tests'); generateBuiltTests(); - generateBuiltTests(true); runAndExit(); break; case 'old-jquery-and-extend-prototypes': @@ -196,7 +203,6 @@ switch (process.env.TEST_SUITE) { case 'all': console.log('suite: all'); generateBuiltTests(); - generateBuiltTests(true); generateOldJQueryTests(); generateExtendPrototypeTests(); generateEachPackageTests(); diff --git a/broccoli/babel-helpers.js b/broccoli/babel-helpers.js index 324e979c280..9d4818114f0 100644 --- a/broccoli/babel-helpers.js +++ b/broccoli/babel-helpers.js @@ -2,16 +2,9 @@ const Funnel = require('broccoli-funnel'); -module.exports = function(env) { - let file; - if (env === 'debug') { - file = 'external-helpers-dev.js'; - } else if (env === 'prod') { - file = 'external-helpers-prod.js'; - } - +module.exports = function() { return new Funnel('packages/external-helpers/lib', { - files: [file], + files: ['external-helpers.js'], getDestinationPath() { return 'ember-babel.js'; }, diff --git a/broccoli/bootstrap-modules.js b/broccoli/bootstrap-modules.js index ebc88b2ca9b..5baee1e18cd 100644 --- a/broccoli/bootstrap-modules.js +++ b/broccoli/bootstrap-modules.js @@ -1,10 +1,7 @@ 'use strict'; const WriteFile = require('broccoli-file-creator'); - -function defaultExport(moduleExport) { - return `(function (m) { if (typeof module === "object" && module.exports) { module.exports = m } }(requireModule('${moduleExport}').default));\n`; -} +const { stripIndent } = require('common-tags'); function sideeffects(moduleExport) { return `requireModule('${moduleExport}')`; @@ -14,11 +11,26 @@ function umd(moduleExport) { return `(function (m) { if (typeof module === "object" && module.exports) { module.exports = m } }(requireModule('${moduleExport}')));\n`; } -module.exports = function bootstrapModule(moduleExport, type = 'sideeffects') { +function testing() { + return stripIndent` + var testing = requireModule('ember-testing'); + Ember.Test = testing.Test; + Ember.Test.Adapter = testing.Adapter; + Ember.Test.QUnitAdapter = testing.QUnitAdapter; + Ember.setupForTesting = testing.setupForTesting; + `; +} + +function empty() { + return ''; +} + +module.exports = function bootstrapModule(type, moduleExport) { let moduleType = { - default: defaultExport, - umd, + empty, sideeffects, + testing, + umd, }; return new WriteFile('bootstrap', moduleType[type](moduleExport)); diff --git a/broccoli/debug-macros.js b/broccoli/debug-macros.js new file mode 100644 index 00000000000..6b250d26cdd --- /dev/null +++ b/broccoli/debug-macros.js @@ -0,0 +1,43 @@ +'use strict'; + +const Babel = require('broccoli-babel-transpiler'); +const FEATURES = require('./features'); + +module.exports = function debugMacros(tree, environment) { + let isDebug = environment !== 'production'; + + let plugins = [ + [ + 'debug-macros', + { + debugTools: { + source: '@ember/debug', + assertPredicateIndex: 1, + isDebug, + }, + externalizeHelpers: { + module: true, + }, + flags: [ + { source: '@glimmer/env', flags: { DEBUG: isDebug } }, + { + source: '@ember/canary-features', + flags: Object.assign( + // explicit list of additional exports within @ember/canary-features + // without adding this (with a null value) an error is thrown during + // the feature replacement process (e.g. XYZ is not a supported flag) + { + FEATURES: null, + DEFAULT_FEATURES: null, + isEnabled: null, + }, + FEATURES + ), + }, + ], + }, + ], + ]; + + return new Babel(tree, { plugins }); +}; diff --git a/broccoli/strip-for-prod.js b/broccoli/strip-for-prod.js index 50bebbea75b..26693ab43f1 100644 --- a/broccoli/strip-for-prod.js +++ b/broccoli/strip-for-prod.js @@ -1,13 +1,12 @@ 'use strict'; const Babel = require('broccoli-babel-transpiler'); -const stripClassCallCheck = require('./transforms/strip-class-call-check'); module.exports = function stripForProd(tree) { let options = { plugins: [ - [stripClassCallCheck, { source: 'ember-babel' }], ['minify-dead-code-elimination', { optimizeRawSize: true }], + ['filter-imports', { imports: { 'ember-babel': ['_classCallCheck'] } }], ], }; diff --git a/broccoli/to-es.js b/broccoli/to-es.js deleted file mode 100644 index 91c2e99b1a8..00000000000 --- a/broccoli/to-es.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -const Babel = require('broccoli-babel-transpiler'); -const injectBabelHelpers = require('./transforms/inject-babel-helpers'); -const injectNodeGlobals = require('./transforms/inject-node-globals'); -const enifed = require('./transforms/transform-define'); -const FEATURES = require('./features'); -const resolveModuleSource = require('amd-name-resolver').moduleResolve; - -module.exports = function toES5(tree, babelPlugins, _options) { - let options = Object.assign( - { - environment: 'development', - }, - _options - ); - - let isDebug = options.environment !== 'production'; - - options.moduleIds = true; - options.resolveModuleSource = resolveModuleSource; - options.sourceMap = true; - options.plugins = [ - injectBabelHelpers, - [ - 'debug-macros', - { - debugTools: { - source: '@ember/debug', - assertPredicateIndex: 1, - isDebug, - }, - externalizeHelpers: { - module: true, - }, - flags: [ - { source: '@glimmer/env', flags: { DEBUG: isDebug } }, - { - source: '@ember/canary-features', - flags: Object.assign( - // explicit list of additional exports within @ember/canary-features - // without adding this (with a null value) an error is thrown during - // the feature replacement process (e.g. XYZ is not a supported flag) - { - FEATURES: null, - DEFAULT_FEATURES: null, - isEnabled: null, - }, - FEATURES - ), - }, - ], - }, - ], - ...babelPlugins, - injectNodeGlobals, - ['transform-es2015-modules-amd', { noInterop: true, strict: true }], - enifed, - ]; - - if (options.transformDefine) { - options.plugins = [enifed]; - delete options.transformDefine; - } - - if (options.transformModules === false) { - options.plugins.pop(); - options.plugins.pop(); - delete options.moduleIds; - delete options.resolveModuleSource; - delete options.transformModules; - } - - if (options.inlineHelpers) { - options.plugins.shift(); - delete options.inlineHelpers; - } - - delete options.environment; - - return new Babel(tree, options); -}; diff --git a/broccoli/to-es5.js b/broccoli/to-es5.js index 3120dac2e30..87d5efac4a0 100644 --- a/broccoli/to-es5.js +++ b/broccoli/to-es5.js @@ -1,24 +1,32 @@ 'use strict'; -const toES = require('./to-es'); +const Babel = require('broccoli-babel-transpiler'); +const injectBabelHelpers = require('./transforms/inject-babel-helpers'); -module.exports = function toES5(tree, _options) { - return toES( - tree, - [ - ['transform-es2015-template-literals', { loose: true }], - ['transform-es2015-literals'], - ['transform-es2015-arrow-functions'], - ['transform-es2015-destructuring', { loose: true }], - ['transform-es2015-spread', { loose: true }], - ['transform-es2015-parameters'], - ['transform-es2015-computed-properties', { loose: true }], - ['transform-es2015-shorthand-properties'], - ['transform-es2015-block-scoping', { throwIfClosureRequired: true }], - ['check-es2015-constants'], - ['transform-es2015-classes', { loose: true }], - ['transform-object-assign'], - ], - _options - ); +module.exports = function toES6(tree, _options) { + let options = Object.assign({}, _options); + + options.sourceMap = true; + options.plugins = [ + injectBabelHelpers, + ['transform-es2015-template-literals', { loose: true }], + ['transform-es2015-literals'], + ['transform-es2015-arrow-functions'], + ['transform-es2015-destructuring', { loose: true }], + ['transform-es2015-spread', { loose: true }], + ['transform-es2015-parameters'], + ['transform-es2015-computed-properties', { loose: true }], + ['transform-es2015-shorthand-properties'], + ['transform-es2015-block-scoping', { throwIfClosureRequired: true }], + ['check-es2015-constants'], + ['transform-es2015-classes', { loose: true }], + ['transform-object-assign'], + ]; + + if (options.inlineHelpers) { + options.plugins.shift(); + delete options.inlineHelpers; + } + + return new Babel(tree, options); }; diff --git a/broccoli/to-es6.js b/broccoli/to-es6.js deleted file mode 100644 index 92f41996aca..00000000000 --- a/broccoli/to-es6.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const toES = require('./to-es'); - -module.exports = function toES5(tree, _options) { - return toES(tree, [], _options); -}; diff --git a/broccoli/to-named-amd.js b/broccoli/to-named-amd.js index ba11134712d..da58fcb549a 100644 --- a/broccoli/to-named-amd.js +++ b/broccoli/to-named-amd.js @@ -3,18 +3,28 @@ const resolveModuleSource = require('amd-name-resolver').moduleResolve; const enifed = require('./transforms/transform-define'); const injectNodeGlobals = require('./transforms/inject-node-globals'); -module.exports = function processModulesOnly(tree, annotation) { +module.exports = function processModulesOnly(tree, strict = false) { + let transformOptions = { noInterop: true }; + + // These options need to be exclusive for some reason, even the key existing + // on the options hash causes issues. + if (strict) { + transformOptions.strict = true; + } else { + transformOptions.loose = true; + } + let options = { + sourceMap: true, plugins: [ // ensures `@glimmer/compiler` requiring `crypto` works properly // in both browser and node-land injectNodeGlobals, - ['transform-es2015-modules-amd', { loose: true, noInterop: true }], + ['transform-es2015-modules-amd', transformOptions], enifed, ], moduleIds: true, resolveModuleSource, - annotation, }; return new Babel(tree, options); diff --git a/broccoli/transforms/strip-class-call-check.js b/broccoli/transforms/strip-class-call-check.js deleted file mode 100644 index 57810ed278a..00000000000 --- a/broccoli/transforms/strip-class-call-check.js +++ /dev/null @@ -1,87 +0,0 @@ -// TODO there are like 3 things that do this -'use strict'; - -function stripClassCallCheck({ traverse }) { - return { - name: 'remove classCallCheck', - visitor: { - Program: { - enter(path, state) { - let [amd] = path.get('body'); - - if (!amd) { - return; - } - - let [, deps, callBack] = amd.get('expression.arguments'); - let params = callBack.get('params'); - let elements = deps.get('elements'); - - for (let i = 0; i < elements.length; i++) { - let el = elements[i]; - if (el.node.value === state.opts.source) { - this.binding = params[i]; - this.index = i; - break; - } - } - }, - exit(path) { - if (!this.binding) { - return; - } - - traverse.clearCache(); - path.scope.crawl(); - - let [amd] = path.get('body'); - let [, deps, callBack] = amd.get('expression.arguments'); - let binding = callBack.scope.bindings[this.binding.node.name]; - let elements = deps.get('elements'); - if (binding.referencePaths.length === 0) { - this.binding.remove(); - elements[this.index].remove(); - } - }, - }, - - CallExpression(path) { - let callee = path.get('callee'); - - if (!this.binding) { - return; - } - - if (callee.isSequenceExpression()) { - let [, member] = callee.get('expressions'); - - if ( - member.node.object.name === this.binding.node.name && - member.node.property.name.indexOf('classCallCheck') > -1 - ) { - path.remove(); - } - } - - if (callee.isMemberExpression()) { - if ( - callee.node.object.name === this.binding.node.name && - callee.node.property.name.indexOf('classCallCheck') > -1 - ) { - path.remove(); - } - } - }, - }, - }; -} - -stripClassCallCheck.baseDir = function() { - return 'babel-core'; -}; - -stripClassCallCheck.cacheKey = function() { - return stripClassCallCheck.toString(); -}; - -module.exports = stripClassCallCheck; diff --git a/build-metadata.json b/build-metadata.json deleted file mode 100644 index 85109dbb043..00000000000 --- a/build-metadata.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "3.6.0-bugfix-ie-dual-build+0bbf1ce3", - "buildType": "bugfix-ie-dual-build", - "SHA": "0bbf1ce363324a1e40c67c0a32676ffe32ea9a39", - "assetPath": "/bugfix-ie-dual-build/shas/0bbf1ce363324a1e40c67c0a32676ffe32ea9a39.tgz" -} \ No newline at end of file diff --git a/ember-cli-build.js b/ember-cli-build.js index e08120a293b..07110c2ed64 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -9,12 +9,11 @@ const concatBundle = require('./broccoli/concat-bundle'); const concat = require('broccoli-concat'); const testIndexHTML = require('./broccoli/test-index-html'); const toES5 = require('./broccoli/to-es5'); -const toES6 = require('./broccoli/to-es6'); const toNamedAMD = require('./broccoli/to-named-amd'); const stripForProd = require('./broccoli/strip-for-prod'); +const debugMacros = require('./broccoli/debug-macros'); const minify = require('./broccoli/minify'); const rename = require('./broccoli/rename'); -const { stripIndent } = require('common-tags'); const { routerES, jquery, @@ -39,7 +38,6 @@ const ENV = process.env.EMBER_ENV || 'development'; module.exports = function() { let loader = internalLoader(); let nodeModule = nodeModuleUtils(); - let license = emberLicense(); // generate "loose" ES modules... let dependenciesES = new MergeTrees([ @@ -64,6 +62,9 @@ module.exports = function() { // packages/** (after typescript compilation) getPackagesES(), + + // externalized helpers + babelHelpers(), ]); let es = new MergeTrees([packagesES, dependenciesES, templateCompilerDependenciesES], { @@ -82,7 +83,7 @@ module.exports = function() { ); // Rollup - let packagesESRollup = new MergeTrees([ + let packagesRollupES = new MergeTrees([ new Funnel(packagesES, { exclude: [ '@ember/-internals/browser-environment/index.js', @@ -107,27 +108,20 @@ module.exports = function() { rollupPackage(packagesES, '@ember/-internals/container'), ]); - let bundlesES5 = toTranspiledBundles( - toES5, - loader, - license, - nodeModule, - packagesESRollup, - dependenciesES, - templateCompilerDependenciesES - ); + // Bundling + let bundleTrees = [ + buildBundles(packagesRollupES, dependenciesES, templateCompilerDependenciesES), + ]; - let bundlesIE = new Funnel(bundlesES5, { destDir: 'ie' }); + if (ENV === 'production') { + let bundlesES5 = buildBundles( + toES5(packagesRollupES), + toES5(dependenciesES), + toES5(templateCompilerDependenciesES) + ); - let bundlesES6 = toTranspiledBundles( - toES6, - loader, - license, - nodeModule, - packagesESRollup, - dependenciesES, - templateCompilerDependenciesES - ); + bundleTrees.push(new Funnel(bundlesES5, { destDir: 'ie' })); + } let emberTestsEmptyTestem = new Funnel('tests', { files: ['testem.js'], @@ -137,9 +131,8 @@ module.exports = function() { return new MergeTrees([ new Funnel(es, { destDir: 'es' }), + ...bundleTrees, pkgAndTestESBundleDebug, - bundlesES6, - bundlesIE, emberTestsEmptyTestem, nodeTests(), @@ -150,70 +143,43 @@ module.exports = function() { ]); }; -function toTranspiledBundles( - toES, - loader, - license, - nodeModule, - packagesESRollup, - dependenciesES, - templateCompilerDependenciesES -) { - // ES5 - let babelDebugHelpersTranspiled = toES(babelHelpers('debug'), { - annotation: 'babel helpers debug', - }); - - let packagesTranspiled = toES(packagesESRollup); - let dependenciesTranspiled = toES(dependenciesES); - let templateCompilerDependenciesTranspiled = toES(templateCompilerDependenciesES); +function buildBundles(packagesES, dependenciesES, templateCompilerDependenciesES) { + let packagesDevES = debugMacros(packagesES, 'development'); + let dependenciesDevES = debugMacros(dependenciesES, 'development'); + let templateCompilerDependenciesDevES = debugMacros( + templateCompilerDependenciesES, + 'development' + ); - // Bundling - let emberTestsBundle = new MergeTrees([ - new Funnel(packagesTranspiled, { - include: [ - 'internal-test-helpers/**', + let emberDebugFiles = new MergeTrees([ + new Funnel(packagesDevES, { + exclude: [ '@ember/-internals/*/tests/**' /* internal packages */, '*/*/tests/**' /* scoped packages */, '*/tests/**' /* packages */, - 'license.js', + 'ember-template-compiler/**', + 'internal-test-helpers/**', ], }), - loader, - license, - nodeModule, - babelDebugHelpersTranspiled, + dependenciesDevES, + bootstrapModule('sideeffects', 'ember'), ]); - emberTestsBundle = concatBundle(emberTestsBundle, { - outputFile: 'ember-tests.js', - hasBootstrap: false, - }); - - let emberDebugBundle = new MergeTrees([ - new Funnel(packagesTranspiled, { - exclude: [ + let emberTestsFiles = new MergeTrees([ + new Funnel(packagesDevES, { + include: [ + 'internal-test-helpers/**', '@ember/-internals/*/tests/**' /* internal packages */, '*/*/tests/**' /* scoped packages */, '*/tests/**' /* packages */, - 'ember-template-compiler/**', - 'internal-test-helpers/**', + 'license.js', ], }), - dependenciesTranspiled, - loader, - license, - nodeModule, - bootstrapModule('ember'), - babelDebugHelpersTranspiled, + bootstrapModule('empty'), ]); - emberDebugBundle = concatBundle(emberDebugBundle, { - outputFile: 'ember.debug.js', - }); - - let emberTestingBundle = new MergeTrees([ - new Funnel(packagesTranspiled, { + let emberTestingFiles = new MergeTrees([ + new Funnel(packagesDevES, { include: [ '@ember/debug/lib/**', '@ember/debug/index.js', @@ -222,58 +188,38 @@ function toTranspiledBundles( 'license.js', ], }), - loader, - license, - babelDebugHelpersTranspiled, - nodeModule, + bootstrapModule('testing'), ]); - emberTestingBundle = concatBundle(emberTestingBundle, { - outputFile: 'ember-testing.js', - hasBootstrap: false, - footer: stripIndent` - var testing = requireModule('ember-testing'); - Ember.Test = testing.Test; - Ember.Test.Adapter = testing.Adapter; - Ember.Test.QUnitAdapter = testing.QUnitAdapter; - Ember.setupForTesting = testing.setupForTesting; - `, - }); - - function templateCompiler() { - return new MergeTrees([ - new Funnel(packagesTranspiled, { - include: [ - '@ember/-internals/utils.js', - '@ember/-internals/environment.js', - '@ember/-internals/browser-environment.js', - '@ember/canary-features/**', - '@ember/debug/index.js', - '@ember/debug/lib/**', - '@ember/deprecated-features/**', - '@ember/error/index.js', - '@ember/polyfills/index.js', - '@ember/polyfills/lib/**', - 'ember/version.js', - 'ember-template-compiler/**', - ], - }), - bootstrapModule('ember-template-compiler', 'umd'), - ]); - } + let templateCompilerFiles = new MergeTrees([ + new Funnel(packagesDevES, { + include: [ + '@ember/-internals/utils.js', + '@ember/-internals/environment.js', + '@ember/-internals/browser-environment.js', + '@ember/canary-features/**', + '@ember/debug/index.js', + '@ember/debug/lib/**', + '@ember/deprecated-features/**', + '@ember/error/index.js', + '@ember/polyfills/index.js', + '@ember/polyfills/lib/**', + 'ember/version.js', + 'ember-template-compiler/**', + ], + }), + templateCompilerDependenciesDevES, + bootstrapModule('umd', 'ember-template-compiler'), + ]); - let bundles = [emberTestsBundle, emberTestingBundle, emberDebugBundle]; + let emberProdFiles, emberTestsProdFiles; if (ENV === 'production') { - let prodPackagesTranspiled = stripForProd( - toES(packagesESRollup, { environment: 'production' }) - ); - let babelProdHelpersTranspiled = toES(babelHelpers('prod'), { - environment: 'production', - }); + let packagesProdES = stripForProd(debugMacros(packagesES, 'production')); + let dependenciesProdES = stripForProd(debugMacros(dependenciesES, 'production')); - let emberProdBundle = new MergeTrees([ - new Funnel(prodPackagesTranspiled, { + emberProdFiles = new MergeTrees([ + new Funnel(packagesProdES, { exclude: [ '@ember/-internals/*/tests/**' /* internal packages */, '*/*/tests/**' /* scoped packages */, @@ -283,27 +229,12 @@ function toTranspiledBundles( 'internal-test-helpers/**', ], }), - stripForProd(dependenciesTranspiled), - loader, - license, - nodeModule, - bootstrapModule('ember'), - babelProdHelpersTranspiled, + dependenciesProdES, + bootstrapModule('sideeffects', 'ember'), ]); - emberProdBundle = concatBundle(emberProdBundle, { - outputFile: 'ember.prod.js', - }); - bundles.push(emberProdBundle); - - let emberProdMinRename = rename(emberProdBundle, { - 'ember.prod.js': 'ember.min.js', - }); - let emberMinBundle = minify(emberProdMinRename); - bundles.push(emberMinBundle); - - let emberTestsBundle = new MergeTrees([ - new Funnel(prodPackagesTranspiled, { + emberTestsProdFiles = new MergeTrees([ + new Funnel(packagesProdES, { include: [ 'internal-test-helpers/**', '*/*/tests/**' /* scoped packages */, @@ -311,52 +242,43 @@ function toTranspiledBundles( 'license.js', ], }), - loader, - license, - nodeModule, - babelProdHelpersTranspiled, + bootstrapModule('empty'), ]); - emberTestsBundle = concatBundle(emberTestsBundle, { - outputFile: 'ember-tests.prod.js', - hasBootstrap: false, - }); - bundles.push(emberTestsBundle); - // Note: // We have to build custom production template compiler // because we strip babel helpers in the prod build - let emberTemplateCompilerBundle = new MergeTrees([ - stripForProd(templateCompiler()), - stripForProd(templateCompilerDependenciesTranspiled), - loader, - license, - babelProdHelpersTranspiled, - nodeModule, - ]); - - emberTemplateCompilerBundle = concatBundle(emberTemplateCompilerBundle, { - outputFile: 'ember-template-compiler.js', - }); - bundles.push(emberTemplateCompilerBundle); - } else { - let emberTemplateCompilerBundle = new MergeTrees([ - templateCompiler(), - templateCompilerDependenciesTranspiled, - loader, - license, - babelDebugHelpersTranspiled, - nodeModule, - ]); + templateCompilerFiles = stripForProd(templateCompilerFiles); + } - emberTemplateCompilerBundle = concatBundle(emberTemplateCompilerBundle, { - outputFile: 'ember-template-compiler.js', - }); + // Files that are prebuilt and should not be AMD transformed + let vendor = [internalLoader(), nodeModuleUtils(), emberLicense()]; + + let emberProdBundle = emberProdFiles && buildBundle('ember.prod.js', emberProdFiles, vendor); + let emberMinBundle = + emberProdBundle && minify(rename(emberProdBundle, { 'ember.prod.js': 'ember.min.js' })); + let emberProdTestsBundle = + emberTestsProdFiles && buildBundle('ember-tests.prod.js', emberTestsProdFiles, vendor); + + return new MergeTrees( + [ + emberProdBundle, + emberMinBundle, + emberProdTestsBundle, + buildBundle('ember.debug.js', emberDebugFiles, vendor), + buildBundle('ember-tests.js', emberTestsFiles, vendor), + buildBundle('ember-testing.js', emberTestingFiles, vendor), + buildBundle('ember-template-compiler.js', templateCompilerFiles, vendor), + ].filter(Boolean) + ); +} - bundles.push(emberTemplateCompilerBundle); - } +function buildBundle(name, tree, extras) { + let bundleWithExtras = new MergeTrees([toNamedAMD(tree, true), ...extras]); - return new MergeTrees(bundles); + return concatBundle(bundleWithExtras, { + outputFile: name, + }); } function glimmerDependenciesES() { diff --git a/package.json b/package.json index f61049ec167..a8158685604 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "aws-sdk": "^2.46.0", "babel-plugin-check-es2015-constants": "^6.22.0", "babel-plugin-debug-macros": "^0.2.0-beta.6", + "babel-plugin-filter-imports": "1.1.2", "babel-plugin-minify-dead-code-elimination": "^0.3.0", "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", "babel-plugin-transform-es2015-block-scoping": "^6.26.0", diff --git a/packages/external-helpers/lib/external-helpers-prod.js b/packages/external-helpers/lib/external-helpers-prod.js deleted file mode 100644 index 2fac6d95e3a..00000000000 --- a/packages/external-helpers/lib/external-helpers-prod.js +++ /dev/null @@ -1,42 +0,0 @@ -const create = Object.create; -const setPrototypeOf = Object.setPrototypeOf; -const defineProperty = Object.defineProperty; - -export function classCallCheck() {} - -export function inherits(subClass, superClass) { - subClass.prototype = create(superClass === null ? null : superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true, - }, - }); - if (superClass !== null) setPrototypeOf(subClass, superClass); -} - -export function taggedTemplateLiteralLoose(strings, raw) { - strings.raw = raw; - return strings; -} - -function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ('value' in descriptor) descriptor.writable = true; - defineProperty(target, descriptor.key, descriptor); - } -} - -export function createClass(Constructor, protoProps, staticProps) { - if (protoProps !== undefined) defineProperties(Constructor.prototype, protoProps); - if (staticProps !== undefined) defineProperties(Constructor, staticProps); - return Constructor; -} - -export function possibleConstructorReturn(self, call) { - return (call !== null && typeof call === 'object') || typeof call === 'function' ? call : self; -} diff --git a/packages/external-helpers/lib/external-helpers-dev.js b/packages/external-helpers/lib/external-helpers.js similarity index 72% rename from packages/external-helpers/lib/external-helpers-dev.js rename to packages/external-helpers/lib/external-helpers.js index 99ed71491ac..cff93d7379a 100644 --- a/packages/external-helpers/lib/external-helpers-dev.js +++ b/packages/external-helpers/lib/external-helpers.js @@ -1,18 +1,24 @@ +import { DEBUG } from '@glimmer/env'; + const create = Object.create; const setPrototypeOf = Object.setPrototypeOf; const defineProperty = Object.defineProperty; export function classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError('Cannot call a class as a function'); + if (DEBUG) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } } } export function inherits(subClass, superClass) { - if (typeof superClass !== 'function' && superClass !== null) { - throw new TypeError( - 'Super expression must either be null or a function, not ' + typeof superClass - ); + if (DEBUG) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError( + 'Super expression must either be null or a function, not ' + typeof superClass + ); + } } subClass.prototype = create(superClass === null ? null : superClass.prototype, { constructor: { @@ -47,8 +53,10 @@ export function createClass(Constructor, protoProps, staticProps) { } export const possibleConstructorReturn = function(self, call) { - if (!self) { - throw new ReferenceError(`this hasn't been initialized - super() hasn't been called`); + if (DEBUG) { + if (!self) { + throw new ReferenceError(`this hasn't been initialized - super() hasn't been called`); + } } return (call !== null && typeof call === 'object') || typeof call === 'function' ? call : self; }; diff --git a/yarn.lock b/yarn.lock index 73e578e8b62..a84324f1276 100644 --- a/yarn.lock +++ b/yarn.lock @@ -800,6 +800,14 @@ babel-plugin-ember-modules-api-polyfill@^2.3.0: dependencies: ember-rfc176-data "^0.3.0" +babel-plugin-filter-imports@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/babel-plugin-filter-imports/-/babel-plugin-filter-imports-1.1.2.tgz#c6e1f2685253bbda91b1dc5a6652ce825f771264" + integrity sha512-BpXJV3fndKEP1D9Yhwpz4NIjM/d1FYpdx4E4KmUPnTIFUxXNj0QEAY18MXVzEyYi2EWEVhoOG2CmclDfdMj5ew== + dependencies: + babel-types "^6.26.0" + lodash "^4.17.10" + babel-plugin-minify-dead-code-elimination@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.3.0.tgz#a323f686c404b824186ba5583cf7996cac81719e" @@ -5760,6 +5768,11 @@ lodash@^4.0.0, lodash@^4.14.0, lodash@^4.16.1, lodash@^4.17.2, lodash@^4.17.4, l resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" integrity sha1-eCA6TRwyiuHYbcpkYONptX9AVa4= +lodash@^4.17.10: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + log-symbols@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"