From 4f5c0bb1d0ff09a7cdeb08b93a2c4cdee92a341b Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Mon, 22 Jan 2018 12:35:21 -0800 Subject: [PATCH] fix production instrumented builds --- index.js | 6 +++++- lib/stripped-build-plugins.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index cafe40a0fdc..bb18ce28210 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,10 @@ function isProductionEnv() { return isProd && !isTest; } +function isInstrumentedBuild() { + return INSTRUMENT_HEIMDALL; +} + module.exports = { name: 'ember-data', @@ -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' diff --git a/lib/stripped-build-plugins.js b/lib/stripped-build-plugins.js index 45570f1826d..a0c5194a799 100644 --- a/lib/stripped-build-plugins.js +++ b/lib/stripped-build-plugins.js @@ -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 @@ -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 }] );