Skip to content

Commit

Permalink
[BUGFIX][FEAT] Adds a second dist build which targets IE
Browse files Browse the repository at this point in the history
This PR adds a second dist to the build which targets IE. This allows
the primary bundles to drop ES5 compilation from babel, and allows us to
choose which bundles we want to use based on the consuming application's
targets.

In the long run, we want to actually enable consuming apps to build the
Ember source code themselves. This is a temporary in-between measure to
address a bug in native classes, in which users who do _not_ have IE as
a build target cannot `.extend` from native classes due to conflicts
in transpilation vs actual native class syntax.
  • Loading branch information
pzuraq committed Nov 7, 2018
1 parent 0bbf1ce commit 6e6b2ff
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 173 deletions.
9 changes: 8 additions & 1 deletion bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ function generateEachPackageTests() {
.forEach(generateTestsFor);
}

function generateBuiltTests() {
function generateBuiltTests(ie) {
// 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');
});
Expand Down Expand Up @@ -179,6 +184,7 @@ switch (process.env.TEST_SUITE) {
case 'built-tests':
console.log('suite: built-tests');
generateBuiltTests();
generateBuiltTests(true);
runAndExit();
break;
case 'old-jquery-and-extend-prototypes':
Expand All @@ -190,6 +196,7 @@ switch (process.env.TEST_SUITE) {
case 'all':
console.log('suite: all');
generateBuiltTests();
generateBuiltTests(true);
generateOldJQueryTests();
generateExtendPrototypeTests();
generateEachPackageTests();
Expand Down
15 changes: 15 additions & 0 deletions broccoli/strip-for-prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'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 }],
],
};

return new Babel(tree, options);
};
82 changes: 82 additions & 0 deletions broccoli/to-es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
'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);
};
117 changes: 17 additions & 100 deletions broccoli/to-es5.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,24 @@
'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 stripClassCallCheck = require('./transforms/strip-class-call-check');
const resolveModuleSource = require('amd-name-resolver').moduleResolve;
const toES = require('./to-es');

module.exports = function toES5(tree, _options) {
let options = Object.assign(
{
environment: 'developement',
},
_options
);

let isDebug = options.environment !== 'production';

options.moduleIds = true;
options.resolveModuleSource = resolveModuleSource;
options.sourceMap = true;
options.plugins = [
injectBabelHelpers,
return toES(
tree,
[
'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
),
},
],
},
['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'],
],
['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'],
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);
_options
);
};

function stripForProd(tree) {
let options = {
plugins: [
[stripClassCallCheck, { source: 'ember-babel' }],
['minify-dead-code-elimination', { optimizeRawSize: true }],
],
};

return new Babel(tree, options);
}

module.exports.stripForProd = stripForProd;
7 changes: 7 additions & 0 deletions broccoli/to-es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const toES = require('./to-es');

module.exports = function toES5(tree, _options) {
return toES(tree, [], _options);
};
6 changes: 6 additions & 0 deletions build-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "3.6.0-bugfix-ie-dual-build+0bbf1ce3",
"buildType": "bugfix-ie-dual-build",
"SHA": "0bbf1ce363324a1e40c67c0a32676ffe32ea9a39",
"assetPath": "/bugfix-ie-dual-build/shas/0bbf1ce363324a1e40c67c0a32676ffe32ea9a39.tgz"
}
Loading

0 comments on commit 6e6b2ff

Please sign in to comment.