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 build tooling cannot resolve source in Typescript monorepo #11572

Closed
7 tasks done
cefn opened this issue Jan 3, 2023 · 1 comment
Closed
7 tasks done

Vite build tooling cannot resolve source in Typescript monorepo #11572

cefn opened this issue Jan 3, 2023 · 1 comment

Comments

@cefn
Copy link

cefn commented Jan 3, 2023

Describe the bug

I am running Vite on a test suite in a monorepo. Although other tooling (expecially typescript tooling and my editor) resolves modules correctly, with autocompletion and navigation working well, Vite doesn't seem to be able to resolve a module even when the resolved path is correct.

In the Logs section below you can see a build from a clean checkout of the example repro at https://github.com/cefn/vite-resolution-repro/tree/5e7f0f6fd210b2b5fa50783bbc3896e76abb195b They show the failure to resolve the ...types module, followed by a listing that shows that the types module is in fact there in place.

Reproduction

https://github.com/cefn/vite-resolution-repro/tree/5e7f0f6fd210b2b5fa50783bbc3896e76abb195b

Steps to reproduce

Run npm install && npm run test.

System Info

$ npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y

  System:
    OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Core(TM) i7-7Y75 CPU @ 1.30GHz
    Memory: 12.33 GB / 14.20 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 18.12.1 - ~/.asdf/installs/nodejs/18.12.1/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.12.1/bin/yarn
    npm: 9.1.1 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chromium: 90.0.4430.212
    Firefox: 102.6.0esr

Used Package Manager

npm

Logs

[github/vitest-resolution-repro]$ npm install && npm run test

added 800 packages, and audited 803 packages in 1m

127 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] test
> wireit

🏃 [packages/offline-composition:build] Running command "tsc --build"
🏃 [packages/load-json:build] Running command "tsc --build"
✅ [packages/load-json:build] Executed successfully
🏃 [packages/load-json:test] Running command "true || vitest run --globals"
✅ [packages/load-json:test] Executed successfully
✅ [packages/offline-composition:build] Executed successfully
🏃 [packages/offline-composition:test] Running command "vitest run --globals"

 RUN  v0.25.8 /home/cefn/Documents/github/vitest-resolution-repro/packages/offline-composition

 ❯ test/index.test.ts  (0 test)

⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/index.test.ts [ test/index.test.ts ]
Error: Cannot find module '/home/cefn/Documents/github/vitest-resolution-repro/packages/load-json/dist/esm/types' imported from /home/cefn/Documents/github/vitest-resolution-repro/packages/load-json/dist/esm/index.js

[github/vitest-resolution-repro]$ ls /home/cefn/Documents/github/vitest-resolution-repro/packages/load-json/dist/esm
index.d.ts  index.js  index.js.map  types.d.ts  types.js  types.js.map

Validations

@sapphi-red
Copy link
Member

Node.js's ESM requires file extension. Or you can use deps.inline to make vitest process those files.
related: vitest-dev/vitest#2468

Closing as this is not a bug.

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

No branches or pull requests

2 participants