Skip to content

Commit c4d7f02

Browse files
committed
fix: compile js and ts separately
1 parent 9d916fa commit c4d7f02

File tree

1 file changed

+9
-13
lines changed
  • packages/runtime/src/helpers

1 file changed

+9
-13
lines changed

packages/runtime/src/helpers/dev.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@ export const onPreDev: OnPreBuild = async ({ constants, netlifyConfig }) => {
2727
console.log('Watching for changes in Next.js middleware...')
2828
}
2929
// Eventually we might want to do this via esbuild's API, but for now the CLI works fine
30-
const childProcess = execa(`esbuild`, [
31-
`--bundle`,
32-
`--outdir=${resolve('.netlify')}`,
33-
`--format=esm`,
34-
`--target=esnext`,
35-
'--watch',
36-
// Watch for both, because it can have either ts or js
37-
resolve(base, 'middleware.ts'),
38-
resolve(base, 'middleware.js'),
39-
])
40-
41-
childProcess.stdout.pipe(process.stdout)
42-
childProcess.stderr.pipe(process.stderr)
30+
31+
const common = [`--bundle`, `--outdir=${resolve('.netlify')}`, `--format=esm`, `--target=esnext`, '--watch']
32+
33+
// TypeScript
34+
execa(`esbuild`, [...common, resolve(base, 'middleware.ts')], { all: true }).all.pipe(process.stdout)
35+
36+
// JavaScript
37+
execa(`esbuild`, [...common, resolve(base, 'middleware.js')], { all: true }).all.pipe(process.stdout)
38+
4339
// Don't return the promise because we don't want to wait for the child process to finish
4440
}

0 commit comments

Comments
 (0)