{"name":"fix-dts-default-cjs-exports","type":"module","version":"1.0.1","packageManager":"pnpm@10.6.3","description":"Utility to fix TypeScript declarations when using default exports in CommonJS.","author":{"name":"userquin","email":"userquin@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/userquin/fix-dts-default-cjs-exports.git"},"bugs":{"url":"https://github.com/userquin/fix-dts-default-cjs-exports/issues"},"keywords":["rollup","cjs","typescript","default exports"],"sideEffects":false,"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./rollup":{"import":{"types":"./dist/rollup.d.mts","default":"./dist/rollup.mjs"},"require":{"types":"./dist/rollup.d.cts","default":"./dist/rollup.cjs"}}},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","typesVersions":{"*":{"rollup":["./dist/rollup.d.ts"]}},"scripts":{"prepack":"pkgroll --clean-dist","test:full":"pnpm test:coverage && pnpm test:attw","test:coverage":"vitest run --coverage","test":"vitest","lint":"eslint .","lint:fix":"pnpm lint --fix","release":"bumpp && npm publish","test:attw":"pnpm test:reexport-types && pnpm test:reexport-default && pnpm test:mixed-declarations","test:reexport-types":"attw --pack test/fixtures/reexport-types","test:reexport-default":"attw --pack test/fixtures/reexport-default","test:mixed-declarations":"attw --pack test/fixtures/mixed-declarations"},"dependencies":{"magic-string":"^0.30.17","mlly":"^1.7.4","rollup":"^4.34.8"},"devDependencies":{"@antfu/eslint-config":"^4.3.0","@arethetypeswrong/cli":"^0.17.4","@types/node":"^20.14.8","@vitest/coverage-v8":"^3.0.6","bumpp":"^10.0.3","eslint":"^9.21.0","pathe":"^2.0.3","pkgroll":"^2.11.0","typescript":"^5.7.3","unbuild":"3.3.1","vitest":"^3.0.6"},"_id":"fix-dts-default-cjs-exports@1.0.1","gitHead":"da36479e00b50f08ba7afd60c673f606f0db79e6","homepage":"https://github.com/userquin/fix-dts-default-cjs-exports#readme","_nodeVersion":"20.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==","shasum":"955cb6b3d519691c57828b078adadf2cb92e9549","tarball":"http://registry-npm.ywwl.com/fix-dts-default-cjs-exports/download/fix-dts-default-cjs-exports-1.0.1.tgz","fileCount":18,"unpackedSize":43250,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCP/tD8ePnzUpkQKWBrmCZN/Ym/IIjyHRrjgNLxYmKp2wIgHNmGj2wiF+a3OOgu8v/Awolk79JMBkAeR58ttQQ7h/g="}],"size":7148,"noattachment":false,"key":"/fix-dts-default-cjs-exports/-/fix-dts-default-cjs-exports-1.0.1.tgz"},"_npmUser":{"name":"userquin","email":"userquin@gmail.com"},"directories":{},"maintainers":[{"name":"danielroe","email":"daniel@roe.dev"},{"name":"userquin","email":"userquin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fix-dts-default-cjs-exports_1.0.1_1742292251668_0.22040591042293078"},"_hasShrinkwrap":false,"readme":"# Fix TypeScript Declarations for default CJS exports\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![License][license-src]][license-href]\n\nThis utility will allow you to fix the TypeScript declaration in CommonJS modules when using default exports.\n\nCheck the CJS fixtures in the test folder and the [CJS](./CJS.md) document for further details when using `rollup-plugin-dts`.\n\n## Features\n\n- 🚀 Fix default exports in CommonJS modules via API or Rollup plugin\n- ✨ Generate CommonJS `d.ts` and `d.cts` files from `d.mts` files\n- 💥 Use it with custom builders like [unbuild](https://github.com/unjs/unbuild), [tsup](https://github.com/egoist/tsup) or [pkgroll](https://github.com/privatenumber/pkgroll) (right now only `unbuild` supported, `tsup` and `pkgroll` don't allow adding Rollup plugins)\n\n## unbuild\n\n> [!NOTE]\n>\n> [unbuild](https://github.com/unjs/unbuild) `v3.5.0` uses the Rollup plugin from this package to fix the default exports in CommonJS modules.\n\nFor older `unbuild` versions, you can add the Rollup plugin from this package using the `rollup:dts:options` hook.\n\n> [!WARNING]\n>\n> You should register the plugin directly when enabling `rollup.emitCJS = true` option, otherwise you can get wrong transformations.\n>\n> The plugin exposed here is just a helper to fix the default exports in CommonJS modules, it cannot control what files are being generated, check the [declaration](https://github.com/unjs/unbuild?tab=readme-ov-file#configuration) option in the readme file.\n\nYou will need to remove its current internal plugin adding the one provided by this package:\n```ts\n// build.config.ts\nimport { FixDtsDefaultCjsExportsPlugin } from 'fix-dts-default-cjs-exports/rollup'\nimport { defineBuildConfig } from 'unbuild'\n\nexport default defineBuildConfig({\n  entries: ['<your-entry-points>'],\n  declaration: true,\n  clean: true,\n  rollup: { emitCJS: true },\n  hooks: {\n    'rollup:dts:options': (ctx, options) => {\n      /* uncomment this block if you want to remove the unbuild internal plugin\n      options.plugins = plugins.filter((p) => {\n        if (!p || typeof p === 'string' || Array.isArray(p) || !('name' in p))\n          return true\n\n        return p.name !== 'unbuild-fix-cjs-export-type'\n      })\n      */\n      options.plugins.push(FixDtsDefaultCjsExportsPlugin({\n        warn: message => ctx.warnings.add(message)\n      }))\n    }\n  }\n})\n```\n\n## tsup\n\nSince [tsup](https://github.com/egoist/tsup) doesn't expose any hook to allow change internal configuration, we need a change in the package to include the Rollup plugin from this package instead its built-in one.\n\n## pkgroll\n\n[pkgroll](https://github.com/privatenumber/pkgroll) is exposing only the `cli`, we need a change in the package to include the Rollup plugin from this package instead its built-in one.\n\n## License\n\n[MIT](./LICENSE) License © 2025-PRESENT [Joaquín Sánchez](https://github.com/userquin)\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/fix-dts-default-cjs-exports?style=flat&colorA=18181B&colorB=F0DB4F\n[npm-version-href]: https://npmjs.com/package/fix-dts-default-cjs-exports\n[npm-downloads-src]: https://img.shields.io/npm/dm/fix-dts-default-cjs-exports?style=flat&colorA=18181B&colorB=F0DB4F\n[npm-downloads-href]: https://npmjs.com/package/fix-dts-default-cjs-exports\n[license-src]: https://img.shields.io/github/license/userquin/fix-dts-default-cjs-exports.svg?style=flat&colorA=18181B&colorB=F0DB4F\n[license-href]: https://github.com/userquin/fix-dts-default-cjs-exports/blob/main/LICENSE\n","publish_time":1742292251838,"_cnpm_publish_time":1742292251838,"dist-tags":{"latest":"1.0.1"}}