Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot specify build target #2565

Closed
m4rch3n1ng opened this issue Oct 6, 2021 · 5 comments · Fixed by #2618
Closed

cannot specify build target #2565

m4rch3n1ng opened this issue Oct 6, 2021 · 5 comments · Fixed by #2618
Labels
feature request New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.

Comments

@m4rch3n1ng
Copy link

m4rch3n1ng commented Oct 6, 2021

Describe the bug

while running svelte-kit build i cannot set the build target, it says
"build_server: The value for kit.vite.build.target specified in svelte.config.js has been ignored. This option is controlled by SvelteKit."
and when i then try to build a project where i use BigInt it says
"> Transform failed with 1 error: app.js:2052:9: error: Big integer literals are not available in the configured target environment ("es2018")"

Reproduction

  1. create an empty ("skeleton") sveltekit project (with the node-adapter)
  2. create an index.js file in src/routes and fill it with
export function get () {
	let n = 10n

	return {
		status: 200,
		body: n.toString()
	}
}
  1. overwrite your svelte.config.js to
import node from "@sveltejs/adapter-node"

export default {
	kit: {
		adapter: node(),
		vite: {
			build: {
				target: "esnext"
			}
		}
	}
}

Logs

$ npm run build

> [email protected] build
> svelte-kit build --verbose

vite v2.6.3 building for production...
✓ 13 modules transformed.
.svelte-kit/output/client/_app/manifest.json               0.96 KiB
.svelte-kit/output/client/_app/layout.svelte-65943d9d.js   0.53 KiB / gzip: 0.35 KiB 
.svelte-kit/output/client/_app/error.svelte-1cfc6a4a.js    1.56 KiB / gzip: 0.74 KiB 
.svelte-kit/output/client/_app/assets/start-61d1577b.css   0.16 KiB / gzip: 0.15 KiB 
.svelte-kit/output/client/_app/start-6f07df61.js           15.17 KiB / gzip: 5.91 KiB
.svelte-kit/output/client/_app/chunks/vendor-af0f2ef7.js   7.08 KiB / gzip: 2.89 KiB 
  build_server: The value for kit.vite.build.target specified in svelte.config.js has been ignored. This option is controlled by SvelteKit.
vite v2.6.3 building SSR bundle for production...
✓ 14 modules transformed.
[vite:esbuild-transpile] Transform failed with 1 error:
app.js:2052:9: error: Big integer literals are not available in the configured target environment ("es2018")

Big integer literals are not available in the configured target environment ("es2018")
2050|  
2051|  function get () {
2052|   let n = 10n;
   |           ^
2053|  
2054|   return {

> Transform failed with 1 error:
app.js:2052:9: error: Big integer literals are not available in the configured target environment ("es2018")
Error: Transform failed with 1 error:
app.js:2052:9: error: Big integer literals are not available in the configured target environment ("es2018")
    at failureErrorWithLog (C:\Users\User\OneDrive\Programming\small_projects\javascript\testing\sveltekit\nft\test\node_modules\esbuild\lib\main.js:1493:15)
    at C:\Users\User\OneDrive\Programming\small_projects\javascript\testing\sveltekit\nft\test\node_modules\esbuild\lib\main.js:1282:29
    at C:\Users\User\OneDrive\Programming\small_projects\javascript\testing\sveltekit\nft\test\node_modules\esbuild\lib\main.js:629:9
    at handleIncomingPacket (C:\Users\User\OneDrive\Programming\small_projects\javascript\testing\sveltekit\nft\test\node_modules\esbuild\lib\main.js:726:9) 
    at Socket.readFromStdout (C:\Users\User\OneDrive\Programming\small_projects\javascript\testing\sveltekit\nft\test\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)

System Info

  System:
    OS: Windows 10 10.0.19043
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 8.02 GB / 15.93 GB
  Binaries:
    Node: 16.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.24.1 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.38)
  npmPackages:
    @sveltejs/adapter-node: next => 1.0.0-next.53
    @sveltejs/kit: next => 1.0.0-next.180
    svelte: ^3.43.0 => 3.43.1

Severity

serious, but I can work around it

Additional Information

no additional information

@bluwy bluwy added feature request New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. labels Oct 7, 2021
@bluwy
Copy link
Member

bluwy commented Oct 7, 2021

Currently, SvelteKit fixes that to es2018:

target: 'es2018',

I'm not sure the reason for that as it was written 7 months ago, but I think it may be safe to remove it since adapters have another step to further bundle it with another target. It probably won't be a breaking change as the default target value by Vite is lower than es2018.

@gunggmee
Copy link
Contributor

This PR by @GrygrFlzr is the one introduced target: 'es2018' and there're explanation for the reason behind it: #486 (comment)

As I see it, es2018+ is there to support async/await syntax. Does it mean that we can simply change the value to es2020? Or at least can we allow users to override the target with any value satisfying es2018+?

@gunggmee
Copy link
Contributor

Just found that one of yesterday's PRs (#2604) partially solved the issue. Now the target is es2020 so it is okay to use big integer literals, but it still shows a warning if svelte.config.js tries to override the target.

@bluwy
Copy link
Member

bluwy commented Oct 16, 2021

Thanks for digging into this @gunggmee. I think we should allow build.target to be changed, and have es2020 as the default. I don't think it would be easy to validate the value to be higher than es2020 though, esbuild's target option is magnificently flexible, e.g. chrome80, firefox90. If one sets a lower value, then Vite should (hopefully) provide a nice message for what to do. Feel free to send a PR to apply my first sentence :)

@gunggmee
Copy link
Contributor

@bluwy Thanks for helpful comment. Just made a draft PR. Could you please take a look at it, and let me know if this is a good way to go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants