{"id":13527429,"url":"https://github.com/timocov/dts-bundle-generator","last_synced_at":"2025-04-01T09:31:30.775Z","repository":{"id":37270655,"uuid":"85065027","full_name":"timocov/dts-bundle-generator","owner":"timocov","description":"A tool to generate a single bundle of dts with types tree-shaking","archived":false,"fork":false,"pushed_at":"2024-08-27T21:19:51.000Z","size":726,"stargazers_count":760,"open_issues_count":20,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T22:23:39.949Z","etag":null,"topics":["bundle","definition","dts","typescript","typescript-definitions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timocov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"timocov","patreon":null,"open_collective":"dts-bundle-generator"}},"created_at":"2017-03-15T11:35:29.000Z","updated_at":"2024-10-29T15:55:12.000Z","dependencies_parsed_at":"2023-12-29T12:32:22.958Z","dependency_job_id":"dd754d0b-0f04-41e7-bcb2-e6211509a01f","html_url":"https://github.com/timocov/dts-bundle-generator","commit_stats":{"total_commits":519,"total_committers":18,"mean_commits":"28.833333333333332","dds":0.08477842003853564,"last_synced_commit":"964f6c62d9f825d222661c179adc47fb7f23c6ac"},"previous_names":[],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timocov%2Fdts-bundle-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timocov%2Fdts-bundle-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timocov%2Fdts-bundle-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timocov%2Fdts-bundle-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timocov","download_url":"https://codeload.github.com/timocov/dts-bundle-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246616121,"owners_count":20806062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","definition","dts","typescript","typescript-definitions"],"created_at":"2024-08-01T06:01:47.774Z","updated_at":"2025-04-01T09:31:28.955Z","avatar_url":"https://github.com/timocov.png","language":"TypeScript","readme":"\u003c!-- markdownlint-disable MD033 --\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/timocov/dts-bundle-generator\"\u003e\n    \u003cimg width=\"250px\" height=\"250px\" src=\"https://github.com/timocov/dts-bundle-generator/raw/master/.github/logo.svg?sanitize=true\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n# DTS Bundle Generator\n\n[![GH Actions][ci-img]][ci-link]\n[![npm version][npm-version-img]][npm-link]\n[![Downloads][npm-downloads-img]][npm-link]\n\nSmall tool to generate a dts bundle from your ts code.\n\nFor example:\n\n```ts\n// a.ts\nexport class A {}\n```\n\n```ts\n// b.ts\nexport class B {}\n```\n\n```ts\n// entry.ts\nimport { A } from './a';\nimport { B } from './b';\n\ndeclare function makeA(): A;\nexport function makeB(): B {\n    makeA();\n    return new B();\n}\n```\n\nWhen you run `dts-bundle-generator -o my.d.ts entry.ts` in `my.d.ts` you will get the following:\n\n```ts\ndeclare class B {\n}\nexport declare function makeB(): B;\n```\n\n## Installation\n\n1. Install the package from `npm`:\n\n    ```bash\n    npm install --save-dev dts-bundle-generator\n    ```\n\n    or\n\n    ```bash\n    npm install -g dts-bundle-generator\n    ```\n\n1. Enable `declaration` compiler option in `tsconfig.json`\n\n## Usage\n\n```\nUsage: dts-bundle-generator [options] \u003cfile(s)\u003e\n\nOptions:\n  --help                         Show help                                                 [boolean]\n  --out-file, -o                 File name of generated d.ts                                [string]\n  --verbose                      Enable verbose logging                   [boolean] [default: false]\n  --silent                       Disable any logging except errors        [boolean] [default: false]\n  --no-check                     Skip validation of generated d.ts file   [boolean] [default: false]\n  --fail-on-class                Fail if generated dts contains class declaration\n                                                                          [boolean] [default: false]\n  --external-inlines             Array of package names from node_modules to inline typings from.\n                                 Used types will be inlined into the output file             [array]\n  --external-imports             Array of package names from node_modules to import typings from.\n                                 Used types will be imported using \"import { First, Second } from\n                                 'library-name';\".\n                                 By default all libraries will be imported (except inlined libraries\n                                 and libraries from @types)                                  [array]\n  --external-types               Array of package names from @types to import typings from via the\n                                 triple-slash reference directive.\n                                 By default all packages are allowed and will be used according to\n                                 their usages                                                [array]\n  --umd-module-name              Name of the UMD module. If specified then `export as namespace\n                                 ModuleName;` will be emitted                               [string]\n  --project                      Path to the tsconfig.json file that will be used for the\n                                 compilation                                                [string]\n  --sort                         Sort output nodes                        [boolean] [default: false]\n  --inline-declare-global        Enables inlining of `declare global` statements contained in files\n                                 which should be inlined (all local files and packages from\n                                 `--external-inlines`)                    [boolean] [default: false]\n  --inline-declare-externals     Enables inlining of `declare module` statements of the global\n                                 modules (e.g. `declare module 'external-module' {}`, but NOT\n                                 `declare module './internal-module' {}`) contained in files which\n                                 should be inlined (all local files and packages from inlined\n                                 libraries)                               [boolean] [default: false]\n  --disable-symlinks-following   (EXPERIMENTAL) Disables resolving of symlinks to the original path.\n                                 See https://github.com/timocov/dts-bundle-generator/issues/39 for\n                                 more information                         [boolean] [default: false]\n  --respect-preserve-const-enum  Enables stripping the `const` keyword from every direct-exported\n                                 (or re-exported) from entry file `const enum`. See\n                                 https://github.com/timocov/dts-bundle-generator/issues/110 for more\n                                 information                              [boolean] [default: false]\n  --export-referenced-types      By default all interfaces, types and const enums are marked as\n                                 exported even if they aren't exported directly. This option allows\n                                 you to disable this behavior so a node will be exported if it is\n                                 exported from root source file only.      [boolean] [default: true]\n  --config                       File path to the generator config file                     [string]\n  --no-banner                    Allows remove \"Generated by dts-bundle-generator\" comment from the\n                                 output                                   [boolean] [default: false]\n  --version                      Show version number                                       [boolean]\n```\n\n### Examples\n\nTo generate a dts bundle for a single entry file:\n\n```bash\n./node_modules/.bin/dts-bundle-generator -o my.d.ts path/to/your/entry-file.ts\n```\n\nTo generate a dts bundle for multiple entry files:\n\n```bash\n./node_modules/.bin/dts-bundle-generator path/to/your/entry-file.ts path/to/your/entry-file-2.ts\n```\n\nTo generate a dts bundle for a single entry file with external inlines and imports:\n\n```bash\n./node_modules/.bin/dts-bundle-generator \\\n  --external-inlines=@mycompany/internal-project \\\n  --external-imports=@angular/core rxjs \\\n  -- path/to/your/entry-file.ts\n```\n\n\u003e [!NOTE]\n\u003e Note that, as in the above example, the arguments accepting arrays (like `--external-inlines` or `--external-imports`) accept multiple values separated by spaces. Since the input file(s) are positional arguments, you need to put the `--` separator before it when it is preceded by an argument that accepts multiple values. Otherwise you will get an error (`Error: No input files specified`).\n\nTo generate a dts bundle for a single entry file with external types:\n\n```bash\n./node_modules/.bin/dts-bundle-generator --external-types=jquery path/to/your/entry-file.ts\n```\n\n## Config file\n\nIt is unnecessary, but you can use config file for the tool. See [config documentation](src/config-file/README.md) for more information.\n\n## Why\n\nIf you have modules then you can create definitions by default using `tsc`, but `tsc` generates them for each module separately.\nYeah, you can use `outFile` (for `amd` and `system`), but generated code looks like this:\n\n```ts\ndeclare module \"a\" {\n    export class A {\n    }\n}\ndeclare module \"b\" {\n    export class B {\n    }\n}\ndeclare module \"entry\" {\n    import { B } from \"b\";\n    export function makeB(): B;\n}\n```\n\nbut:\n\n1. `A` is not used at all and most probably you do not want to export it.\n1. If you bundle your code in a way when all modules are merged (like when using Webpack or Rollup) then there should be no such modules as `a` or `b` (actually `entry` too) in the resulting file.\n\n[ci-img]: https://github.com/timocov/dts-bundle-generator/workflows/CI%20Test/badge.svg?branch=master\n[ci-link]: https://github.com/timocov/dts-bundle-generator/actions?query=branch%3Amaster\n\n[npm-version-img]: https://badge.fury.io/js/dts-bundle-generator.svg\n[npm-downloads-img]: https://img.shields.io/npm/dm/dts-bundle-generator.svg\n[npm-link]: https://www.npmjs.com/package/dts-bundle-generator\n","funding_links":["https://github.com/sponsors/timocov","https://opencollective.com/dts-bundle-generator"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimocov%2Fdts-bundle-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimocov%2Fdts-bundle-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimocov%2Fdts-bundle-generator/lists"}