Skip to content

Commit

Permalink
Update babel getter to work with babel-jest@24
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jessidhia authored Jan 28, 2019
1 parent 81f3936 commit ebe8237
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ebe8237

Please sign in to comment.