Skip to content

Commit 1de3657

Browse files
committed
Ensure profile.js skips test file compilation like regular runs
Read the 'compileEnhancements' option from package.json and guard against the Babel config helper not returning any config.
1 parent d42865b commit 1de3657

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

profile.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const conf = pkgConf.sync('ava', {
3939
defaults: {
4040
babel: {
4141
testOptions: {}
42-
}
42+
},
43+
compileEnhancements: true
4344
}
4445
});
4546

@@ -78,16 +79,18 @@ const cacheDir = findCacheDir({
7879
files: [file]
7980
}) || uniqueTempDir();
8081

81-
babelConfigHelper.build(process.cwd(), cacheDir, babelConfigHelper.validate(conf.babel), true)
82+
babelConfigHelper.build(process.cwd(), cacheDir, babelConfigHelper.validate(conf.babel), conf.compileEnhancements === true)
8283
.then(result => {
83-
const precompiler = new CachingPrecompiler({
84-
path: cacheDir,
85-
getBabelOptions: result.getOptions,
86-
babelCacheKeys: result.cacheKeys
87-
});
88-
8984
const precompiled = {};
90-
precompiled[file] = precompiler.precompileFile(file);
85+
if (result) {
86+
const precompiler = new CachingPrecompiler({
87+
path: cacheDir,
88+
getBabelOptions: result.getOptions,
89+
babelCacheKeys: result.cacheKeys
90+
});
91+
92+
precompiled[file] = precompiler.precompileFile(file);
93+
}
9194

9295
const opts = {
9396
file,

0 commit comments

Comments
 (0)