You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a tsconfig.json file in the /functions folder causes wrangler pages dev to crash.
Looking at the error output, wrangler is trying to compile tsconfig.json with esbuild which fails and then crashes wrangler.
Environment Information
Node.js v16.10.0
NPM v7.24.0
OS: Ubuntu 20.04.3 (running on Windows 11 via WSL)
Steps to reproduce
Create a new Cloudflare Pages compatible project with TS. E.g. Vite with vue-ts: npm init vite@latest foo -- --template vue-ts
Install npm packages cd foo && npm i
Create a functions directory and add a test function:
/functions/api/test.ts:
// Uses the example code from https://developers.cloudflare.com/pages/platform/functions#writing-your-first-functionexportasyncfunctiononRequest(context){// Contents of context objectconst{
request,// same as existing Worker API
env,// same as existing Worker API
params,// if filename includes [id] or [[path]]
waitUntil,// same as ctx.waitUntil in existing Worker API
next,// used for middleware or to fetch assets
data,// arbitrary space for passing data between middlewares}=context;returnnewResponse("Hello, world!");}
Run with wrangler npx wrangler pages dev -- npm run dev. Works ✅
Run with wrangler npx wrangler pages dev -- npm run dev. Fails ❌
Error output:
Running npm run dev...
Sleeping 5 seconds to allow proxy process to start before attempting to automatically determine port...
To skip, specify the proxy port with --proxy.
[proxy]:
> [email protected] dev
> vite
[proxy]: Pre-bundling dependencies:
vue
[proxy]: (this will be run only when your dependencies or config have changed)
[proxy]:
vite v2.6.14 dev server running at:
[proxy]: > Local: http://localhost:3000/
> Network: use `--host` to expose
ready in 394ms.
Automatically determined the proxy port to be 3000.
/home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1493
let error = new Error(`${text}${summary}`);
^
Error: Transform failed with 1 error:
<stdin>:2:19: error: Expected ";" but found ":"
at failureErrorWithLog (/home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1493:15)
at /home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:1282:29
at /home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:629:9
at handleIncomingPacket (/home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/home/drevan/projects/foo/node_modules/@cloudflare/pages-functions-compiler/node_modules/esbuild/lib/main.js:596:7)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:199:23) {
errors: [
{
detail: undefined,
location: {
column: 19,
file: '<stdin>',
length: 1,
line: 2,
lineText: ' "compilerOptions": {',
namespace: '',
suggestion: ''
},
notes: [],
pluginName: '',
text: 'Expected ";" but found ":"'
}
],
warnings: []
}
/home/drevan/projects/foo/node_modules/wrangler/wrangler-dist/cli.js:27069
throw ex;
^
BuildError [1]: Build failed with exit code 1
at ChildProcess.<anonymous> (file:///home/drevan/projects/foo/node_modules/@miniflare/core/dist/src/index.js:214:25)
at ChildProcess.emit (node:events:390:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
code: 1,
cause: undefined
}
The text was updated successfully, but these errors were encountered:
Having a
tsconfig.json
file in the/functions
folder causeswrangler pages dev
to crash.Looking at the error output, wrangler is trying to compile
tsconfig.json
with esbuild which fails and then crashes wrangler.Environment Information
Steps to reproduce
vue-ts
:npm init vite@latest foo -- --template vue-ts
cd foo && npm i
/functions/api/test.ts
:npx wrangler pages dev -- npm run dev
. Works ✅tsconfig.json
file in/functions
./functions/tsconfig.json
:npx wrangler pages dev -- npm run dev
. Fails ❌Error output:
The text was updated successfully, but these errors were encountered: