-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4048 from pangratz/fix-ember-addon-production
Strip stuff from addon before it is added to app
- Loading branch information
Showing
5 changed files
with
130 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var babel = require('broccoli-babel-transpiler'); | ||
var path = require('path'); | ||
|
||
function babelOptions(libraryName, _options) { | ||
_options = _options || {}; | ||
|
||
var options = { | ||
whitelist: [ | ||
'es6.templateLiterals', | ||
'es6.parameters', | ||
'es6.arrowFunctions', | ||
'es6.destructuring', | ||
'es6.spread', | ||
'es6.properties.computed', | ||
'es6.properties.shorthand', | ||
'es6.blockScoping', | ||
'es6.constants', | ||
'es6.modules' | ||
], | ||
sourceMaps: false, | ||
modules: 'amdStrict', | ||
moduleRoot: libraryName, | ||
moduleId: true, | ||
// Transforms /index.js files to use their containing directory name | ||
getModuleId: function (name) { | ||
return name.replace(/\/index$/g, ''); | ||
}, | ||
resolveModuleSource: function(name, filename) { | ||
if (name.indexOf('.') === 0) { | ||
return libraryName + '/' + path.join(path.dirname(filename), name); | ||
} else { | ||
return name; | ||
} | ||
} | ||
}; | ||
|
||
Object.keys(_options).forEach(function(opt) { | ||
options[opt] = _options[opt]; | ||
}); | ||
|
||
return options; | ||
} | ||
|
||
module.exports = function(packageName, tree, _options) { | ||
var options = babelOptions(packageName, _options); | ||
|
||
return babel(tree, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var filterImports = require('babel-plugin-filter-imports'); | ||
var featureFlags = require('babel-plugin-feature-flags'); | ||
var babelBuild = require('./babel-build'); | ||
|
||
module.exports = function(packageName, tree, _options) { | ||
var featuresJsonPath = path.join(__dirname, '../config/features.json'); | ||
var featuresJson = fs.readFileSync(featuresJsonPath, { encoding: 'utf8' }); | ||
var features = JSON.parse(featuresJson); | ||
|
||
// TODO explicitly set all features which are not enabled to `false`, so | ||
// they are stripped --> make this configurable or pass features | ||
// | ||
// for (var feature in features) { | ||
// if (features[feature] !== true) { | ||
// features[feature] = false; | ||
// } | ||
// } | ||
|
||
var plugins = [ | ||
featureFlags({ | ||
import: { module: 'ember-data/-private/features' }, | ||
features: features | ||
}), | ||
|
||
filterImports({ | ||
'ember-data/-private/debug': [ | ||
'assert', | ||
'debug', | ||
'deprecate', | ||
'info', | ||
'runInDebug', | ||
'warn', | ||
'debugSeal' | ||
] | ||
}) | ||
]; | ||
|
||
var options = _options || {}; | ||
options.plugins = plugins; | ||
|
||
return babelBuild(packageName, tree, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters