Skip to content

Commit

Permalink
Bring back strip-class-call-check.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Mar 15, 2017
1 parent d746d3f commit 10827a4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
17 changes: 9 additions & 8 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var merge = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
var globals = require('./lib/globals');
var yuidoc = require('./lib/yuidoc');
//var stripClassCallCheck = require('babel5-plugin-strip-class-callcheck'); // no babel@6 version
var StripClassCallCheck = require('babel6-plugin-strip-class-callcheck');
var path = require('path');

// allow toggling of heimdall instrumentation
Expand All @@ -20,13 +20,14 @@ for (var i = 0; i < args.length; i++) {

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// TODO: fix classcallcheck removal with babel@6
// babel: {
// plugins: [
// // while ember-data strips itself, ember does not currently
// { transformer: stripClassCallCheck, position: 'after' }
// ]
// }
minifyJS: { enabled: false },
// use babel6 options until we are using ember-cli@2.13
babel6: {
postTransformPlugins: [
// while ember-data strips itself, ember does not currently
[StripClassCallCheck]
]
}
});

if (INSTRUMENT_HEIMDALL) {
Expand Down
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,19 @@ module.exports = {
return;
}

this.options.babel = this.options.babel || {};
add(this.options.babel, 'plugins', require('./lib/stripped-build-plugins')(process.env.EMBER_ENV));
let customPlugins = require('./lib/stripped-build-plugins')(process.env.EMBER_ENV);

var babel = this.options.babel = this.options.babel || {};

babel.plugins = [].concat(
babel.plugins,
customPlugins.plugins
).filter(Boolean);

babel.postTransformPlugins = [].concat(
babel.postTransformPlugins,
customPlugins.postTransformPlugins
).filter(Boolean);

this._hasSetupBabelOptions = true;
},
Expand Down
6 changes: 5 additions & 1 deletion lib/babel-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function babelOptions(libraryName, _options) {

var options = {
plugins: [],
postTransformPlugins: [],
sourceMaps: false,
moduleRoot: libraryName,
moduleIds: true,
Expand Down Expand Up @@ -35,7 +36,10 @@ function babelOptions(libraryName, _options) {
'transform-es2015-block-scoping',
'transform-es2015-constants',
['transform-es2015-classes', { loose: true }],
]);
], options.postTransformPlugins).filter(Boolean);

// this is not a "real" babel option, so we delete it
delete options.postTransformPlugins;

return options;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/stripped-build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var FilterImports = require('babel-plugin-filter-imports');
var FeatureFlags = require('babel-plugin-feature-flags');
var StripHeimdall = require('babel6-plugin-strip-heimdall');
//var stripClassCallCheck = require('babel5-plugin-strip-class-callcheck'); // no babel@6 version
var StripClassCallCheck = require('babel6-plugin-strip-class-callcheck');

function uniqueAdd(obj, key, values) {
var a = obj[key] = obj[key] || [];
Expand All @@ -29,12 +29,13 @@ module.exports = function(environment) {
// features[feature] = false;
// }
// }

var postTransformPlugins = [];
var plugins = [
[ FeatureFlags, {
import: { module: 'ember-data/-private/features' },
features: features
}]
// { transformer: stripClassCallCheck, position: 'after' } // no babel@6 version yet
];

if (process.env.INSTRUMENT_HEIMDALL === 'false') {
Expand All @@ -45,6 +46,7 @@ module.exports = function(environment) {
}

if (environment === 'production') {
postTransformPlugins.push([StripClassCallCheck]);
uniqueAdd(filteredImports, 'ember-data/-private/debug', [
'assert',
'assertPolymorphicType',
Expand All @@ -58,5 +60,5 @@ module.exports = function(environment) {
}
plugins.push([FilterImports, filteredImports]);

return plugins;
return { plugins, postTransformPlugins };
};
3 changes: 1 addition & 2 deletions lib/stripped-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var babelBuild = require('./babel-build');
var strippedBuildPlugins = require('./stripped-build-plugins');

module.exports = function(packageName, tree, environmentBuildingFor) {
var options = {};
options.plugins = strippedBuildPlugins(environmentBuildingFor);
var options = strippedBuildPlugins(environmentBuildingFor);

return babelBuild(packageName, tree, options);
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"amd-name-resolver": "0.0.5",
"babel-plugin-feature-flags": "^0.3.1",
"babel-plugin-filter-imports": "^0.3.1",
"babel5-plugin-strip-class-callcheck": "^5.1.0",
"babel6-plugin-strip-class-callcheck": "^6.0.0",
"babel6-plugin-strip-heimdall": "^6.0.1",
"broccoli-babel-transpiler": "^6.0.0",
"broccoli-file-creator": "^1.0.0",
"broccoli-merge-trees": "^1.0.0",
"chalk": "^1.1.1",
"ember-cli-babel": "^6.0.0-beta.3",
"ember-cli-babel": "^6.0.0-beta.5",
"ember-cli-path-utils": "^1.0.0",
"ember-cli-string-utils": "^1.0.0",
"ember-cli-test-info": "^1.0.0",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,9 @@ babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babel5-plugin-strip-class-callcheck@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/babel5-plugin-strip-class-callcheck/-/babel5-plugin-strip-class-callcheck-5.1.0.tgz#77d4a40c8614d367b8a21a53908159806dba5f91"
babel6-plugin-strip-class-callcheck@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/babel6-plugin-strip-class-callcheck/-/babel6-plugin-strip-class-callcheck-6.0.0.tgz#de841c1abebbd39f78de0affb2c9a52ee228fddf"

babel6-plugin-strip-heimdall@^6.0.1:
version "6.0.1"
Expand Down Expand Up @@ -2160,9 +2160,9 @@ ember-cli-babel@^5.0.0, ember-cli-babel@^5.1.10, ember-cli-babel@^5.1.3, ember-c
ember-cli-version-checker "^1.0.2"
resolve "^1.1.2"

ember-cli-babel@^6.0.0-beta.3:
version "6.0.0-beta.4"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.0.0-beta.4.tgz#28895e8afb60df22e23de6b29d2372da25d8ecc5"
ember-cli-babel@^6.0.0-beta.5:
version "6.0.0-beta.5"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.0.0-beta.5.tgz#7d67c7907592450768afbe5943f7d81fdb4a322f"
dependencies:
amd-name-resolver "0.0.6"
babel-plugin-transform-es2015-modules-amd "^6.24.0"
Expand Down

0 comments on commit 10827a4

Please sign in to comment.