Skip to content

Commit

Permalink
fix production instrumented builds
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jan 22, 2018
1 parent 6894000 commit c7d8454
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function isProductionEnv() {
return isProd && !isTest;
}

function isInstrumentedBuild() {
return INSTRUMENT_HEIMDALL;
}

module.exports = {
name: 'ember-data',

Expand Down Expand Up @@ -137,7 +141,7 @@ module.exports = {
let withoutPrivate = new Funnel(treeWithVersion, {
exclude: [
'-private',
isProductionEnv() ? '-debug' : false
isProductionEnv() && !isInstrumentedBuild() ? '-debug' : false
].filter(Boolean),

destDir: 'ember-data'
Expand Down
11 changes: 8 additions & 3 deletions lib/stripped-build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = function(environment) {
var featuresJsonPath = __dirname + '/../config/features.json';
var featuresJson = fs.readFileSync(featuresJsonPath, { encoding: 'utf8' });
var features = JSON.parse(featuresJson);
var strippedImports = {};
var filteredImports = {};

// TODO explicitly set all features which are not enabled to `false`, so
Expand All @@ -54,21 +55,25 @@ module.exports = function(environment) {

if (process.env.INSTRUMENT_HEIMDALL === 'false') {
plugins.push([StripHeimdall]);
uniqueAdd(filteredImports, 'ember-data/-debug', ['instrument']);
uniqueAdd(strippedImports, 'ember-data/-debug', ['instrument']);
} else {
console.warn('NOT STRIPPING HEIMDALL');
}

if (/production/.test(environment) || process.env.INSTRUMENT_HEIMDALL === 'true') {
postTransformPlugins.push([StripClassCallCheck]);
uniqueAdd(filteredImports, 'ember-data/-debug', [
uniqueAdd(strippedImports, 'ember-data/-debug', [
'assertPolymorphicType'
]);
}

Object.keys(strippedImports).forEach((k) => {
filteredImports[k] = true;
});

plugins.push(
[FilterImports, filteredImports],
[StripFilteredImports, filteredImports],
[StripFilteredImports, strippedImports],
[TransformBlockScoping, { 'throwIfClosureRequired': true }]
);

Expand Down

0 comments on commit c7d8454

Please sign in to comment.