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

Vue 3.3 unable to resolve external package types if external file contains relative import and extension #8339

Closed
kalvenschraut opened this issue May 16, 2023 · 0 comments

Comments

@kalvenschraut
Copy link
Contributor

Vue version

3.3.2

Link to minimal reproduction

https://github.com/kalvenschraut/vue-unresolved-types-build-failure

Steps to reproduce

See README in the repo.

What is expected?

Build not to fail and type to be resolve

What is actually happening?

I think the problem is that vue is trying to do a relative resolve of an import that is inside of an external package.

While this could work, would have to fix resolveExt to handle the various scenarios, I think the more ideal direction is to allow typescript resolve these relative imports if there are not within your own package here.

if (source.startsWith('.')) {

Not sure how feasible that direction is. Only thing I can think of it having to know where the project root is and compare the source.filename with that before determining your direction. Maybe by using process.cwd()?

Otherwise, I would just strip off any extension and try the various ones it already is doing. The .js extension will resolve to the actual built file without the types which would be bad. If allow .ts extension still needs to be stripped since likely looking for .d.ts if its inside an external package due to the files likely being built by some tool.

System Info

System:
    OS: Linux 5.15 Gentoo Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
    Memory: 19.12 GB / 26.78 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.12.1 - /usr/bin/node
    Yarn: 3.3.0 - /usr/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
    Watchman: 2023.01.16.00 - /usr/bin/watchman
  Browsers:
    Firefox: 102.7.0esr
  npmPackages:
    vue: 3.3.2 => 3.3.2

Any additional comments?

Made a separate issue from #8326 as that one is about making the build not fail, this one is about making sure the type is resolved.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant