Skip to content

Commit b3f7a70

Browse files
committed
Fix custom extension compilation without disabling Babel
Fixes #1836.
1 parent a66bc0f commit b3f7a70

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

api.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,14 @@ class Api extends Emittery {
232232
filename => {
233233
throw new Error(`Cannot apply full precompilation, possible bad usage: ${filename}`);
234234
};
235-
const precompileEnhancementsOnly = compileEnhancements && this.options.extensions.enhancementsOnly.length > 0 ?
236-
babelPipeline.build(projectDir, cacheDir, null, compileEnhancements) :
237-
filename => {
238-
throw new Error(`Cannot apply enhancement-only precompilation, possible bad usage: ${filename}`);
239-
};
235+
let precompileEnhancementsOnly = () => null;
236+
if (compileEnhancements) {
237+
precompileEnhancementsOnly = this.options.extensions.enhancementsOnly.length > 0 ?
238+
babelPipeline.build(projectDir, cacheDir, null, compileEnhancements) :
239+
filename => {
240+
throw new Error(`Cannot apply enhancement-only precompilation, possible bad usage: ${filename}`);
241+
};
242+
}
240243

241244
this._precompiler = {
242245
cacheDir,

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
"tap": "^12.0.1",
162162
"temp-write": "^3.4.0",
163163
"touch": "^3.1.0",
164+
"ts-node": "^6.1.1",
164165
"typescript": "^2.8.3",
165166
"xo": "^0.21.1",
166167
"zen-observable": "^0.8.8"

test/fixture/ts-node/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ava": {
3+
"compileEnhancements": false,
4+
"extensions": ["ts"],
5+
"require": ["ts-node/register"]
6+
}
7+
}

test/fixture/ts-node/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import test from '../../../';
2+
3+
test('pass', t => {
4+
t.pass();
5+
});

test/integration/compilation.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ test('workers load compiled helpers if in the require configuration', t => {
6868
t.end();
6969
});
7070
});
71+
72+
test('skips babel compilation for custom extensions, with disabled enhancement compilation', t => {
73+
execCli(['test.ts'], {dirname: 'fixture/ts-node'}, err => {
74+
t.ifError(err);
75+
t.end();
76+
});
77+
});

0 commit comments

Comments
 (0)