Skip to content

types and exports in dependency package.json break module specifier generation #46281

@andrewbranch

Description

@andrewbranch

#46159 seems to cause us to ignore the top-level types field when there’s an exports field when trying to see if we can resolve a node_modules path to a package-style module specifier. Complete failing fourslash test:

// @module: commonjs

// @Filename: /node_modules/react-hook-form/package.json
//// {
////   "name": "react-hook-form",
////   "main": "dist/index.cjs.js",
////   "module": "dist/index.esm.js",
////   "types": "dist/index.d.ts",
////   "exports": {
////     "./package.json": "./package.json",
////     ".": {
////       "import": "./dist/index.esm.js",
////       "require": "./dist/index.cjs.js"
////     }
////   }
//// }

// @Filename: /node_modules/react-hook-form/dist/index.cjs.js
//// module.exports = {};

// @Filename: /node_modules/react-hook-form/dist/index.esm.js
//// export function useForm() {}

// @Filename: /node_modules/react-hook-form/dist/index.d.ts
//// export function useForm(): any;

// @Filename: /index.ts
//// useForm/**/

verify.importFixModuleSpecifiers("", ["react-hook-form"]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions