Skip to content

A typescript package that supports both commonjs and esmodule should generate .d.ts and .d.cts type files, now only .d.ts #1030

Open
@yuntian001

Description

@yuntian001

typescript 文档请参考:https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing

package.json

"type": "module",
    "main": "dist/index.cjs",
    "module": "dist/index.js",
    "types": "dist/index.d.ts",
    "exports": {
      ".": {
        "import": {
          "types": "./dist/index.d.ts",
          "default":"./dist/index.js"
        },
        "require":  {
          "types": "./dist/index.d.cts",
          "default":"./dist/index.cjs"
        }
      }      
    },
    "files": [
      "dist"
    ],
    "scripts": {
      "test": "npm run build && cd ./test && npm run dev",
      "clean": "rimraf dist",
      "build": "rimraf dist && microbundle --target node  -f esm,cjs"
    },

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions