From ebe823780b39867bb8eff4a5b86ff96b22854f42 Mon Sep 17 00:00:00 2001 From: Jessica Franco Date: Tue, 29 Jan 2019 00:17:02 +0900 Subject: [PATCH 1/2] Update babel getter to work with babel-jest@24 babel-jest@24 will also use loadPartialConfig to be able to mix its own options into the config in an API-conforming manner. However, loadPartialConfig will throw an assertion error if the config has not only been loaded, but also had its plugins instantiatied. loadOptions() does the whole thing, including instantiating the plugins, so it can't be used for multiple config loading passes, only the final pass. --- src/config/config-set.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/config-set.ts b/src/config/config-set.ts index 3b53e14be1..c8591f3545 100644 --- a/src/config/config-set.ts +++ b/src/config/config-set.ts @@ -336,16 +336,16 @@ export class ConfigSet { base = { ...base, ...babelConfig.value } } - // loadOptions is from babel 7+, and OptionManager is backward compatible but deprecated 6 API - const { OptionManager, loadOptions, version } = importer.babelCore(ImportReasons.BabelJest) + // loadPartialConfig is from babel 7+, and OptionManager is backward compatible but deprecated 6 API + const { OptionManager, loadPartialConfig, version } = importer.babelCore(ImportReasons.BabelJest) // cwd is only supported from babel >= 7 if (version && semver.satisfies(version, '>=6 <7')) { delete base.cwd } // call babel to load options let config: BabelConfig - if (typeof loadOptions === 'function') { - config = loadOptions(base) as BabelConfig + if (typeof loadPartialConfig === 'function') { + config = loadPartialConfig(base).options as BabelConfig } else { config = new OptionManager().init(base) as BabelConfig } From 3c2b1cfdff5d265379a4d6315241ad8a714a8f23 Mon Sep 17 00:00:00 2001 From: Jessica Franco Date: Tue, 29 Jan 2019 00:23:31 +0900 Subject: [PATCH 2/2] Fix type error --- src/config/config-set.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config/config-set.ts b/src/config/config-set.ts index c8591f3545..553ad582c9 100644 --- a/src/config/config-set.ts +++ b/src/config/config-set.ts @@ -345,7 +345,8 @@ export class ConfigSet { // call babel to load options let config: BabelConfig if (typeof loadPartialConfig === 'function') { - config = loadPartialConfig(base).options as BabelConfig + const partialConfig = loadPartialConfig(base) + config = partialConfig && partialConfig.options as BabelConfig } else { config = new OptionManager().init(base) as BabelConfig }