Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update babel getter to work with babel-jest@24 #960

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,17 @@ 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') {
const partialConfig = loadPartialConfig(base)
config = partialConfig && partialConfig.options as BabelConfig

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeof partialConfig is Readonly<PartialConfig> | null so that cannot insert to config, error message report.

} else {
config = new OptionManager().init(base) as BabelConfig
}
Expand Down