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

preserveSymlinks option not being sent to esbuild, breaking some execution environments (such as when run from/with junction'd folders on Windows) [fix] #16197

Open
7 tasks done
mnmkay opened this issue Mar 18, 2024 · 1 comment

Comments

@mnmkay
Copy link

mnmkay commented Mar 18, 2024

Describe the bug

I've run into this when attempting to run SvelteKit's introductory "SvelteKit demo app" from a folder that is junction'd (symlinked) on Windows. After a failing application (described in Steps to Reproduce below), I took a look around the vite code and was able to get it working. Whether or not the best resolution, this seems most closely related to vitejs/vite, nonetheless.

For my specific situation, these two locations require preserveSyminks to be set to true (as it is currently, the code is hardcoded to fail):

preserveSymlinks: false,

platform: 'node',

Line 1100 goes to the externalize-deps plugin (via tryNodeResolve) and
At line 1063, above it needs to be among the options, which get fed into esbuild (flagsForBuildOptions):

https://github.com/evanw/esbuild/blob/9d1777f23d9b64c186345223d92f319e59388d8b/lib/shared/common.ts#L225

(Incidentally and importantly, for eventual configuration/fix purposes: it seems these code locations are hit before either svelte.config.js or vite.config.ts are ever read)

Seems like this would not affect only Windows, but I don't know:
Some other issues that might be related: (no idea).
#16176
#10802

Reproduction

https://kit.svelte.dev/

Steps to reproduce

#run from a junction'd windows directory (ie example, CWD is folder C:\project that is a junction pointing to D:\real_project):
npm create svelte@latest my-app
cd my-app
npm install
npm run dev -- --open
...

#choose SvelteKit demo app, be navigated to the opened localhost url, then get to a broken application page with the console error:

The request url "D:/real_project/my-app/node_modules/@sveltejs/kit/src/runtime/client/entry.js" is outside of Vite serving allow list.
# to work the PATH needs to start with C:/project, remaining unresolved

System Info

System:
    OS: Windows 10 10.0.19045
    ...
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (122.0.2365.80)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    vite: ^5.0.3 => 5.1.6

Used Package Manager

npm

Logs

No response

Validations

@bmcbarron
Copy link

bmcbarron commented Mar 27, 2024

This started happening to me after a node_modules reinstall this week. It seems like maybe some sveltejs files aren't being whitelisted anymore. My workaround was to update server.fs.allow in vite.config.ts:

  allow = [..., '<path to node_modules>/@sveltejs/kit/src/runtime']

Edit: My build environment is git bash on Windows.

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

No branches or pull requests

2 participants