next.js
babae8dd - Don't lookup JSON files in `baseUrl` (#70070)

Commit
1 year ago
Don't lookup JSON files in `baseUrl` (#70070) Closes PACK-3123 Closes #66835 `baseUrl` has this odd behavior where it does **not** apply to JSON file imports. `ResolveModules::Path` is currently only used for `baseUrl`. Either: - we document that this is the behavior of `ResolveModules::Path` - or introduce some additional enum variant `ResolveModules::PathExceptJson` - or add an extension exclusion list to `ResolveModules::Path(Vc<FileSystemPath>, Vc<IndexSet<RcStr>>)` --- Here you can see that `tsc --traceResolution` doesn't look at `hypertune-nextjs-turbo-error/hypertune.json`: ``` ======== Resolving module 'hypertune' from '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/src/app/page.tsx'. ======== Explicitly specified module resolution kind: 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. 'baseUrl' option is set to '/Users/niklas/Desktop/hypertune-nextjs-turbo-error', using this value to resolve non-relative module name 'hypertune'. Resolving module name 'hypertune' relative to base url '/Users/niklas/Desktop/hypertune-nextjs-turbo-error' - '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune'. Loading module as file / folder, candidate module location '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune', target file types: TypeScript, JavaScript, Declaration, JSON. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune.ts' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune.tsx' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune.d.ts' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune.js' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune.jsx' does not exist. Directory '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/hypertune' does not exist, skipping all lookups in it. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/src/app/package.json' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/src/package.json' does not exist. Found 'package.json' at '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/package.json'. Loading module 'hypertune' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. Directory '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/src/app/node_modules' does not exist, skipping all lookups in it. Directory '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/src/node_modules' does not exist, skipping all lookups in it. Found 'package.json' at '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune/package.json'. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune.ts' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune.tsx' does not exist. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune.d.ts' does not exist. 'package.json' does not have a 'typesVersions' field. 'package.json' does not have a 'typings' field. 'package.json' has 'types' field './dist/index.d.ts' that references '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune/dist/index.d.ts'. File '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune/dist/index.d.ts' exists - use it as a name resolution result. Resolving real path for '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/hypertune/dist/index.d.ts', result '/Users/niklas/Desktop/hypertune-nextjs-turbo-error/node_modules/.pnpm/hypertune@2.5.2/node_modules/hypertune/dist/index.d.ts'. ```
Author
Parents
Loading