From fd9ebf9e1de4b3bab2d6d4e82bcb0b5f1c628ef8 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 13 Jul 2018 07:01:11 -0700 Subject: [PATCH] Remove option-filtering options from the final options results. (#8315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | Q                       | A | ------------------------ | --- | Fixed Issues? | Fixes https://github.com/babel/babel-loader/issues/642 | Patch: Bug Fix? | Y | Major: Breaking Change? | N | Minor: New Feature? | | Tests Added + Pass? | Yes | Documentation PR Link | | Any Dependency Changes? | | License | MIT Since these were getting left in, things that loaded the config, and then passed in back to Babel would get `test` and such _twice_, which could lead to either bad configuration merging, or no configuration at all if the patterns were relative to different directories, as was the case in https://github.com/babel/babel-loader/issues/642. --- packages/babel-core/src/config/config-chain.js | 4 ++++ packages/babel-core/test/config-chain.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/babel-core/src/config/config-chain.js b/packages/babel-core/src/config/config-chain.js index d117e7c53802..aafebf0c8f60 100644 --- a/packages/babel-core/src/config/config-chain.js +++ b/packages/babel-core/src/config/config-chain.js @@ -500,11 +500,15 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions { }; delete options.extends; delete options.env; + delete options.overrides; delete options.plugins; delete options.presets; delete options.passPerPreset; delete options.ignore; delete options.only; + delete options.test; + delete options.include; + delete options.exclude; // "sourceMap" is just aliased to sourceMap, so copy it over as // we merge the options together. diff --git a/packages/babel-core/test/config-chain.js b/packages/babel-core/test/config-chain.js index dea23e0db236..849da38cfc02 100644 --- a/packages/babel-core/test/config-chain.js +++ b/packages/babel-core/test/config-chain.js @@ -899,6 +899,23 @@ describe("buildConfigChain", function() { expect(opts.comments).toBe(true); }); + + it("should remove the overrides and filtering fields from the options", () => { + const opts = loadOptions({ + cwd: fixture("nonexistant-fake"), + filename: fixture("nonexistant-fake", "src.js"), + babelrc: false, + overrides: [], + test: /^/, + include: /^/, + exclude: [], + }); + + expect(opts.overrides).toBeUndefined(); + expect(opts.test).toBeUndefined(); + expect(opts.include).toBeUndefined(); + expect(opts.exclude).toBeUndefined(); + }); }); describe("config files", () => {