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

Module resolution breaking for Yarn PNP in TS 4.8 #50547

Closed
Rykus0 opened this issue Aug 30, 2022 · 4 comments
Closed

Module resolution breaking for Yarn PNP in TS 4.8 #50547

Rykus0 opened this issue Aug 30, 2022 · 4 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@Rykus0
Copy link

Rykus0 commented Aug 30, 2022

Bug Report

Our repo is using Yarn Berry workspaces with PNP, and after upgrading to 4.8, we are seeing a lot of errors resolving modules and types. It seems to be that the module resolution is only trying to look in local files and node_modules.

🔎 Search Terms

  • yarn
  • pnp
  • resolution
  • module

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 4.7.4 and 4.8

⏯ Playground Link

  1. Clone the TVA repo
  2. Checkout deps/ts-up
  3. run yarn lint:ts

💻 Code

🙁 Actual behavior

Types and modules not resolved, resulting in a failed build.

Log excerpt (error):

➤ YN0000: tests/hooks/useEscToClose.test.tsx(43,5): error TS2304: Cannot find name 'expect'.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(8,8): error TS2307: Cannot find module 'react' or its corresponding type declarations.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(9,30): error TS2307: Cannot find module 'react-dom' or its corresponding type declarations.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(10,28): error TS2307: Cannot find module 'react-dom/client' or its corresponding type declarations.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(11,10): error TS2305: Module '"test-utils"' has no exported member 'render'.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(11,24): error TS2305: Module '"test-utils"' has no exported member 'screen'.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(11,32): error TS2305: Module '"test-utils"' has no exported member 'waitForElementToBeRemoved'.
➤ YN0000: tests/hooks/useFocusTrap.test.tsx(14,1): error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.

Log excerpt (resolution):

➤ YN0000: ======== Resolving module 'tslib' from '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/chakra.ts'. ========
➤ YN0000: Explicitly specified module resolution kind: 'NodeNext'.
➤ YN0000: 'baseUrl' option is set to '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src', using this value to resolve non-relative module name 'tslib'.
➤ YN0000: Resolving module name 'tslib' relative to base url '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src' - '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib'.
➤ YN0000: Loading module as file / folder, candidate module location '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib', target file type 'TypeScript'.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.ts' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.tsx' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.d.ts' does not exist.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib' does not exist, skipping all lookups in it.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/package.json' does not exist according to earlier cached lookups.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/package.json' exists according to earlier cached lookups.
➤ YN0000: Loading module 'tslib' from 'node_modules' folder, target file type 'TypeScript'.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: 'baseUrl' option is set to '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src', using this value to resolve non-relative module name 'tslib'.
➤ YN0000: Resolving module name 'tslib' relative to base url '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src' - '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib'.
➤ YN0000: Loading module as file / folder, candidate module location '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib', target file type 'JavaScript'.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.js' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.jsx' does not exist.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib' does not exist, skipping all lookups in it.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/package.json' does not exist according to earlier cached lookups.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/package.json' exists according to earlier cached lookups.
➤ YN0000: Loading module 'tslib' from 'node_modules' folder, target file type 'JavaScript'.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: 'baseUrl' option is set to '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src', using this value to resolve non-relative module name 'tslib'.
➤ YN0000: Resolving module name 'tslib' relative to base url '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src' - '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib'.
➤ YN0000: Loading module as file / folder, candidate module location '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib', target file type 'Json'.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib' does not exist, skipping all lookups in it.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/package.json' does not exist according to earlier cached lookups.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/package.json' exists according to earlier cached lookups.
➤ YN0000: Loading module 'tslib' from 'node_modules' folder, target file type 'Json'.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/thomas-pietrosanti/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/Users/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: Directory '/node_modules' does not exist, skipping all lookups in it.
➤ YN0000: ======== Module name 'tslib' was not resolved. ========

🙂 Expected behavior

No errors (Modules are resolved). This was the case in 4.7.4

Log excerpt:

➤ YN0000: ======== Resolving module 'tslib' from '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/chakra.ts'. ========
➤ YN0000: Explicitly specified module resolution kind: 'NodeNext'.
➤ YN0000: 'baseUrl' option is set to '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src', using this value to resolve non-relative module name 'tslib'.
➤ YN0000: Resolving module name 'tslib' relative to base url '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src' - '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib'.
➤ YN0000: Loading module as file / folder, candidate module location '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib', target file type 'TypeScript'.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.ts' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.tsx' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib.d.ts' does not exist.
➤ YN0000: Directory '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/tslib' does not exist, skipping all lookups in it.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/src/package.json' does not exist according to earlier cached lookups.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/packages/headless-styles/package.json' exists according to earlier cached lookups.
➤ YN0000: Loading module 'tslib' from 'node_modules' folder, target file type 'TypeScript'.
➤ YN0000: Found 'package.json' at '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/package.json'.
➤ YN0000: 'package.json' does not have a 'typesVersions' field.
➤ YN0000: File name '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.js' has a '.js' extension - stripping it.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.ts' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.tsx' does not exist.
➤ YN0000: File '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.d.ts' exist - use it as a name resolution result.
➤ YN0000: Resolving real path for '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.d.ts', result '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.d.ts'.
➤ YN0000: ======== Module name 'tslib' was successfully resolved to '/Users/thomas-pietrosanti/tva-review/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip/node_modules/tslib/tslib.d.ts' with Package ID 'tslib/tslib.d.ts@2.4.0'. ========
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Aug 30, 2022
@RyanCavanaugh
Copy link
Member

Likely for 4.8 patch - cc @andrewbranch

@RyanCavanaugh RyanCavanaugh added External Relates to another program, environment, or user action which we cannot control. and removed Needs Investigation This issue needs a team member to investigate its status. labels Aug 30, 2022
@RyanCavanaugh
Copy link
Member

Jake reminded me that yarn makes TypeScript support yarn-pnp by patching tsc. It looks like yarn hasn't supplied a 4.8 patch yet

@jakebailey
Copy link
Member

yarnpkg/berry@06929db added a patch for 4.8.1-rc and above; potentially there's something wrong going on there, but yes, this isn't our bug.

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

4 participants