-
-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Labels
contribution welcomeenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersreleased
Description
When I try to build an internal package in my monorepo using tsup
, I see the following:
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.3.0
CLI Target: node14
CJS Build start
✘ [ERROR] Top-level await is not available in the configured target environment ("node14")
src/index.ts:11:4:
11 │ await import("dotenv").then((dotenv)=>dotenv.config({
╵ ~~~~~
CJS Build failed
Error: Build failed with 1 error:
src/index.ts:11:4: ERROR: Top-level await is not available in the configured target environment ("node14")
at failureErrorWithLog (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:1566:15)
at /Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:1024:28
at runOnEndCallbacks (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:1438:61)
at buildResponseToResult (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:1022:7)
at /Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:1134:14
at responseCallbacks.<computed> (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:671:9)
at handleIncomingPacket (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/Users/jacob/code/selfbuilder/node_modules/esbuild/lib/main.js:647:7)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
This does not make sense to me, since the target specified in tsconfig.json is esnext
:
...
"compilerOptions": {
"module": "esnext",
"target": "esnext",
},
Additionally, package.json specifies "type": "module"
.
Why does tsup ignore the target in tsconfig.json and use node14 instead?
NOTE: It works (bundles successfully using esm) if I configure tsup directly, by adding the following to package.json:
"tsup": {
"target": "esnext",
"format": ["esm"]
},
chachako
Metadata
Metadata
Assignees
Labels
contribution welcomeenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersreleased