Skip to content

Commit 18c751d

Browse files
committed
Fix presets array bug
In `ember-cli` when using `DELAYED_TRANSPILATION` feature, we explicitly set `disablePresetEnv` flag to `true`. `shouldRunPresetEnv` is a negation of `disablePresetEnv`. Prior to this change `options.presets` was an array with one `false` item in it (`shouldRunPresetEnv` was set to `false`) and would let files be transplied when `DELAYED_TRANSPILATION` was enabled. Useful links: + https://github.com/ember-cli/ember-cli/blob/2e0cade64c4698cc48b1fdc20fda2219e63cc973/lib/models/addon.js#L256
1 parent fcc6c89 commit 18c751d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ module.exports = {
223223

224224
options.presets = [
225225
shouldRunPresetEnv && this._getPresetEnvPlugins(addonProvidedConfig),
226-
]
226+
].filter(Boolean);
227227

228228
if (shouldCompileModules) {
229229
options.moduleIds = true;

node-tests/addon-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,24 @@ describe('ember-cli-babel', function() {
791791
expect(result.plugins).to.deep.include(plugin);
792792
});
793793

794+
it('sets `presets` to empty array if `disablePresetEnv` is true', function() {
795+
let options = {
796+
'ember-cli-babel': {
797+
disablePresetEnv: true,
798+
}
799+
};
800+
this.addon.parent = {
801+
options: {
802+
babel6: {
803+
plugins: [ {} ]
804+
},
805+
},
806+
};
807+
808+
let result = this.addon.buildBabelOptions(options);
809+
expect(result.presets).to.deep.equal([]);
810+
});
811+
794812
it('user plugins are before preset-env plugins', function() {
795813
let plugin = function Plugin() {};
796814
this.addon.parent = {

0 commit comments

Comments
 (0)