mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Reject auto-imports of relative paths through node_modules in bundler resolution (#52536)
This commit is contained in:
parent
c93f20bcf8
commit
60edd0685f
@ -2413,7 +2413,9 @@ export function getModuleSpecifierResolverHost(program: Program, host: LanguageS
|
||||
|
||||
/** @internal */
|
||||
export function moduleResolutionUsesNodeModules(moduleResolution: ModuleResolutionKind): boolean {
|
||||
return moduleResolution === ModuleResolutionKind.Node10 || moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext;
|
||||
return moduleResolution === ModuleResolutionKind.Node10
|
||||
|| moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext
|
||||
|| moduleResolution === ModuleResolutionKind.Bundler;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @module: esnext
|
||||
// @moduleResolution: bundler
|
||||
|
||||
// @Filename: /node_modules/dep/package.json
|
||||
//// {
|
||||
//// "name": "dep",
|
||||
//// "version": "1.0.0",
|
||||
//// "exports": "./dist/index.js"
|
||||
//// }
|
||||
|
||||
// @Filename: /node_modules/dep/dist/utils.d.ts
|
||||
//// export const util: () => void;
|
||||
|
||||
// @Filename: /node_modules/dep/dist/index.d.ts
|
||||
//// export * from "./utils";
|
||||
|
||||
// @Filename: /index.ts
|
||||
//// util/**/
|
||||
|
||||
// Ensures we filter out the relative path through node_modules
|
||||
// for the non-reexport source, which can only be accessed
|
||||
// directly with the relative path since it's blocked by the
|
||||
// package.json "exports" field.
|
||||
verify.importFixModuleSpecifiers("", ["dep"]);
|
||||
Loading…
x
Reference in New Issue
Block a user