-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugcurrent functionality does not work as desiredcurrent functionality does not work as desiredhelp wantedscope:internals
Milestone
Description
From #1822 (comment):
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register",
"tsconfig-paths/register"
]
},Because of how ts is specified, AVA won't apply its Babel pipeline to it. However, note that the babel option is not disabled.
The logic in these lines is broken:
const {projectDir, babelConfig} = this.options;
const compileEnhancements = this.options.compileEnhancements !== false;
const precompileFull = babelConfig ?
babelPipeline.build(projectDir, cacheDir, babelConfig, compileEnhancements) :
filename => {
throw new Error(`Cannot apply full precompilation, possible bad usage: ${filename}`);
};
const precompileEnhancementsOnly = compileEnhancements && this.options.extensions.enhancementsOnly.length > 0 ?
babelPipeline.build(projectDir, cacheDir, null, compileEnhancements) :
filename => {
throw new Error(`Cannot apply enhancement-only precompilation, possible bad usage: ${filename}`);
};
this._precompiler = {
cacheDir,
enabled: babelConfig || compileEnhancements,
precompileEnhancementsOnly,
precompileFull
};Note how this._precompiler.enabled ends up being true. However precompileEnhancementsOnly is set to a function that always throws. Consequently, when compiling TypeScript files, precompileEnhancementsOnly is called and AVA crashes.
I think the logic should be such that a () => null function is when compileEnhancements is false, and the error-throwing function is used when it's not and this.options.extensions.enhancementsOnly.length is 0.
Metadata
Metadata
Assignees
Labels
bugcurrent functionality does not work as desiredcurrent functionality does not work as desiredhelp wantedscope:internals