diff --git a/api.js b/api.js index 6cb688777..ea0060ee5 100644 --- a/api.js +++ b/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, diff --git a/package-lock.json b/package-lock.json index f27306ead..a625e1607 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5267,6 +5267,12 @@ } } }, + "make-error": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", + "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==", + "dev": true + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -10269,6 +10275,29 @@ "integrity": "sha1-N21NKdlR1jaKb3oK6FwvTV4GWPM=", "dev": true }, + "ts-node": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.1.1.tgz", + "integrity": "sha512-79FnymLGDBd/nXoiak1L6w6fd9Zz9Ge/x8/Aglaeh31KkqRLDzbfT1vBGlO5dqc76WzufTlW4IYl7e01CVUF5A==", + "dev": true, + "requires": { + "arrify": "^1.0.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, "tsame": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/tsame/-/tsame-2.0.0.tgz", @@ -10922,6 +10951,12 @@ "camelcase": "^4.1.0" } }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", + "dev": true + }, "zen-observable": { "version": "0.8.8", "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.8.tgz", diff --git a/package.json b/package.json index 98136dfde..b86663940 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/fixture/ts-node/package.json b/test/fixture/ts-node/package.json new file mode 100644 index 000000000..ae2b2e819 --- /dev/null +++ b/test/fixture/ts-node/package.json @@ -0,0 +1,7 @@ +{ + "ava": { + "compileEnhancements": false, + "extensions": ["ts"], + "require": ["ts-node/register"] + } +} diff --git a/test/fixture/ts-node/test.ts b/test/fixture/ts-node/test.ts new file mode 100644 index 000000000..3d087bb5f --- /dev/null +++ b/test/fixture/ts-node/test.ts @@ -0,0 +1,5 @@ +import test from '../../../'; + +test('pass', t => { + t.pass(); +}); diff --git a/test/integration/compilation.js b/test/integration/compilation.js index aa7319fb1..f385bea96 100644 --- a/test/integration/compilation.js +++ b/test/integration/compilation.js @@ -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(); + }); +});