adobe / css-tools

CSS parser / stringifier for Node.js
MIT License
44 stars 10 forks source link

TypeScript issue: `moduleResolution:NodeNext` doesn’t work with this library #271

Open rauschma opened 9 months ago

rauschma commented 9 months ago

The problem

tsconfig.json:

"module": "NodeNext",
"moduleResolution": "NodeNext",

TypeScript code:

import { parse } from '@adobe/css-tools';

Result – error from tsc:

Solutions

Quickest fix – change package.json:

"exports": {
  "import": "./dist/index.mjs",
  "types": "./dist/types.d.ts",
  "require": "./dist/index.cjs"
},

In the long run, you don’t need "main", "module" and "types" (anywhere!) anymore, as these are superseded by "exports" and modern TypeScript .d.ts resolution. You only have to rename:

mv types.d.ts index.d.mts

Possibly useful

holblin commented 9 months ago

Fixed through https://github.com/adobe/css-tools/pull/274 I will keep this issue open for the long term solution.

Thanks a lot for that detailed issue. This is very use full and well detailed. I truly appreciated.