From e335458c2c321a500c5b3ff8e82c338b0d507795 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Mon, 29 May 2023 15:20:09 +0200 Subject: [PATCH] fix(extractor): support jsx in js files (#1678) --- packages/cli/src/api/catalog.test.ts | 1 + packages/cli/src/api/extractors/babel.ts | 2 +- .../cli/src/api/fixtures/collect-typescript-jsx/jsx-in-js.js | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 packages/cli/src/api/fixtures/collect-typescript-jsx/jsx-in-js.js diff --git a/packages/cli/src/api/catalog.test.ts b/packages/cli/src/api/catalog.test.ts index d5c661831..193cba8b8 100644 --- a/packages/cli/src/api/catalog.test.ts +++ b/packages/cli/src/api/catalog.test.ts @@ -180,6 +180,7 @@ describe("Catalog", () => { it("should support JSX and Typescript", async () => { const messages = await extractFromFiles( [ + fixture("collect-typescript-jsx/jsx-in-js.js"), fixture("collect-typescript-jsx/jsx-syntax.jsx"), fixture("collect-typescript-jsx/tsx-syntax.tsx"), fixture("collect-typescript-jsx/macro.tsx"), diff --git a/packages/cli/src/api/extractors/babel.ts b/packages/cli/src/api/extractors/babel.ts index 09c9bb284..4fb1ac09a 100644 --- a/packages/cli/src/api/extractors/babel.ts +++ b/packages/cli/src/api/extractors/babel.ts @@ -49,7 +49,7 @@ const extractor: ExtractorType = { } } - if ([/\.jsx$/, /\.tsx$/].some((r) => filename.match(r))) { + if ([/\.js$/, /\.jsx$/, /\.tsx$/].some((r) => filename.match(r))) { parserPlugins.push("jsx") } diff --git a/packages/cli/src/api/fixtures/collect-typescript-jsx/jsx-in-js.js b/packages/cli/src/api/fixtures/collect-typescript-jsx/jsx-in-js.js new file mode 100644 index 000000000..bf7d9b718 --- /dev/null +++ b/packages/cli/src/api/fixtures/collect-typescript-jsx/jsx-in-js.js @@ -0,0 +1,2 @@ +// jsx syntax in files without explicit jsx extension +const jsx =
Hello!