sindresorhus / ansi-escapes

ANSI escape codes for manipulating the terminal
MIT License
494 stars 44 forks source link

Exports CJS #34

Closed jaikme closed 1 year ago

jaikme commented 1 year ago

I'm really enjoyed this package, but can you help me with something?

I'm trying to use this package with ts-node, but it rejects the "exports": "./index.js" of the package because my compilerOptions.module need to be a CJS.

I'm here to suggest ship ESM & CJS with the following configuration:

ansi-escapes/package.json

"type": "module",
"exports": {
  "import": "./index.js",
  "require": "./dist/index.cjs"
},
"scripts": {
  ...
  "build": "tsup src/index.js",
  "prepublishOnly": "npm run build"
},
"files": [
  "dist",
  "index.js",
  "index.d.ts"
],
"devDependencies": {
  ...
  "tsup": "^6.7.0",
}

I used tsup here, but have other means like unbuild

wrap-ansi have the same issue

Is this viable ? Need help ?