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

vite.moduleGraph.safeModulesPath contents are... weird #3349

Closed
Rich-Harris opened this issue Jan 14, 2022 · 10 comments
Closed

vite.moduleGraph.safeModulesPath contents are... weird #3349

Rich-Harris opened this issue Jan 14, 2022 · 10 comments
Labels

Comments

@Rich-Harris
Copy link
Member

Rich-Harris commented Jan 14, 2022

Describe the bug

This is a bit of an odd one — it's not causing any problems per se, and the fault probably lies with Vite, but I haven't succeeded in reproducing it in Vite without Kit, so I'm raising it here instead.

Vite's moduleGraph has a safeModulesPath set of paths that (I think) have been determined to be safe to serve. But the paths are truncated. When I log them out, a typical list looks like this:

[
  "elte-kit/dev/generated/root.svelte",
  "elte-kit/dev/generated/manifest.js",
  "e_modules/.vite/svelte.js",
  "elte-kit/dev/runtime/chunks/utils.js",
  "e_modules/.vite/svelte_store.js",
  "elte-kit/dev/runtime/internal/singletons.js",
  "elte-kit/dev/runtime/paths.js",
  "e_modules/.vite/svelte_internal.js",
  "e_modules/svelte-hmr/runtime/hot-api-esm.js",
  "e_modules/svelte-hmr/runtime/proxy-adapter-dom.js",
  "elte-kit/dev/components/layout.svelte",
  "elte-kit/dev/components/error.svelte",
  "/routes/index.svelte",
  "e_modules/.vite/chunk-TFQY2HEV.js",
  "e_modules/.vite/chunk-U3E4LOIS.js",
  "e_modules/svelte-hmr/runtime/index.js",
  "e_modules/svelte-hmr/runtime/overlay.js",
  "e_modules/svelte-hmr/runtime/hot-api.js",
  "e_modules/svelte-hmr/runtime/proxy.js",
  "e_modules/svelte-hmr/runtime/svelte-hooks.js",
  "e_modules/vite/dist/client/env.mjs"
]

Reproduction

https://github.com/Rich-Harris/vite-safe-modules-repro

Logs

No response

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 86.67 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 95.0.2
    Safari: 15.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.10
    @sveltejs/kit: next => 1.0.0-next.229
    svelte: ^3.44.0 => 3.46.1

Severity

annoyance

Additional Information

No response

@Conduitry
Copy link
Member

FWIW, I can't reproduce this. I'm getting an empty array/set. Ubuntu on WSL.

@geoffrich
Copy link
Member

It repros for me -- the list is as described in the issue report. Also Ubuntu on WSL.

@ghostdevv
Copy link
Member

Same, arch linux

@bluwy
Copy link
Member

bluwy commented Jan 15, 2022

Reproducible with macos M1 Pro. But I have to visit http://localhost:3000 first, then http://localhost:3000/safe-modules-inspector, for it to show the paths. Loading the subpath URL directly after dev server startup shows an empty list.

A quick search in Vite shows this line to be truncating it.

@bluwy bluwy added the vite label Jan 15, 2022
@dominikg
Copy link
Member

unconditionally stripping the first 4 chars seems weird.
I remember that there is a place in vite-plugin-svelte where we strip the fs prefix, and you have to take platform into account to end up with a proper absolute path: https://github.com/sveltejs/vite-plugin-svelte/blob/843841552c3d3d02809c6db34b10b935e2b98770/packages/vite-plugin-svelte/src/utils/id.ts#L73

@ghostdevv
Copy link
Member

@bluwy this is the same for me actually, didn't realise

@dominikg
Copy link
Member

may be fixed by vitejs/vite#6518

@benmccann
Copy link
Member

Thanks @dominikg! Not sure if you saw, but it looks like there's a test failure on that PR that will need to be looked at

@dominikg
Copy link
Member

yeah i just rebased the PR and it fails in the same way so seems valid. Unfortunately it's windows and my windows vm is toast.

@benmccann
Copy link
Member

vitejs/vite#6518 was just merged and will be included in Vite 2.9

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

No branches or pull requests

7 participants