Skip to content

Commit

Permalink
Fix presets array bug
Browse files Browse the repository at this point in the history
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
  • Loading branch information
twokul committed May 26, 2018
1 parent fcc6c89 commit 18c751d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ module.exports = {

options.presets = [
shouldRunPresetEnv && this._getPresetEnvPlugins(addonProvidedConfig),
]
].filter(Boolean);

if (shouldCompileModules) {
options.moduleIds = true;
Expand Down
18 changes: 18 additions & 0 deletions node-tests/addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,24 @@ describe('ember-cli-babel', function() {
expect(result.plugins).to.deep.include(plugin);
});

it('sets `presets` to empty array if `disablePresetEnv` is true', function() {

This comment has been minimized.

Copy link
@stefanpenner

stefanpenner May 30, 2018

Member

thanks for the test!

let options = {
'ember-cli-babel': {
disablePresetEnv: true,
}
};
this.addon.parent = {
options: {
babel6: {
plugins: [ {} ]
},
},
};

let result = this.addon.buildBabelOptions(options);
expect(result.presets).to.deep.equal([]);
});

it('user plugins are before preset-env plugins', function() {
let plugin = function Plugin() {};
this.addon.parent = {
Expand Down

0 comments on commit 18c751d

Please sign in to comment.