Skip to content

Unable to Find Type Declarations for Vue Files in Dependency Package with "exports" Field #252

Closed
@Jannchie

Description

@Jannchie

Related plugins

Describe the bug

When trying to import Vue files from a dependency package that contains an "exports" field in its package.json. While I am able to successfully import the files in my project, I am unable to find the associated TS type declarations.

I can't pinpoint the source of the problem.
I have a feeling that this might be a problem with vite-plugin-vue.

Reproduction

https://stackblitz.com/edit/vitejs-vite-wkgkc1?file=src%2FApp.vue,node_modules%2Ffoo%2Fpackage.json,node_modules%2Ffoo%2Fbar.vue&terminal=dev

Steps to reproduce

We need to download this project and run it locally to reproduce the problem.

TS doesn't work with "exports" field in the “foo/package.json”
image

But, this path works.
image

System Info

System:
    OS: Windows 10 10.0.22623
    CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900K
    Memory: 20.86 GB / 63.79 GB
  Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.6 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.891.0), Chromium (116.0.1938.76)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-vue: ^4.2.3 => 4.2.3 
    vite: ^4.4.9 => 4.4.9 


### Used Package Manager

pnpm

### Logs

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite-plugin-vue/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite-plugin-vue/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions