Permalink
Browse files

Fix custom extension compilation without disabling Babel

Fixes #1836.
  • Loading branch information...
novemberborn committed Jun 12, 2018
1 parent a66bc0f commit b3f7a7071c0cb4d6b68ba73e5d06dc6c515614a5
Showing with 63 additions and 5 deletions.
  1. +8 −5 api.js
  2. +35 −0 package-lock.json
  3. +1 −0 package.json
  4. +7 −0 test/fixture/ts-node/package.json
  5. +5 −0 test/fixture/ts-node/test.ts
  6. +7 −0 test/integration/compilation.js
View
13 api.js
@@ -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,
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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"
@@ -0,0 +1,7 @@
{
"ava": {
"compileEnhancements": false,
"extensions": ["ts"],
"require": ["ts-node/register"]
}
}
@@ -0,0 +1,5 @@
import test from '../../../';
test('pass', t => {
t.pass();
});
@@ -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 b3f7a70

Please sign in to comment.