Skip to content

Commit

Permalink
Fix custom extension compilation without disabling Babel
Browse files Browse the repository at this point in the history
Fixes #1836.
  • Loading branch information
novemberborn committed Jun 12, 2018
1 parent 52bc64b commit 6fcda0f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ class Api extends Emittery {
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}`);
};
let precompileEnhancementsOnly = () => null;
if (compileEnhancements) {
precompileEnhancementsOnly = 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,
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"tap": "^12.0.1",
"temp-write": "^3.4.0",
"touch": "^3.1.0",
"ts-node": "^6.1.1",
"typescript": "^2.8.3",
"xo": "^0.21.1",
"zen-observable": "^0.8.8"
Expand Down
7 changes: 7 additions & 0 deletions test/fixture/ts-node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ava": {
"compileEnhancements": false,
"extensions": ["ts"],
"require": ["ts-node/register"]
}
}
5 changes: 5 additions & 0 deletions test/fixture/ts-node/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test from '../../../';

test('pass', t => {
t.pass();
});
7 changes: 7 additions & 0 deletions test/integration/compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ test('workers load compiled helpers if in the require configuration', t => {
t.end();
});
});

test('skips babel compilation for custom extensions, with disabled enhancement compilation', t => {
execCli(['test.ts'], {dirname: 'fixture/ts-node'}, err => {
t.ifError(err);
t.end();
});
});

0 comments on commit 6fcda0f

Please sign in to comment.