From b34b337ff6a393ff3a787768848be0abd5e781ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 11 Oct 2021 21:27:13 +0200 Subject: [PATCH] Handle `.mts` and `.cts` files in `@babel/preset-typescript` --- packages/babel-preset-typescript/src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/babel-preset-typescript/src/index.js b/packages/babel-preset-typescript/src/index.js index e384e41c2424..f91f4a6a4f25 100644 --- a/packages/babel-preset-typescript/src/index.js +++ b/packages/babel-preset-typescript/src/index.js @@ -41,16 +41,16 @@ export default declare((api, opts) => { plugins: [[transformTypeScript, pluginOptions(isTSX)]], }, ] - : [ + : // Only set 'test' if explicitly requested, since it requires that + // Babel is being called` + [ { - // Only set 'test' if explicitly requested, since it requires that - // Babel is being called` - test: /\.ts$/, + test: /\.[mc]?ts$/, plugins: [[transformTypeScript, pluginOptions(false)]], }, + { test: /\.mts$/, sourceType: "module" }, + { test: /\.cts$/, sourceType: "script" }, { - // Only set 'test' if explicitly requested, since it requires that - // Babel is being called` test: /\.tsx$/, plugins: [[transformTypeScript, pluginOptions(true)]], },