Skip to content

Commit

Permalink
feature: transpile tsx and jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
stagas committed Feb 4, 2022
1 parent fe6ce0e commit 337d439
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const createServer = async (setup: ServerSetup) => {
let filename = path.resolve(path.join(setup.root, url))
let contents: string

if (filename.endsWith('.ts')) {
if (filename.endsWith('.ts') || filename.endsWith('.tsx') || filename.endsWith('.jsx')) {
const result = buildSync({
entryPoints: [filename],
format: 'esm',
Expand All @@ -54,7 +54,7 @@ export const createServer = async (setup: ServerSetup) => {
const [file] = result.outputFiles || []
if (!file) throw new TypeError('Build failed, no output files')
contents = Buffer.from(file.contents).toString('utf8')
filename = filename.replace('.ts', '.js')
filename = filename.replace('.ts', '.js').replace('.tsx', '.js').replace('.jsx', '.js')
} else {
contents = await fs.readFile(filename, 'utf8')
}
Expand Down

0 comments on commit 337d439

Please sign in to comment.