-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Vanilla JS instanceof check fails if using pnpm as packagemanager and preserveSymlinks set to true in vite.config.ts #17631
Comments
I think this is working as intended. The doc from esbuild explains it better https://esbuild.github.io/api/#preserve-symlinks
|
Maybe the vanilla example which I try to recreate is not specific enough. There is a server component which implements the redirect() function which is imported in following way:
in this function a class Redirect is thrown
The Redirect is imported with following import: which points to file => "my-app/node_modules/.pnpm/@sveltejs+kit@2.5.18_@sveltejs[email protected][email protected][email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/control" The instance check which fails is located in following file:
This Redirect is imported in following way: which points to following file => my-app/node_modules/.pnpm/@sveltejs+kit@2.5.18_@sveltejs[email protected][email protected][email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/control.js So the fucntion which throws the Redirect and the function which deals with the instanceof check uses the same import and the same file in my opinion. my-app/node_modules/.pnpm/@sveltejs+kit@2.5.18_@sveltejs[email protected][email protected][email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/runtime/control.js So I would guess if the import has the same filePath there must not be a dublication of the Redirect Instances. Folder Structure node_modules |
Thanks for cleaning up the repro and explanation. This appears to me that it's still expected behavior and Sveletekit is not able to support From what I can see by running
here On the other hand, somewhere in a different line, you would also see the one from
So, it's likely that Sveltekit somehow eneded up resolving/importing from "realpath" internally, so that'll be a distinct Having Sveltekit side issue seems appropriate to me, so let me close this issue. |
Describe the bug
Before I created this issue here, I had experienced an issue with a svelte kit application which uses vite under the hood.
This issue can be found here Original Svelte Kit Issue or the reduced one Part II.
First I thought the issue related to the svelte kit framework but in the meantime I'm no longer convinced.
I created a small repo with a defaulft vanilla installation of ts and vite.
Update 07/09/2024:
As mentioned by hi-ogawa I did not manage to create a vanilla ts example which mirrors the exact issue I would guess.
So we should consider the Original Issue Part II.
I also include the explanation within follwing comment #17631 (comment).
The svelte kit application uses a default javascript api "instanceof" to check whether an thrown error is a Redirect Class or not. If a redirect is detected the application redirects the user.
If the check fails the user will not be redirected.
There is a direct influence of this behavour in regard to the vite.config.ts setting preserveSymlinks.
If "preserveSymlinks" is set to true the instanceof check will fail and the user is not redirected at all.
If "preserveSymlinks" is set to false the user is redirected.
Reproduction
https://github.com/msprada/vite-pnpm-issue-preserveSymlinkshttps://github.com/msprada/svelte-kit-issue--12139-II
Steps to reproduce
To Reproduce
pnpm install
- Click the "Throw Redirect" Button- An alert will be shownBe aware
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: