dnt icon indicating copy to clipboard operation
dnt copied to clipboard

"exports" field does not have types, and that results in a package being untyped

Open v1rtl opened this issue 8 months ago • 2 comments

./esm/spektr.js path leads to nowhere

Config:

{
  "name": "spektr",
  "description": "Elegant CLI framework.",
  "repository": {
    "type": "git",
    "url": "https://github.com/StauroDEV/spektr.git"
  },
  "license": "Apache-2.0",
  "bugs": {
    "url": "https://github.com/StauroDEV/spektr/issues"
  },
  "module": "./esm/spektr.js",
  "exports": {
    ".": {
      "import": "./esm/spektr.js"
    },
    "./plugins/color.js": {
      "import": "./esm/plugins/color.js"
    }
  },
  "publishConfig": {
    "access": "public"
  },
  "dependencies": {
    "picocolors": "^1.1.1",
    "table": "^6.8.1",
    "type-detect": "^4.1.0"
  },
  "devDependencies": {
    "@types/node": "latest",
    "@types/type-detect": "^4.0.3"
  },
  "_generatedBy": "dnt@dev",
  "packageManager": "[email protected]+sha512.c89847b0667ddab50396bbbd008a2a43cf3b581efd59cf5d9aa8923ea1fb4b8106c041d540d08acb095037594d73ebc51e1ec89ee40c88b30b8a66c0fae0ac1b"
}

Result package.json:

{
  "name": "spektr",
  "description": "Elegant CLI framework.",
  "repository": {
    "type": "git",
    "url": "https://github.com/StauroDEV/spektr.git"
  },
  "license": "Apache-2.0",
  "bugs": {
    "url": "https://github.com/StauroDEV/spektr/issues"
  },
  "module": "./esm/spektr.js",
  "exports": {
    ".": {
      "import": "./esm/spektr.js"
    },
    "./plugins/color.js": {
      "import": "./esm/plugins/color.js"
    }
  },
  "publishConfig": {
    "access": "public"
  },
  "dependencies": {
    "picocolors": "^1.1.1",
    "table": "^6.8.1",
    "type-detect": "^4.1.0"
  },
  "devDependencies": {
    "@types/node": "latest",
    "@types/type-detect": "^4.0.3"
  },
  "_generatedBy": "dnt@dev",
  "packageManager": "[email protected]+sha512.c89847b0667ddab50396bbbd008a2a43cf3b581efd59cf5d9aa8923ea1fb4b8106c041d540d08acb095037594d73ebc51e1ec89ee40c88b30b8a66c0fae0ac1b"
}

https://publint.dev/[email protected]

v1rtl avatar Apr 19 '25 14:04 v1rtl

It looks like the package.json was pasted for the config. Can you include that?

I have a feeling this might be by design? It only includes a "types" export when using declaration: "separate" because that causes the types to be in a different folder. When not doing that, there's a sibling .d.ts file, so there's no need to include a types export.

  • https://github.com/denoland/dnt/blob/3cbe7dafce9d5113b8cc0b70c1fedae7218e5496/lib/package_json.ts#L102
  • https://github.com/denoland/dnt/blob/3cbe7dafce9d5113b8cc0b70c1fedae7218e5496/tests/integration.test.ts#L642

dsherret avatar Apr 19 '25 19:04 dsherret

Apparently the issue was that for some reason in the esm directory it created an SRC directory and because of that, the paths broke

once I removed type-detect as a dependency, the issue went away

v1rtl avatar Apr 19 '25 21:04 v1rtl