S
SolidJS•3mo ago
Joe Pea

how to change solid-start build `target`?

I tried this in app.config:
export default defineConfig({
extensions: ["mdx", "md"],
vite: {
build: { target: "esnext" },
},
})
export default defineConfig({
extensions: ["mdx", "md"],
vite: {
build: { target: "esnext" },
},
})
but when I put a top-level await in a module, then npm run build says this:
ERROR Transform failed with 1 error: 10:24:53 AM
/Users/trusktr/src/showcase/.vinxi/build/ssr/ssr.js:1:17460: ERROR: Top-level await is not available in the configured target environment ("es2019")
ERROR Transform failed with 1 error: 10:24:53 AM
/Users/trusktr/src/showcase/.vinxi/build/ssr/ssr.js:1:17460: ERROR: Top-level await is not available in the configured target environment ("es2019")
The top-level await is working fine in npm run dev, but I get that error only with build. How do we change the target?
No description
3 Replies
Joe Pea
Joe PeaOP•3mo ago
Ah, looks like I had to replace this,
vite: {
build: { target: "esnext" },
}
vite: {
build: { target: "esnext" },
}
with this,
server: { esbuild: { options: { target: "esnext" } } },
server: { esbuild: { options: { target: "esnext" } } },
which is confusing because when looking at intellisense in VS Code, it tells us that vite.build.target is for configuring the esbuild target:
No description
Joe Pea
Joe PeaOP•3mo ago
This is not clear from the solid-start docs, I found this clue by searching Discord conversations, f.e. https://discord.com/channels/722131463138705510/1228007897506644039/1270169209246060577 @docs-team ^ docs feature request, not clear how to change the target, and I think it would be obvious for people to assume that vite.build.target will control it For now I'll leave both vite.build.target and server.esbuild.options.target set to esnext, as I don't know if both are needed or not.
davedbase
davedbase•3mo ago
A PR or issue to capture that would be awesome 🙂
Want results from more Discord servers?
Add your server