From 0320fb3ac22056aafe4d7ae966eab84dbf23fda9 Mon Sep 17 00:00:00 2001 From: Ahn Date: Wed, 14 Apr 2021 10:24:53 +0200 Subject: [PATCH] fix(compiler): return file content on emitSkipped for non ts/tsx files (#2515) Closes #2513 --- .../with-babel-7-string-config/package-lock.json | 6 +++--- e2e/__templates__/with-babel-7/package-lock.json | 6 +++--- src/compiler/language-service.ts | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/e2e/__templates__/with-babel-7-string-config/package-lock.json b/e2e/__templates__/with-babel-7-string-config/package-lock.json index 57a123c2cf..f4b7894255 100644 --- a/e2e/__templates__/with-babel-7-string-config/package-lock.json +++ b/e2e/__templates__/with-babel-7-string-config/package-lock.json @@ -2112,9 +2112,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001150", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz", - "integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==", + "version": "1.0.30001208", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz", + "integrity": "sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA==", "dev": true }, "capture-exit": { diff --git a/e2e/__templates__/with-babel-7/package-lock.json b/e2e/__templates__/with-babel-7/package-lock.json index 478ca9f1a1..56b8b5e63d 100644 --- a/e2e/__templates__/with-babel-7/package-lock.json +++ b/e2e/__templates__/with-babel-7/package-lock.json @@ -2112,9 +2112,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001150", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001150.tgz", - "integrity": "sha512-kiNKvihW0m36UhAFnl7bOAv0i1K1f6wpfVtTF5O5O82XzgtBnb05V0XeV3oZ968vfg2sRNChsHw8ASH2hDfoYQ==", + "version": "1.0.30001208", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz", + "integrity": "sha512-OE5UE4+nBOro8Dyvv0lfx+SRtfVIOM9uhKqFmJeUbGriqhhStgp1A0OyBpgy3OUF8AhYCT+PVwPC1gMl2ZcQMA==", "dev": true }, "capture-exit": { diff --git a/src/compiler/language-service.ts b/src/compiler/language-service.ts index 3f925b3853..23411a4b7b 100644 --- a/src/compiler/language-service.ts +++ b/src/compiler/language-service.ts @@ -260,9 +260,14 @@ export const initializeLanguageServiceInstance = (configs: ConfigSet, logger: Lo } /* istanbul ignore next (this should never happen but is kept for security) */ if (output.emitSkipped) { - logger.warn(interpolate(Errors.CannotProcessFile, { file: fileName })) + const message = interpolate(Errors.CannotProcessFile, { file: fileName }) + if (TS_TSX_REGEX.test(fileName)) { + throw new Error(message) + } else { + logger.warn(message) - return [code, '{}'] + return [code, '{}'] + } } // Throw an error when requiring `.d.ts` files. if (!output.outputFiles.length) {