Skip to content

Commit c074d3d

Browse files
authored
Use the jsx loader for .js files (#128)
1 parent 913f15b commit c074d3d

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

.changeset/silent-mugs-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'pleasantest': patch
3+
---
4+
5+
Enable JSX parsing/transpilation for .js, .mjs, .cjs files (not just .jsx)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module-server/plugins/esbuild-plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const esbuildPlugin = (): Plugin => {
1212
name: 'esbuild',
1313
async transform(code, id) {
1414
if (!shouldProcess(id)) return null;
15-
const loader = extname(id).slice(1) as esbuild.Loader;
15+
const ext = extname(id).slice(1);
16+
const loader = /[cm]?jsx?$/.test(ext) ? 'jsx' : (ext as esbuild.Loader);
1617
return esbuild
1718
.transform(code, {
1819
sourcefile: id,

0 commit comments

Comments
 (0)