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

SvelteKit compiles some nonsense empty object #1513

Closed
mukaschultze opened this issue May 21, 2021 · 1 comment
Closed

SvelteKit compiles some nonsense empty object #1513

mukaschultze opened this issue May 21, 2021 · 1 comment

Comments

@mukaschultze
Copy link

Describe the bug
SvelteKit compiles some nonsense empty object when using process.env.SOME_KEY, and works fine when using process.env["SOME_KEY"].

Logs
No relevant logs, the build process works just fine.

To Reproduce

  • npm init svelte@next empty-obj
  • cd empty-obj
  • Add the following code anywhere on src\routes\todos\_api.js:
console.log(process.env.PATH); // This works
console.log(process.env["PATH"]); // This doesn't
  • npm run build
  • Open the compiled .svelte-kit\output\server\app.js file
  • Search for "PATH" and check the output code, the code looks like something like this:
console.log({}.PATH);
console.log(process.env["PATH"]);

You can see in the output that there is an {}.PATH, this is incorrect and very hard to debug.

Expected behavior
Both process.env.PATH and process.env["PATH"] should work just fine and have the correct output.

Information about your SvelteKit Installation:

Diagnostics System: OS: Windows 10 10.0.19042 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 17.00 GB / 31.80 GB Binaries: Node: 16.2.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 7.11.2 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 90.0.4430.212 Edge: Spartan (44.19041.964.0), Chromium (90.0.818.62) npmPackages: @sveltejs/kit: next => 1.0.0-next.109 svelte: ^3.34.0 => 3.38.2

Severity
How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of SvelteKit entirely?

It's just annoying and extremely hard to debug.

Note: the more honest and specific you are here the more we will take you seriously.

Additional context

  • Also happens on node 15
  • Happens on npm run dev as well
  • I couldn't reproduce it with other objects, only with process.env.SOMETHING
@GrygrFlzr
Copy link
Member

This is out of SvelteKit's control. Tracked in vitejs/vite#3176 instead.

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

2 participants