{"name":"fix-dts-default-cjs-exports","version":"0.0.1","keywords":["rollup","cjs","typescript","default exports"],"author":{"name":"userquin","email":"userquin@gmail.com"},"license":"MIT","_id":"fix-dts-default-cjs-exports@0.0.1","maintainers":[{"name":"userquin","email":"userquin@gmail.com"}],"homepage":"https://github.com/userquin/fix-dts-default-cjs-exports#readme","bugs":{"url":"https://github.com/userquin/fix-dts-default-cjs-exports/issues"},"dist":{"shasum":"afa6ea9624b1c038c0d8d24e80d908e0c536e196","tarball":"http://registry-npm.ywwl.com/fix-dts-default-cjs-exports/download/fix-dts-default-cjs-exports-0.0.1.tgz","fileCount":13,"integrity":"sha512-Qa2130+SIawxFxux+yeveoHzgpY346kchfW8IcmVTZnjHWa4VC/ublBT3D5HIs9vbnKWE1GJyYfRei2J3ARRBg==","signatures":[{"sig":"MEUCICKhdI2367tUpRHaC6EgmGoZD31PqmozRnD7b/KrzuO5AiEA3H1UAb9k2TqWJskCgrue+FNwh52GIwf30cj2MWpy/oE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31253,"size":6303,"noattachment":false,"key":"/fix-dts-default-cjs-exports/-/fix-dts-default-cjs-exports-0.0.1.tgz"},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.cts","module":"./dist/index.mjs","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"}},"./package.json":"./package.json"},"gitHead":"392951897d383c32b3b9746ee5c931cc63a6935e","scripts":{"lint":"eslint .","test":"vitest","prepack":"pkgroll --clean-dist","release":"bumpp && npm publish","lint:fix":"pnpm lint --fix","test:attw":"pnpm test:reexport-types && pnpm test:reexport-default && pnpm test:mixed-declarations","test:full":"pnpm test:coverage && pnpm test:attw","test:coverage":"vitest run --coverage","test:reexport-types":"attw --pack ./test/cjs-types-fixture/reexport-types","test:reexport-default":"attw --pack ./test/cjs-types-fixture/reexport-default","test:mixed-declarations":"attw --pack ./test/cjs-types-fixture/mixed-declarations"},"_npmUser":{"name":"userquin","email":"userquin@gmail.com"},"repository":{"url":"git+https://github.com/userquin/fix-dts-default-cjs-exports.git","type":"git"},"_npmVersion":"10.9.2","description":"Utility to fix TypeScript declarations when using default exports in CommonJS.","directories":{},"sideEffects":false,"_nodeVersion":"20.10.0","dependencies":{"mlly":"^1.7.4","rollup":"^4.34.8","magic-string":"^0.30.17"},"typesVersions":{"*":{"rollup":["./dist/rollup.cts"]}},"_hasShrinkwrap":false,"packageManager":"pnpm@10.4.1","devDependencies":{"bumpp":"^10.0.3","pathe":"^2.0.3","eslint":"^9.21.0","vitest":"^3.0.6","pkgroll":"^2.11.0","unbuild":"3.3.1","typescript":"^5.7.3","@types/node":"^20.14.8","@vitest/coverage-v8":"^3.0.6","@antfu/eslint-config":"^4.3.0","@arethetypeswrong/cli":"^0.17.4"},"_npmOperationalInternal":{"tmp":"tmp/fix-dts-default-cjs-exports_0.0.1_1740336841600_0.21554262613287434","host":"s3://npm-registry-packages-npm-production"},"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":1740336841804,"_cnpm_publish_time":1740336841804,"dist-tags":{"latest":"1.0.1"}}