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

error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11") #859

Closed
frederikhors opened this issue Apr 3, 2021 · 7 comments

Comments

@frederikhors
Copy link
Contributor

Describe the bug

During build it throws with:

error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11")

To Reproduce

A new svelte@next init app and a minimal Getting started code from https://github.com/timostamm/protobuf-ts.

(I know, but I don't have time right now for a new repo)

Expected behavior

I can build.

Can I change the target it detects? Can I remove that "es2019" for example?

Stacktraces

Stack trace
> Transform failed with 2 errors:
pages\players\index.svelte-e4c16403.js:4121:23: error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11")
pages\players\index.svelte-e4c16403.js:4160:23: error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11")
Error: Transform failed with 2 errors:
pages\players\index.svelte-e4c16403.js:4121:23: error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11")
pages\players\index.svelte-e4c16403.js:4160:23: error: Big integer literals are not available in the configured target environment ("chrome61", "edge18", "es2019", "firefox60", "safari11")
    at failureErrorWithLog (C:\kit\node_modules\esbuild\lib\main.js:1224:15)
    at C:\kit\node_modules\esbuild\lib\main.js:1072:33
    at C:\kit\node_modules\esbuild\lib\main.js:568:9
    at handleIncomingPacket (C:\kit\node_modules\esbuild\lib\main.js:657:9)
    at Socket.readFromStdout (C:\kit\node_modules\esbuild\lib\main.js:535:7)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Information about your SvelteKit Installation:

Diagnostics

System:
OS: Windows 10 10.0.19042
Binaries:
Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
npm: 7.8.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@sveltejs/kit: 1.0.0-next.70 => 1.0.0-next.70
svelte: 3.37.0 => 3.37.0
vite: 2.1.5 => 2.1.5

  • Your adapter: static
@dummdidumm
Copy link
Member

dummdidumm commented Apr 3, 2021

This is unrelated to Svelte. BigInt is a new syntax feature only available in modern browsers, and it cannot be transpiled. You could set your target to es2020 if you only target modern browsers. You very likely also need to adjust the corresponding vite config https://vitejs.dev/config/#build-options
Some pointers:
Explanation on why it isn't easy to transpiled or poly fill: evanw/esbuild#732
Related Stack Overflow questions: https://stackoverflow.com/questions/57560501/bigint-literals-are-not-available-when-targeting-lower-than-esnext , https://stackoverflow.com/questions/59456390/using-bigint-in-typescript

@bgins
Copy link

bgins commented Aug 6, 2021

Hello 👋. I've run into this issue and the recommended solution doesn't appear to be an option.

When I add

vite: () => ({
    build: {
        target: [ 'es2020' ]
    }
})

to kit in svelte.conifg.js and run npm run build (i.e. svelte-kit build), I get the message:

build_server: The value for kit.vite.build.target specified in svelte.config.js has been ignored. This option is controlled by SvelteKit.

Reading around a bit in the Discord channel and in other issues, it sounds like SveleKit targets es2019 with es2020 lib support. Is there a configuration that will allow for the use of Big integer literals?

I am testing this with the template app recommended on the SvelteKit homepage with TypeScript enabled. I've set the tsconfig.json target to es2020 in case there was some interaction there that might be problematic.

My use case would work fine with adapter-static if there is some way that the adapter might help here.


Please let me know if I can fill in any additional details or if I should open a new issue on this. Thanks! 🙏

@kotx
Copy link

kotx commented Aug 23, 2021

When I add

vite: () => ({
    build: {
        target: [ 'es2020' ]
    }
})

to kit in svelte.conifg.js and run npm run build (i.e. svelte-kit build), I get the message:

build_server: The value for kit.vite.build.target specified in svelte.config.js has been ignored. This option is controlled by SvelteKit.

Seems like with this code, despite the error, it still works. Would still like a method without the error though.

@gunggmee
Copy link
Contributor

gunggmee commented Oct 12, 2021

@dummdidumm, it seems like sveltekit doesn't allow users (I mean, developers who use the framework) to change vite.build.target option. As I see it, the following code is related to the problem @bgins and @kotx reported earlier:

const [merged_config, conflicts] = deep_merge(modified_vite_config, {
configFile: false,
root: cwd,
base: assets_base,
build: {
target: 'es2018',
ssr: true,
outDir: `${output_dir}/server`,
polyfillDynamicImport: false,
rollupOptions: {
input: {
app: app_file
},
output: {
format: 'esm',
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
inlineDynamicImports: true
},
preserveEntrySignatures: 'strict'
}
},
plugins: [
svelte({
extensions: config.extensions,
compilerOptions: {
hydratable: !!config.kit.hydrate
}
})
],
resolve: {
alias: {
$app: path.resolve(`${build_dir}/runtime/app`),
$lib: config.kit.files.lib
}
}
});
print_config_conflicts(conflicts, 'kit.vite.', 'build_server');

Edited: Just found an open issue directly related to this problem: #2565

@idosius
Copy link

idosius commented Jul 5, 2022

This issue still reproduces when running SvelteKit's dev server. I haven't been able to find any fix or workaround.

@bluwy
Copy link
Member

bluwy commented Jul 14, 2022

You can set optimizeDeps.esbuildOptions.target: 'es2020' and build.target: 'es2020' in the vite config to fix the issue (i believe)

@wesAlves
Copy link

wesAlves commented Jul 26, 2022

You can set optimizeDeps.esbuildOptions.target: 'es2020' and build.target: 'es2020' in the vite config to fix the issue (i believe)

Worked for me!!!
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants