Skip to content

Commit

Permalink
Merge pull request #450 from HeroicEric/remove-workaround-fixed-upstream
Browse files Browse the repository at this point in the history
Remove workaround for `@babel/helper-compilation-functions` bug that was fixed upstream
  • Loading branch information
Bert De Block committed Jan 28, 2023
2 parents 19404de + f8d64cf commit c83ed26
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
10 changes: 1 addition & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {
} = require("./lib/babel-options-util");

const VersionChecker = require('ember-cli-version-checker');
const clone = require('clone');
const babel = require('@babel/core');
const getBabelOptions = require('./lib/get-babel-options');
const findApp = require('./lib/find-app');
Expand Down Expand Up @@ -312,14 +311,7 @@ module.exports = {

let parser = require('@babel/helper-compilation-targets').default;
if (typeof targets === 'object' && targets !== null) {
// babel version 7.10.0 introduced a change that mutates the input:
// https://github.com/babel/babel/pull/11500
// copy the object to guard against it, otherwise subsequent calls to
// _getTargets() will only have a mutated copy and lose all config from `config/targets.js`
// in the host application.
// PR to fix this upstream in babel: https://github.com/babel/babel/pull/11648
const copy = clone(targets);
return parser(copy);
return parser(targets);
} else {
return targets;
}
Expand Down
11 changes: 0 additions & 11 deletions node-tests/addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const terminateWorkerPool = require('./utils/terminate-workers');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const clone = require('clone');
const {
_shouldHandleTypeScript,
_shouldIncludeHelpers,
Expand Down Expand Up @@ -1877,16 +1876,6 @@ describe('ember-cli-babel', function() {
let pluginRequired = this.addon.isPluginRequired('transform-regenerator');
expect(pluginRequired).to.be.false;
});

it('defensively copies `targets` to prevent @babel/helper-compilation-functions mutating it', function() {
let targets = {
browsers: ['last 2 Chrome versions']
};
this.addon.project.targets = clone(targets);

this.addon.isPluginRequired('transform-regenerator');
expect(this.addon.project.targets).to.deep.equal(targets);
});
});
});

Expand Down

0 comments on commit c83ed26

Please sign in to comment.