Skip to content

unprocessed .svelte files in transitive dependencies within a monorepo #1121

Closed
@AdrianGonz97

Description

@AdrianGonz97

Describe the bug

It seems that vite-plugin-svelte doesn't process the .svelte files from transitive dependencies when those files come from the package's devDependencies, which arguably feels a bit unexpected in the context of a monorepo with private local packages.

In this example, we're importing a svelte component from @lucide/svelte (which is installed as dev dep) in the ui package for a Button component that is then used in the site app.

The idea behind this monorepo setup is to have a local ui package that isn't necessarily published to npm, so the dependency-type for each dependency of that package 'shouldn't really matter' as the dependency will always be resolvable.

One solution (if not, the solution) would be to move the @lucide/svelte dependency in ui to dependencies. However, I think it's worth questioning whether this should be necessary at all if the dependency is locally resolvable.

Reproduction URL

https://github.com/AdrianGonz97/unresolvable-dev-deps-svelte-monorepo

Reproduction

  1. clone https://github.com/AdrianGonz97/unresolvable-dev-deps-svelte-monorepo
  2. run pnpm i && pnpm dev
  3. navigate to http://localhost:5173

Logs

11:56:17 AM [vite] (ssr) Error when evaluating SSR module /src/routes/+page.svelte: Unknown file extension ".svelte" for /home/koala/Reproductions/unresolvable-dev-deps-svelte-monorepo/node_modules/.pnpm/@[email protected][email protected]/node_modules/@lucide/svelte/dist/icons/bubbles.svelte
      at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
      at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
      at defaultLoad (node:internal/modules/esm/load:120:22)
      at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:580:32)
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /home/koala/Reproductions/unresolvable-dev-deps-svelte-monorepo/node_modules/.pnpm/@[email protected][email protected]/node_modules/@lucide/svelte/dist/icons/bubbles.svelte
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:580:32) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 10.94 GB / 31.30 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.19.2 - ~/.volta/tools/image/node/20.19.2/bin/node
    Yarn: 1.22.22 - ~/.volta/tools/image/yarn/1.22.22/bin/yarn
    npm: 10.8.2 - ~/.volta/tools/image/node/20.19.2/bin/npm
    pnpm: 10.9.0 - ~/.volta/bin/pnpm
    bun: 1.1.38 - ~/.bun/bin/bun
  Browsers:
    Chrome: 127.0.6533.119

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageAwaiting triage by a project member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions