{"name":"rolldown-plugin-dts","version":"0.5.0","author":{"name":"三咲智子 Kevin Deng","email":"sxzz@sxzz.moe"},"license":"MIT","_id":"rolldown-plugin-dts@0.5.0","maintainers":[{"name":"sxzz","email":"sxzz@sxzz.moe"}],"homepage":"https://github.com/sxzz/rolldown-plugin-dts#readme","bugs":{"url":"https://github.com/sxzz/rolldown-plugin-dts/issues"},"dist":{"shasum":"e8699eee807010fa16a37e2761f34b16939f455a","tarball":"http://registry-npm.ywwl.com/rolldown-plugin-dts/download/rolldown-plugin-dts-0.5.0.tgz","fileCount":5,"integrity":"sha512-Lf669rSCg7gffltBNWiShKSKtXMr75bMpPRn9Iu5oiLz/CjBXmedscGz3cWmhH0hV36m1YOi/hu8q8GUVR2LEw==","signatures":[{"sig":"MEUCIQC/M1J4U2NvuJLOq27jo5m2OOqbewkuF7hqb6x7eqnk1AIgTqo2WzhtVhj5pwR8xlzD7VvnBN6OCQTMVlVnUl9Swjs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33139,"size":9921,"noattachment":false,"key":"/rolldown-plugin-dts/-/rolldown-plugin-dts-0.5.0.tgz"},"main":"./dist/index.js","type":"module","_from":"file:rolldown-plugin-dts-0.5.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.18.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"funding":"https://github.com/sponsors/sxzz","scripts":{"dev":"tsdown --watch","lint":"eslint --cache .","test":"vitest","build":"tsdown","format":"prettier --cache --write .","release":"bumpp && pnpm publish","lint:fix":"pnpm run lint --fix","typecheck":"tsc --noEmit"},"_npmUser":{"name":"sxzz","email":"sxzz@sxzz.moe"},"prettier":"@sxzz/prettier-config","_resolved":"/private/var/folders/d9/9drlr87n4j904th57x6955l40000gn/T/ce4db383683ab0a6cb7e2596453b8717/rolldown-plugin-dts-0.5.0.tgz","_integrity":"sha512-Lf669rSCg7gffltBNWiShKSKtXMr75bMpPRn9Iu5oiLz/CjBXmedscGz3cWmhH0hV36m1YOi/hu8q8GUVR2LEw==","repository":{"url":"git+https://github.com/sxzz/rolldown-plugin-dts.git","type":"git"},"_npmVersion":"11.2.0","description":"A Rolldown plugin to bundle dts files","directories":{},"_nodeVersion":"22.14.0","dependencies":{"oxc-parser":"^0.62.0","dts-resolver":"^0.1.0","get-tsconfig":"^4.10.0","oxc-transform":"^0.62.0","magic-string-ast":"^0.9.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","diff":"^7.0.0","bumpp":"^10.1.0","eslint":"^9.24.0","tsdown":"^0.8.0-beta.1","vitest":"^3.1.1","prettier":"^3.5.3","rolldown":"^1.0.0-beta.7","typescript":"^5.8.3","@types/diff":"^7.0.2","@types/node":"^22.14.0","estree-walker":"^3.0.3","@sxzz/test-utils":"^0.5.4","rollup-plugin-dts":"^6.2.1","@sxzz/eslint-config":"^6.1.1","@sxzz/prettier-config":"^2.2.1"},"peerDependencies":{"rolldown":"^1.0.0-beta.7","typescript":"^5.0.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/rolldown-plugin-dts_0.5.0_1744788607734_0.37487408816928713","host":"s3://npm-registry-packages-npm-production"},"readme":"# rolldown-plugin-dts\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Unit Test][unit-test-src]][unit-test-href]\n\nA Rolldown plugin that generates and bundles TypeScript declaration files.\n\n## Install\n\nRequires Rolldown 1.2.0 or later and Node.js\n`^22.18.0 || ^24.11.0 || >=26.0.0`.\n\n```bash\nnpm i -D rolldown-plugin-dts\n```\n\nInstall the compiler required by your generator:\n\n```bash\nnpm i -D typescript@^6          # tsc\nnpm i -D typescript@7.1.0-beta  # tsgo API\nnpm i -D tsrs                   # tsrs API\n```\n\nOxc is provided by Rolldown and needs no additional dependency.\n\n## Usage\n\n```ts\n// rolldown.config.ts\nimport { defineConfig } from 'rolldown'\nimport { dts } from 'rolldown-plugin-dts'\n\nexport default defineConfig({\n  input: 'src/index.ts',\n  plugins: [dts()],\n  output: {\n    dir: 'dist',\n    format: 'es',\n  },\n})\n```\n\nSee [rolldown.config.ts](./rolldown.config.ts) for the project's own setup.\n\n## Generators\n\n| Generator | Use it for                                                       | Requirement                                 |\n| --------- | ---------------------------------------------------------------- | ------------------------------------------- |\n| `tsc`     | Full TypeScript compatibility                                    | TypeScript 5.x or 6.x                       |\n| `oxc`     | Fast generation for isolated declarations                        | Code compatible with `isolatedDeclarations` |\n| `tsgo`    | TypeScript Go's asynchronous declaration emit API                | TypeScript 7.1 or later                     |\n| `tsrs`    | [tsrs](https://github.com/oxc-project/tsrs), highly experimental | Latest `tsrs` release                       |\n\nWhen `generator` is omitted, the plugin selects:\n\n1. `oxc` when `compilerOptions.isolatedDeclarations` is enabled.\n2. `tsgo` when `typescript` exposes `Program.prototype.getDeclarationEmit`, or\n   when TypeScript 7.0 is installed (deprecated, see below).\n3. `tsc` otherwise.\n\nAutomatic selection only inspects `typescript` and never selects `tsrs`.\nSelecting `tsgo` explicitly requires TypeScript 7.1 or later, or the\ndeprecated TypeScript 7.0 backend below.\n\n> [!WARNING]\n> With TypeScript 7.0, `tsgo` falls back to running the `tsgo` CLI. This backend\n> is deprecated and will be removed in the next minor; upgrade to TypeScript\n> 7.1 or later. It does not support custom languages, and among the `tsgo.*`\n> options only `tsgo.path` (the executable to run) applies.\n\n`generator` also accepts an object implementing the exported `Generator`\ninterface.\n\n```ts\ndts({\n  generator: 'oxc',\n})\n```\n\n## Options\n\n### General\n\n| Option            | Description                                                                               | Default                 |\n| ----------------- | ----------------------------------------------------------------------------------------- | ----------------------- |\n| `generator`       | Built-in generator name or a custom `Generator` implementation.                           | Inferred                |\n| `tsc`             | Options for the built-in `tsc` generator.                                                 | `{}`                    |\n| `entry`           | Glob or globs selecting files to emit. Supports `!` negation and paths relative to `cwd`. | Rolldown entries        |\n| `cwd`             | Base directory for config discovery, globs, and relative paths.                           | `process.cwd()`         |\n| `dtsInput`        | Treat entry files as existing declarations.                                               | `false`                 |\n| `emitDtsOnly`     | Remove non-declaration chunks from the output.                                            | `false`                 |\n| `tsconfig`        | Config path; `true` discovers one and `false` disables loading.                           | Nearest `tsconfig.json` |\n| `tsconfigRaw`     | Raw config values merged over the loaded config.                                          | `{}`                    |\n| `compilerOptions` | Compiler options merged over the loaded config.                                           | `{}`                    |\n| `sourcemap`       | Emit `.d.ts.map` files.                                                                   | `declarationMap`        |\n| `resolver`        | Resolve declaration imports with `oxc` or `tsc`.                                          | `oxc`                   |\n| `cjsDefault`      | Convert a single default export to `export =`.                                            | `false`                 |\n| `sideEffects`     | Mark declaration modules as having side effects.                                          | `false`                 |\n| `logger`          | Logger implementing `info`, `warn`, and `error`.                                          | `console`               |\n\n`tsc.*`, `oxc.*`, `tsgo.*`, and `tsrs.*` apply only to their respective\ngenerators.\n\n`entry` may include files that are not Rolldown entry points:\n\n```ts\ndts({\n  entry: ['src/**/*.ts', '!src/icons/**'],\n})\n```\n\n`cjsDefault` only changes the emitted export syntax. It does not enable\nCommonJS-style declaration input.\n\n### TypeScript (`tsc`)\n\n| Option            | Description                                                   | Default                                  |\n| ----------------- | ------------------------------------------------------------- | ---------------------------------------- |\n| `tsc.build`       | Use TypeScript build mode and follow project references.      | `false`                                  |\n| `tsc.incremental` | Persist build outputs, including `.tsbuildinfo`, to disk.     | Enabled by the matching tsconfig options |\n| `tsc.parallel`    | Run `tsc` or `vue-tsc` in a separate process.                 | `false`                                  |\n| `tsc.eager`       | Load every file listed by `tsconfig.json`.                    | `false`                                  |\n| `tsc.newContext`  | Use an isolated compiler cache instead of the shared context. | `false`                                  |\n| `tsc.vue`         | Register the built-in Vue integration using `vue-tsc`.        | `false`                                  |\n| `emitJs`          | Generate declarations for JavaScript files with JSDoc types.  | `allowJs` or `checkJs`                   |\n\nTop-level `build`, `incremental`, `parallel`, `eager`, `newContext`, and `vue` are\ndeprecated. Use `tsc.*` instead.\n\n`tsc.incremental` applies to build mode. When disabled, build outputs stay in\nmemory.\n\nTo invalidate a file in the shared compiler cache:\n\n```ts\nimport {\n  globalContext,\n  invalidateContextFile,\n} from 'rolldown-plugin-dts/tsc-context'\n\ninvalidateContextFile(globalContext, 'src/foo.ts')\n```\n\n### Custom languages\n\n`customLanguages` registers non-standard source files such as Vue or Astro.\nVolar integrations must provide both `volarTypeScript` and\n`createVolarPlugins`; they require the `tsc` generator. `tsc.vue: true` is the\npreconfigured Vue shortcut.\n\nThis API is experimental and may change.\n\n### Oxc\n\nOxc generates declarations from each source file independently. Your code must\nbe compatible with `isolatedDeclarations`, including explicit type annotations\nwhere required for exported declarations.\n\n| Option              | Description                                                                                  | Default                          |\n| ------------------- | -------------------------------------------------------------------------------------------- | -------------------------------- |\n| `oxc.stripInternal` | Omit declarations marked with `/** @internal */`.                                            | `compilerOptions.stripInternal`  |\n| `sourcemap`         | Generate `.d.ts.map` files so editors can navigate from declarations to the original source. | `compilerOptions.declarationMap` |\n\n```ts\ndts({\n  generator: 'oxc',\n  sourcemap: true,\n  oxc: {\n    stripInternal: true,\n  },\n})\n```\n\n### TypeScript Go\n\nExperimental. Requires `typescript@7.1.0-beta` or a compatible version and a\n`tsconfig.json`.\n\n| Option                 | Description                                                  | Default                             |\n| ---------------------- | ------------------------------------------------------------ | ----------------------------------- |\n| `tsgo.moduleUrl`       | File URL of the TypeScript package that provides the Go API. | `import.meta.resolve('typescript')` |\n| `tsgo.path`            | Custom API server executable, passed as `tsserverPath`.      | Provided by the selected package    |\n| `tsgo.runExternalCode` | Allow execution of content mappers configured in tsconfig.   | `false`                             |\n| `tsgo.vfs`             | Supply transformed source code through a virtual filesystem. | `false`                             |\n\n- The plugin's current `tsgo` implementation reads compiler settings from the\n  config file; `tsconfigRaw` and `compilerOptions` do not override them.\n- Declaration maps require `compilerOptions.declarationMap: true` in the config\n  file; setting only the plugin's `sourcemap: true` produces a warning.\n- With `tsgo.vfs: true`, source transforms must run before the dts transform hook.\n  Non-Volar custom languages also require a `toTsFilename` mapping.\n  Volar integrations, including `tsc.vue`, require `tsc`.\n\n```ts\ndts({\n  generator: 'tsgo',\n  tsgo: {\n    moduleUrl: import.meta.resolve('typescript'),\n    vfs: true,\n  },\n})\n```\n\n#### Content mappers\n\nConfigure `contentMappers` in your tsconfig and enable `tsgo.runExternalCode`:\n\n```ts\ndts({\n  generator: 'tsgo',\n  tsgo: { runExternalCode: true },\n})\n```\n\nExtensions declared by content mappers (including inherited tsconfig settings)\nare recognized automatically; `customLanguages` is not needed. Content mappers\nread files from disk and cannot be combined with `tsgo.vfs`. If you also emit\nJavaScript, use your framework's Rolldown plugin to transform these source files.\n\n### tsrs\n\nHighly experimental; only the latest `tsrs` release is supported. Accepts the\nsame options as TypeScript Go under `tsrs.*` (`moduleUrl` defaults to\n`import.meta.resolve('tsrs')`).\n\n## Vite\n\nExclude generated declarations from Oxc transformation. Because `oxc.exclude`\nreplaces Vite's default exclusions, keep JavaScript files excluded as well:\n\n```ts\n// vite.config.ts\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  oxc: {\n    exclude: [/\\.js$/, /\\.d\\.[cm]?ts$/],\n  },\n})\n```\n\n## Code splitting\n\nDeclaration chunk names must end in `.d`:\n\n```ts\nexport default {\n  codeSplitting: {\n    groups: [\n      { test: /foo.*\\.d\\.[cm]?ts$/, name: 'shared.d' },\n      { test: /foo/, name: 'shared' },\n    ],\n  },\n}\n```\n\n## Limitations\n\nDeclaration bundling requires an ESM Rolldown output. The `cjs` output format is\nnot supported. For CommonJS packages, build the JavaScript output separately\nand use `emitDtsOnly` for a second declaration-only build.\n\nThe following declaration input cannot be bundled:\n\n- CommonJS export assignments such as `export = value`.\n- CommonJS import aliases such as `import value = require('package')`.\n- Script-style ambient declarations, such as `declare module 'package' { ... }`\n  or unexported top-level `declare` statements. Bundled declaration chunks are\n  always modules, which would change the meaning of these declarations.\n\nMark dependencies that use unsupported declaration syntax as external.\n\n## Credits\n\nInspired by\n[rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts), with an\nindependent implementation. Its MIT-licensed test suite is used with\npermission.\n\n## Sponsors\n\n<p align=\"center\">\n  <a href=\"https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg\">\n    <img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>\n  </a>\n</p>\n\n## License\n\n[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/rolldown-plugin-dts.svg\n[npm-version-href]: https://npmjs.com/package/rolldown-plugin-dts\n[npm-downloads-src]: https://img.shields.io/npm/dm/rolldown-plugin-dts\n[npm-downloads-href]: https://www.npmcharts.com/compare/rolldown-plugin-dts?interval=30\n[unit-test-src]: https://github.com/sxzz/rolldown-plugin-dts/actions/workflows/unit-test.yml/badge.svg\n[unit-test-href]: https://github.com/sxzz/rolldown-plugin-dts/actions/workflows/unit-test.yml\n","publish_time":1744788607973,"_cnpm_publish_time":1744788607973,"dist-tags":{"beta":"0.29.0-beta.2","latest":"0.29.0"}}