WebStorm TypeScript service option to enforce pnpm workspace exports field compliance
0 reputation · 24 Apr 2024, 10:49 UTC
Goal: Configure WebStorm’s TypeScript language service to resolve imports from pnpm workspace packages according to the package.json exports field, ensuring navigation and auto‑import land on the declared entry point rather than the source file.
Uncertainty: It is not documented which resolution strategy WebStorm applies when a workspace package appears under node_modules/.pnpm/.../node_modules/. The IDE may treat the symlinked package as project source, bypassing exports, or follow the real path, and the behavior appears to depend on the “Resolve symlinks” option, the bundled TypeScript version, and the pnpm hoisting mode, with no clear rule provided.
Questions: Does enabling the “Resolve symlinks” option in the TypeScript service settings cause WebStorm to use the real‑path resolver that respects the exports field, or does it retain symlink‑based navigation that points to source files? Is there a supported configuration (e.g., a hidden flag or tsconfig paths adjustment) that forces the IDE to honor the exports field for workspace imports without disabling symlink resolution for external dependencies? How does the “Use types from node_modules” setting influence whether a symlinked workspace package is considered library code for diagnostics and completion when pnpm’s symlinked layout is present?