Skip to content

pnpm + solid-start causes multiple versions of vite to be installed due to inconsistent installation of peerDependencies #265

@btakita

Description

@btakita

vite has peerDependencies. https://github.com/vitejs/vite/blob/main/packages/vite/package.json#L123-L128

  "peerDependencies": {
    "less": "*",
    "sass": "*",
    "stylus": "*",
    "terser": "^5.4.0"
  },

pnpm will install multiple instances of a package with the same version depending on which peers are installed. https://www.pnpm.cn/how-peers-are-resolved

In this snippet of pnpm-lock.yaml there are two installs of vite. Some of the packages that import vite have terser & some do not.

  /vite/3.0.9:
    resolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
    engines: {node: ^14.18.0 || >=16.0.0}
    hasBin: true
    peerDependencies:
      less: '*'
      sass: '*'
      stylus: '*'
      terser: ^5.4.0
    peerDependenciesMeta:
      less:
        optional: true
      sass:
        optional: true
      stylus:
        optional: true
      terser:
        optional: true
    dependencies:
      esbuild: 0.14.54
      postcss: 8.4.16
      resolve: 1.22.1
      rollup: 2.77.3
    optionalDependencies:
      fsevents: 2.3.2

  /vite/3.0.9_terser@5.15.0:
    esolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
    engines: {node: ^14.18.0 || >=16.0.0}
    hasBin: true
    peerDependencies:
      less: '*'
      sass: '*'
      stylus: '*'
      terser: ^5.4.0
    peerDependenciesMeta:
      less:
        optional: true
      sass:
        optional: true
      stylus:
        optional: true
      terser:
        optional: true
    dependencies:
      esbuild: 0.14.54
      postcss: 8.4.16
      resolve: 1.22.1
      rollup: 2.77.3
      terser: 5.15.0
    optionalDependencies:
      fsevents: 2.3.2

I have a component, Singleton_, which is not transpiled presumably due to two different instances of vite being installed. When pnpm run dev is called & the page is loaded, the following error occurs:

ERROR TypeError: __vite_ssr_import_6__.Singleton_ is not a function

I'm not sure what the best solution is. Perhaps any solid-start packages that import vite should mirror vite's peerDependencies? or install all of the peerDependencies?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions