Skip to content

Commit

Permalink
fix(extractor): support jsx in js files (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko authored May 29, 2023
1 parent 57aa5ce commit e335458
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/cli/src/api/catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/api/extractors/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// jsx syntax in files without explicit jsx extension
const jsx = <div>Hello!</div>

1 comment on commit e335458

@vercel
Copy link

@vercel vercel bot commented on e335458 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.