├── .gitattributes ├── test ├── samples │ ├── export-from │ │ ├── input │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ ├── index.js │ │ │ └── types.d.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── import-all │ │ ├── input │ │ │ ├── type.ts │ │ │ ├── namespace.ts │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-default-value │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── no-renames │ │ ├── input │ │ │ ├── function.ts │ │ │ ├── type.ts │ │ │ ├── namespace.ts │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── const-namespace │ │ ├── input │ │ │ ├── index.js │ │ │ └── foo.js │ │ ├── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ │ └── output 5.0 │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── strip-internal │ │ ├── options.json │ │ ├── input │ │ │ ├── internal.d.ts │ │ │ ├── others.d.ts │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-default-function │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-named-as │ │ ├── input │ │ │ ├── index.js │ │ │ └── foo.js │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── export-type │ │ ├── input │ │ │ ├── index.ts │ │ │ └── foo.d.ts │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── generics │ │ ├── input │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── ts │ │ ├── input │ │ │ ├── subpackage │ │ │ │ ├── index.ts │ │ │ │ └── multiply.ts │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── basic │ │ ├── input │ │ │ ├── subpackage │ │ │ │ ├── index.js │ │ │ │ └── multiply.js │ │ │ ├── types.d.ts │ │ │ ├── index.js │ │ │ └── vectors.d.ts │ │ ├── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ │ └── output ^5.5 │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── export-as-default │ │ ├── input │ │ │ ├── types.d.ts │ │ │ └── add.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-default-as │ │ ├── input │ │ │ ├── types.d.ts │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── deconflict-priority │ │ ├── input │ │ │ ├── a.d.ts │ │ │ ├── b.d.ts │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-declare-as-default │ │ ├── input │ │ │ ├── types.d.ts │ │ │ └── add.d.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── export-renamed │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── shadowing │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── path-config │ │ ├── input │ │ │ ├── lib.d.ts │ │ │ ├── nested │ │ │ │ └── file.js │ │ │ └── index.js │ │ ├── output 5.0 - 5.1 │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── ambient-imports │ │ ├── input │ │ │ └── types.d.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── enum │ │ ├── input │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── namespace-exports │ │ ├── input │ │ │ ├── dependency.ts │ │ │ ├── index.ts │ │ │ └── namespace.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── import-external-named │ │ ├── input │ │ │ └── index.js │ │ ├── node_modules │ │ │ └── external │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ └── types.d.ts │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── import-external-named-as │ │ ├── node_modules │ │ │ └── external │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ └── types.d.ts │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── preserve-comments │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── import-external-named-as-conflict │ │ ├── node_modules │ │ │ └── external │ │ │ │ ├── index.js │ │ │ │ ├── package.json │ │ │ │ └── types.d.ts │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── import-external-default │ │ ├── input │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── ignores-missing-sourcemap-segments │ │ ├── input │ │ │ └── index.js │ │ ├── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ │ └── output 5.0 │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── throws │ │ ├── input │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ ├── declare-module │ │ ├── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ │ └── input │ │ │ └── types.d.ts │ ├── jsdoc-import │ │ ├── input │ │ │ ├── vector.d.ts │ │ │ └── index.js │ │ ├── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ │ └── output ^5.5 │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── treeshaking-inline-import │ │ ├── input │ │ │ ├── vectors.d.ts │ │ │ └── index.js │ │ └── output │ │ │ ├── index.d.ts.map │ │ │ └── index.d.ts │ ├── overloads │ │ ├── input │ │ │ └── index.ts │ │ └── output │ │ │ ├── index.d.ts │ │ │ └── index.d.ts.map │ └── preserved-jsdoc-tags │ │ ├── input │ │ └── index.js │ │ └── output │ │ ├── index.d.ts.map │ │ └── index.d.ts ├── tsconfig.json └── test.js ├── .prettierignore ├── .gitignore ├── .editorconfig ├── .prettierrc ├── .changeset ├── config.json └── README.md ├── tsconfig.json ├── LICENSE ├── .github └── workflows │ ├── release.yml │ └── ci.yml ├── package.json ├── src ├── types.d.ts ├── cli.js ├── index.js ├── create-module-declaration.js └── utils.js ├── README.md ├── CHANGELOG.md └── pnpm-lock.yaml /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /test/samples/export-from/input/a.js: -------------------------------------------------------------------------------- 1 | export * from './b.js'; 2 | -------------------------------------------------------------------------------- /test/samples/import-all/input/type.ts: -------------------------------------------------------------------------------- 1 | export type Z = true; 2 | -------------------------------------------------------------------------------- /test/samples/export-from/input/b.js: -------------------------------------------------------------------------------- 1 | export const foo = 'hello'; 2 | -------------------------------------------------------------------------------- /test/samples/export-default-value/input/index.js: -------------------------------------------------------------------------------- 1 | export default 42; 2 | -------------------------------------------------------------------------------- /test/samples/export-from/input/index.js: -------------------------------------------------------------------------------- 1 | export { foo } from './a.js'; 2 | -------------------------------------------------------------------------------- /test/samples/export-from/input/types.d.ts: -------------------------------------------------------------------------------- 1 | export * from './index.js'; 2 | -------------------------------------------------------------------------------- /test/samples/no-renames/input/function.ts: -------------------------------------------------------------------------------- 1 | export function bar() {} 2 | -------------------------------------------------------------------------------- /test/samples/const-namespace/input/index.js: -------------------------------------------------------------------------------- 1 | export { a } from './foo.js'; 2 | -------------------------------------------------------------------------------- /test/samples/strip-internal/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "stripInternal": true 3 | } 4 | -------------------------------------------------------------------------------- /test/samples/export-default-function/input/index.js: -------------------------------------------------------------------------------- 1 | export default function foo() {} 2 | -------------------------------------------------------------------------------- /test/samples/export-named-as/input/index.js: -------------------------------------------------------------------------------- 1 | export { add as plus } from './foo.js'; 2 | -------------------------------------------------------------------------------- /test/samples/export-type/input/index.ts: -------------------------------------------------------------------------------- 1 | export { A as B, C as D } from './foo.js'; 2 | -------------------------------------------------------------------------------- /test/samples/generics/input/index.ts: -------------------------------------------------------------------------------- 1 | export interface Foo { 2 | bar: T; 3 | } 4 | -------------------------------------------------------------------------------- /test/samples/ts/input/subpackage/index.ts: -------------------------------------------------------------------------------- 1 | export { multiply } from './multiply'; 2 | -------------------------------------------------------------------------------- /test/samples/basic/input/subpackage/index.js: -------------------------------------------------------------------------------- 1 | export { multiply } from './multiply.js'; 2 | -------------------------------------------------------------------------------- /test/samples/strip-internal/input/internal.d.ts: -------------------------------------------------------------------------------- 1 | export type Internal = { foo: boolean }; 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # extra ignores for prettier 2 | test/samples/*/output* 3 | pnpm-lock.yaml 4 | -------------------------------------------------------------------------------- /test/samples/export-as-default/input/types.d.ts: -------------------------------------------------------------------------------- 1 | export { add as default } from './add.js'; 2 | -------------------------------------------------------------------------------- /test/samples/export-default-as/input/types.d.ts: -------------------------------------------------------------------------------- 1 | export { default as add } from './index.js'; 2 | -------------------------------------------------------------------------------- /test/samples/export-type/input/foo.d.ts: -------------------------------------------------------------------------------- 1 | export type C = {}; 2 | export declare class A {} 3 | -------------------------------------------------------------------------------- /test/samples/deconflict-priority/input/a.d.ts: -------------------------------------------------------------------------------- 1 | export interface Foo {} 2 | export interface Bar {} 3 | -------------------------------------------------------------------------------- /test/samples/deconflict-priority/input/b.d.ts: -------------------------------------------------------------------------------- 1 | export interface Foo {} 2 | export interface Bar {} 3 | -------------------------------------------------------------------------------- /test/samples/export-declare-as-default/input/types.d.ts: -------------------------------------------------------------------------------- 1 | export { add as default } from './add.js'; 2 | -------------------------------------------------------------------------------- /test/samples/export-renamed/input/index.js: -------------------------------------------------------------------------------- 1 | const number = 42; 2 | 3 | export { number as answer }; 4 | -------------------------------------------------------------------------------- /test/samples/shadowing/input/index.js: -------------------------------------------------------------------------------- 1 | class MyMap extends Map {} 2 | 3 | export { MyMap as Map }; 4 | -------------------------------------------------------------------------------- /test/samples/path-config/input/lib.d.ts: -------------------------------------------------------------------------------- 1 | export type Input = number; 2 | export type Output = number; 3 | -------------------------------------------------------------------------------- /test/samples/ambient-imports/input/types.d.ts: -------------------------------------------------------------------------------- 1 | import 'some-ambient-import'; 2 | 3 | export interface Foo {} 4 | -------------------------------------------------------------------------------- /test/samples/basic/input/types.d.ts: -------------------------------------------------------------------------------- 1 | export { Vector2 } from './vectors.d.ts'; 2 | export * from './index.js'; 3 | -------------------------------------------------------------------------------- /test/samples/enum/input/index.ts: -------------------------------------------------------------------------------- 1 | export enum categories { 2 | ANIMAL, 3 | VEGETABLE, 4 | MINERAL 5 | } 6 | -------------------------------------------------------------------------------- /test/samples/namespace-exports/input/dependency.ts: -------------------------------------------------------------------------------- 1 | export interface Dependency { 2 | name: string; 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /node_modules 3 | /test/samples/*/actual 4 | /test/samples/*/debug 5 | /types 6 | /debug 7 | -------------------------------------------------------------------------------- /test/samples/import-external-named/input/index.js: -------------------------------------------------------------------------------- 1 | import { foo, bar } from 'external'; 2 | 3 | export { foo }; 4 | -------------------------------------------------------------------------------- /test/samples/import-external-named/node_modules/external/index.js: -------------------------------------------------------------------------------- 1 | export function foo() {} 2 | export function bar() {} -------------------------------------------------------------------------------- /test/samples/import-external-named-as/node_modules/external/index.js: -------------------------------------------------------------------------------- 1 | export function foo() {} 2 | export function bar() {} -------------------------------------------------------------------------------- /test/samples/no-renames/input/type.ts: -------------------------------------------------------------------------------- 1 | import { Namespace } from './namespace'; 2 | 3 | export type Y = Namespace.X; 4 | -------------------------------------------------------------------------------- /test/samples/const-namespace/input/foo.js: -------------------------------------------------------------------------------- 1 | export const a = { 2 | x: 1 3 | }; 4 | 5 | export const b = { 6 | y: 2 7 | }; 8 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as/input/index.js: -------------------------------------------------------------------------------- 1 | import { foo as f, bar as b } from 'external'; 2 | 3 | export { f }; 4 | -------------------------------------------------------------------------------- /test/samples/import-external-named/node_modules/external/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "types": "types.d.ts" 4 | } -------------------------------------------------------------------------------- /test/samples/import-external-named/node_modules/external/types.d.ts: -------------------------------------------------------------------------------- 1 | export function foo(): void; 2 | export function bar(): void; -------------------------------------------------------------------------------- /test/samples/preserve-comments/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @deprecated 3 | */ 4 | export function a() { 5 | return 1; 6 | } 7 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/node_modules/external/index.js: -------------------------------------------------------------------------------- 1 | export function foo() {} 2 | export function bar() {} -------------------------------------------------------------------------------- /test/samples/import-external-named-as/node_modules/external/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "types": "types.d.ts" 4 | } -------------------------------------------------------------------------------- /test/samples/import-external-named-as/node_modules/external/types.d.ts: -------------------------------------------------------------------------------- 1 | export function foo(): void; 2 | export function bar(): void; -------------------------------------------------------------------------------- /test/samples/import-all/input/namespace.ts: -------------------------------------------------------------------------------- 1 | export namespace Namespace { 2 | export interface X { 3 | error(): string; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/node_modules/external/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "types": "types.d.ts" 4 | } -------------------------------------------------------------------------------- /test/samples/no-renames/input/namespace.ts: -------------------------------------------------------------------------------- 1 | export namespace Namespace { 2 | export interface X { 3 | error(): string; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/node_modules/external/types.d.ts: -------------------------------------------------------------------------------- 1 | export function foo(): void; 2 | export function bar(): void; -------------------------------------------------------------------------------- /test/samples/import-external-default/input/index.ts: -------------------------------------------------------------------------------- 1 | import x from 'external'; 2 | 3 | export function foo(input: x) { 4 | return input; 5 | } 6 | -------------------------------------------------------------------------------- /test/samples/ignores-missing-sourcemap-segments/input/index.js: -------------------------------------------------------------------------------- 1 | export const object = { 2 | answer: 42 3 | }; 4 | 5 | export function hello() {} 6 | -------------------------------------------------------------------------------- /test/samples/throws/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @throws {Error} nope 3 | * @returns {never} 4 | */ 5 | export function nope() { 6 | throw new Error('nope'); 7 | } 8 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/input/index.js: -------------------------------------------------------------------------------- 1 | import { foo as f, bar as b } from 'external'; 2 | 3 | export { f }; 4 | 5 | export function foo() {} 6 | -------------------------------------------------------------------------------- /test/samples/deconflict-priority/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {import('./a').Foo} foo 3 | * @param {import('./b').Bar} bar 4 | */ 5 | export function x(foo, bar) {} 6 | -------------------------------------------------------------------------------- /test/samples/export-from/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-from' { 2 | export const foo: "hello"; 3 | 4 | export {}; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/declare-module/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'declare-module' { 2 | export interface Foo {} 3 | 4 | export {}; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/import-all/input/index.ts: -------------------------------------------------------------------------------- 1 | import * as X from './namespace'; 2 | import * as Types from './type'; 3 | 4 | export type Y = X.Namespace.X; 5 | export type Z = Types.Z; 6 | -------------------------------------------------------------------------------- /test/samples/const-namespace/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/export-named-as/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/export-renamed/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-renamed' { 2 | export const answer: 42; 3 | 4 | export {}; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map 8 | -------------------------------------------------------------------------------- /test/samples/export-renamed/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/strip-internal/input/others.d.ts: -------------------------------------------------------------------------------- 1 | import { Internal } from './internal'; 2 | 3 | export interface Foo { 4 | bar: string; 5 | /** @internal */ 6 | baz: Internal; 7 | } 8 | -------------------------------------------------------------------------------- /test/samples/const-namespace/output 5.0/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/export-default-value/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-default-value' { 2 | export default 42; 3 | 4 | export {}; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map 8 | -------------------------------------------------------------------------------- /test/samples/export-default-value/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/export-type/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } 9 | -------------------------------------------------------------------------------- /test/samples/generics/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'generics' { 2 | export interface Foo { 3 | bar: T; 4 | } 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/namespace-exports/input/index.ts: -------------------------------------------------------------------------------- 1 | import { type Namespace, type NamespaceWithDeps } from './namespace'; 2 | 3 | export type X = Namespace.X; 4 | export { NamespaceWithDeps }; 5 | -------------------------------------------------------------------------------- /test/samples/export-type/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-type' { 2 | export type D = {}; 3 | export class B {} 4 | 5 | export {}; 6 | } 7 | 8 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/import-external-named-as/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/import-external-named/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [], 5 | "sources": [], 6 | "sourcesContent": [], 7 | "mappings": "" 8 | } -------------------------------------------------------------------------------- /test/samples/strip-internal/input/index.ts: -------------------------------------------------------------------------------- 1 | export { Foo } from './others'; 2 | 3 | /** @internal TS itself will take care of stripping this */ 4 | export interface TSdddd { 5 | foo: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /test/samples/const-namespace/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'const-namespace' { 2 | export namespace a { 3 | let x: number; 4 | } 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/jsdoc-import/input/vector.d.ts: -------------------------------------------------------------------------------- 1 | /** A vector with two components */ 2 | export interface Vector2 { 3 | /** The x component */ 4 | x: number; 5 | /** The y component */ 6 | y: number; 7 | } 8 | -------------------------------------------------------------------------------- /test/samples/strip-internal/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'strip-internal' { 2 | export interface Foo { 3 | bar: string; 4 | } 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/const-namespace/output 5.0/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'const-namespace' { 2 | export namespace a { 3 | const x: number; 4 | } 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-default-function/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-default-function' { 2 | export default function foo(): void; 3 | 4 | export {}; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/import-external-named/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'import-external-named' { 2 | import type { foo } from 'external'; 3 | 4 | export { foo }; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/path-config/input/nested/file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {import('#lib').Input} input 3 | * @returns {import('#lib').Output} 4 | */ 5 | export function foo_nested(input) { 6 | return input * 2; 7 | } 8 | -------------------------------------------------------------------------------- /test/samples/export-named-as/input/foo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two numbers 3 | * @param {number} a 4 | * @param {number} b 5 | * @returns {number} 6 | */ 7 | export function add(a, b) { 8 | return a + b; 9 | } 10 | -------------------------------------------------------------------------------- /test/samples/import-external-named-as/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'import-external-named-as' { 2 | import type { foo as f } from 'external'; 3 | 4 | export { f }; 5 | } 6 | 7 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/treeshaking-inline-import/input/vectors.d.ts: -------------------------------------------------------------------------------- 1 | /** A vector with two components */ 2 | export interface Vector2 { 3 | /** The x component */ 4 | x: number; 5 | /** The y component */ 6 | y: number; 7 | } 8 | -------------------------------------------------------------------------------- /test/samples/export-as-default/input/add.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two numbers 3 | * @param {number} a 4 | * @param {number} b 5 | * @returns {number} 6 | */ 7 | export function add(a, b) { 8 | return a + b; 9 | } 10 | -------------------------------------------------------------------------------- /test/samples/throws/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'throws' { 2 | /** 3 | * @throws {Error} nope 4 | * */ 5 | export function nope(): never; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/ambient-imports/output/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module 'ambient-imports' { 4 | export interface Foo {} 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/enum/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'enum' { 2 | export enum categories { 3 | ANIMAL = 0, 4 | VEGETABLE = 1, 5 | MINERAL = 2 6 | } 7 | 8 | export {}; 9 | } 10 | 11 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-default-as/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two numbers 3 | * @param {number} a 4 | * @param {number} b 5 | * @returns {number} 6 | */ 7 | export default function add(a, b) { 8 | return a + b; 9 | } 10 | -------------------------------------------------------------------------------- /test/samples/preserve-comments/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'preserve-comments' { 2 | /** 3 | * @deprecated 4 | */ 5 | export function a(): number; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | indent_style = tab 7 | indent_size = 2 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | 11 | [README.md] 12 | indent_style = space 13 | -------------------------------------------------------------------------------- /test/samples/overloads/input/index.ts: -------------------------------------------------------------------------------- 1 | interface Foo {} 2 | interface Bar {} 3 | 4 | export function baz(input: Foo): Foo; 5 | export function baz(input: Bar): Bar; 6 | 7 | export function baz(input: Foo | Bar) { 8 | return input; 9 | } 10 | -------------------------------------------------------------------------------- /test/samples/deconflict-priority/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'deconflict-priority' { 2 | export function x(foo: Foo, bar: Bar): void; 3 | interface Foo {} 4 | interface Bar {} 5 | 6 | export {}; 7 | } 8 | 9 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-declare-as-default/input/add.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two numbers 3 | * @param {number} a 4 | * @param {number} b 5 | * @returns {number} 6 | */ 7 | declare function add(a: number, b: number): number; 8 | 9 | export { add }; 10 | -------------------------------------------------------------------------------- /test/samples/import-external-default/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'import-external-default' { 2 | import type { default as x } from 'external'; 3 | export function foo(input: x): x; 4 | 5 | export {}; 6 | } 7 | 8 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-named-as/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-named-as' { 2 | /** 3 | * Add two numbers 4 | * */ 5 | export function plus(a: number, b: number): number; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-default-as/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-default-as' { 2 | /** 3 | * Add two numbers 4 | * */ 5 | export function add(a: number, b: number): number; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/export-from/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo" 6 | ], 7 | "sources": [ 8 | "../input/b.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";cAAaA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'import-external-named-as-conflict' { 2 | import type { foo as f } from 'external'; 3 | export function foo(): void; 4 | 5 | export { f }; 6 | } 7 | 8 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/preserved-jsdoc-tags/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two numbers 3 | * @deprecated 4 | * @example 5 | * const three = add(1, 2); 6 | * @param {number} a 7 | * @param {number} b 8 | */ 9 | export function add(a, b) { 10 | return a + b; 11 | } 12 | -------------------------------------------------------------------------------- /test/samples/generics/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Foo" 6 | ], 7 | "sources": [ 8 | "../input/index.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";kBAAiBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/throws/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "nope" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;iBAIgBA,IAAIA" 14 | } -------------------------------------------------------------------------------- /test/samples/enum/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "categories" 6 | ], 7 | "sources": [ 8 | "../input/index.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";aAAYA,UAAUA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/export-as-default/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-as-default' { 2 | /** 3 | * Add two numbers 4 | * */ 5 | export default function add(a: number, b: number): number; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map 11 | -------------------------------------------------------------------------------- /test/samples/shadowing/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "MyMap" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";OAAMA,KAAKA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/ambient-imports/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Foo" 6 | ], 7 | "sources": [ 8 | "../input/types.d.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;kBAEiBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/declare-module/input/types.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'x' { 2 | // to be honest i'm not entirely certain if this should be 3 | // included in the output or not. my inclination is not, 4 | // but i may change my mind 5 | interface X {} 6 | } 7 | 8 | export interface Foo {} 9 | -------------------------------------------------------------------------------- /test/samples/declare-module/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Foo" 6 | ], 7 | "sources": [ 8 | "../input/types.d.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";kBAOiBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/export-default-as/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;iBAMwBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/jsdoc-import/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;;;;iBAQgBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/preserve-comments/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "a" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;iBAGgBA,CAACA" 14 | } -------------------------------------------------------------------------------- /test/samples/strip-internal/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Foo" 6 | ], 7 | "sources": [ 8 | "../input/others.d.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";kBAEiBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "printWidth": 100, 6 | "overrides": [ 7 | { 8 | "files": ["README.md"], 9 | "options": { 10 | "useTabs": false, 11 | "tabWidth": 2 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/samples/export-as-default/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add" 6 | ], 7 | "sources": [ 8 | "../input/add.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;yBAMgBA,GAAGA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/export-declare-as-default/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'export-declare-as-default' { 2 | /** 3 | * Add two numbers 4 | * */ 5 | export default function add(a: number, b: number): number; 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map 11 | -------------------------------------------------------------------------------- /test/samples/export-default-function/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";yBAAwBA,GAAGA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/import-external-default/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo" 6 | ], 7 | "sources": [ 8 | "../input/index.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;iBAEgBA,GAAGA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/overloads/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'overloads' { 2 | interface Foo { 3 | } 4 | interface Bar { 5 | } 6 | export function baz(input: Foo): Foo; 7 | export function baz(input: Bar): Bar; 8 | 9 | export {}; 10 | } 11 | 12 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/preserved-jsdoc-tags/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;;;;iBAQgBA,GAAGA" 14 | } -------------------------------------------------------------------------------- /test/samples/export-declare-as-default/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add" 6 | ], 7 | "sources": [ 8 | "../input/add.d.ts" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;;;yBAMiBA,GAAGA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/ignores-missing-sourcemap-segments/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'ignores-missing-sourcemap-segments' { 2 | export function hello(): void; 3 | export namespace object { 4 | let answer: number; 5 | } 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'ignores-missing-sourcemap-segments' { 2 | export function hello(): void; 3 | export namespace object { 4 | const answer: number; 5 | } 6 | 7 | export {}; 8 | } 9 | 10 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/import-external-named-as-conflict/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo" 6 | ], 7 | "sources": [ 8 | "../input/index.js" 9 | ], 10 | "sourcesContent": [ 11 | null 12 | ], 13 | "mappings": ";;iBAIgBA,GAAGA" 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/no-renames/input/index.ts: -------------------------------------------------------------------------------- 1 | export { Y } from './type'; 2 | export { Namespace } from './namespace'; 3 | export type X = true; 4 | export function error(): void {} 5 | 6 | export interface Foo { 7 | get bar(): number; 8 | set bar(x: number); 9 | } 10 | export * from './function'; 11 | -------------------------------------------------------------------------------- /test/samples/import-all/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'import-all' { 2 | export type Y =Namespace.X; 3 | export type Z =Z_1; 4 | namespace Namespace { 5 | interface X { 6 | error(): string; 7 | } 8 | } 9 | type Z_1 = true; 10 | 11 | export {}; 12 | } 13 | 14 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /test/samples/treeshaking-inline-import/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two vectors 3 | * @param {import('./vectors').Vector2} a 4 | * @param {import('./vectors').Vector2} b 5 | * @returns {import('./vectors').Vector2} 6 | */ 7 | export function add(a, b) { 8 | return { 9 | x: a.x + b.x, 10 | y: a.y + b.y 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /test/samples/preserved-jsdoc-tags/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'preserved-jsdoc-tags' { 2 | /** 3 | * Add two numbers 4 | * @deprecated 5 | * @example 6 | * const three = add(1, 2); 7 | * */ 8 | export function add(a: number, b: number): number; 9 | 10 | export {}; 11 | } 12 | 13 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/basic/input/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add two vectors 3 | * @param {import('./types').Vector2} a the first vector 4 | * @param {import('./types').Vector2} b the second vector 5 | * @returns {import('./types').Vector2} 6 | */ 7 | export function add(a, b) { 8 | return { 9 | x: a.x + b.x, 10 | y: a.y + b.y 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /test/samples/overloads/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Foo", 6 | "Bar", 7 | "baz" 8 | ], 9 | "sources": [ 10 | "../input/index.ts" 11 | ], 12 | "sourcesContent": [ 13 | null 14 | ], 15 | "mappings": ";WAAUA,GAAGA;;WACHC,GAAGA;;iBAGGC,GAAGA;iBAAHA,GAAGA" 16 | } 17 | -------------------------------------------------------------------------------- /test/samples/jsdoc-import/input/index.js: -------------------------------------------------------------------------------- 1 | /** @import {Vector2} from './vector' */ 2 | 3 | /** 4 | * Add two vectors 5 | * @param {Vector2} a the first vector 6 | * @param {Vector2} b the second vector 7 | * @returns {Vector2} 8 | */ 9 | export function add(a, b) { 10 | return { 11 | x: a.x + b.x, 12 | y: a.y + b.y 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /test/samples/basic/input/vectors.d.ts: -------------------------------------------------------------------------------- 1 | /** A vector with two components */ 2 | export interface Vector2 { 3 | /** The x component */ 4 | x: number; 5 | /** The y component */ 6 | y: number; 7 | } 8 | 9 | /** A vector with three components */ 10 | export interface Vector3 extends Vector2 { 11 | /** The z component */ 12 | z: number; 13 | } 14 | -------------------------------------------------------------------------------- /test/samples/jsdoc-import/output ^5.5/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add", 6 | "Vector2" 7 | ], 8 | "sources": [ 9 | "../input/index.js", 10 | "../input/vector.d.ts" 11 | ], 12 | "sourcesContent": [ 13 | null, 14 | null 15 | ], 16 | "mappings": ";;;;;;iBAQgBA,GAAGA;;WCPFC,OAAOA" 17 | } -------------------------------------------------------------------------------- /test/samples/namespace-exports/input/namespace.ts: -------------------------------------------------------------------------------- 1 | import { Dependency } from './dependency'; 2 | 3 | export namespace Namespace { 4 | export interface X { 5 | x: string; 6 | } 7 | 8 | export interface Y { 9 | y: string; 10 | } 11 | } 12 | 13 | export namespace NamespaceWithDeps { 14 | export interface Z { 15 | z: Dependency; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/samples/treeshaking-inline-import/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "add", 6 | "Vector2" 7 | ], 8 | "sources": [ 9 | "../input/index.js", 10 | "../input/vectors.d.ts" 11 | ], 12 | "sourcesContent": [ 13 | null, 14 | null 15 | ], 16 | "mappings": ";;;;iBAMgBA,GAAGA;;WCLFC,OAAOA" 17 | } -------------------------------------------------------------------------------- /test/samples/ignores-missing-sourcemap-segments/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "hello", 6 | "object" 7 | ], 8 | "sources": [ 9 | "../input/index.js", 10 | "../input/index.d.ts" 11 | ], 12 | "sourcesContent": [ 13 | null, 14 | null 15 | ], 16 | "mappings": ";iBAIgBA,KAAKA;kBCHJC,MAAMA" 17 | } -------------------------------------------------------------------------------- /test/samples/jsdoc-import/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'jsdoc-import' { 2 | /** @import {Vector2} from './vector' */ 3 | /** 4 | * Add two vectors 5 | * @param a the first vector 6 | * @param b the second vector 7 | * */ 8 | export function add(a: Vector2, b: Vector2): Vector2; 9 | 10 | export {}; 11 | } 12 | 13 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "hello", 6 | "object" 7 | ], 8 | "sources": [ 9 | "../input/index.js", 10 | "../input/index.d.ts" 11 | ], 12 | "sourcesContent": [ 13 | null, 14 | null 15 | ], 16 | "mappings": ";iBAIgBA,KAAKA;kBCHJC,MAAMA" 17 | } -------------------------------------------------------------------------------- /test/samples/shadowing/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'shadowing' { 2 | class MyMap extends Map { 3 | constructor(); 4 | constructor(entries?: readonly (readonly [any, any])[]); 5 | constructor(); 6 | constructor(iterable?: Iterable); 7 | } 8 | 9 | export { MyMap as Map }; 10 | } 11 | 12 | //# sourceMappingURL=index.d.ts.map 13 | -------------------------------------------------------------------------------- /test/samples/deconflict-priority/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "x", 6 | "Foo", 7 | "Bar" 8 | ], 9 | "sources": [ 10 | "../input/index.js", 11 | "../input/a.d.ts", 12 | "../input/b.d.ts" 13 | ], 14 | "sourcesContent": [ 15 | null, 16 | null, 17 | null 18 | ], 19 | "mappings": ";iBAIgBA,CAACA;WCJAC,GAAGA;WCCHC,GAAGA" 20 | } -------------------------------------------------------------------------------- /test/samples/import-all/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Y", 6 | "Z", 7 | "Namespace" 8 | ], 9 | "sources": [ 10 | "../input/index.ts", 11 | "../input/type.ts", 12 | "../input/namespace.ts" 13 | ], 14 | "sourcesContent": [ 15 | null, 16 | null, 17 | null 18 | ], 19 | "mappings": ";aAGYA,CAACA;aCHDC,CAACA;WCAIC,SAASA" 20 | } -------------------------------------------------------------------------------- /test/samples/ts/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Vector2", 6 | "Vector3", 7 | "add", 8 | "multiply" 9 | ], 10 | "sources": [ 11 | "../input/index.ts", 12 | "../input/subpackage/multiply.ts" 13 | ], 14 | "sourcesContent": [ 15 | null, 16 | null 17 | ], 18 | "mappings": ";;kBACiBA,OAAOA;;;;;;;kBAQPC,OAAOA;;;;;;;iBAQRC,GAAGA;;;;;;;;;;iBCZHC,QAAQA" 19 | } -------------------------------------------------------------------------------- /test/samples/ts/input/subpackage/multiply.ts: -------------------------------------------------------------------------------- 1 | import type { Vector2 } from 'ts'; 2 | 3 | /** 4 | * Multiply two vectors 5 | */ 6 | export function multiply(a: Vector2, b: Vector2): Vector2 { 7 | return { 8 | x: multiply_numbers(a.x, b.x), 9 | y: multiply_numbers(a.y, b.y) 10 | }; 11 | } 12 | 13 | /** 14 | * Multiply two numbers 15 | */ 16 | function multiply_numbers(a: number, b: number) { 17 | return a * b; 18 | } 19 | -------------------------------------------------------------------------------- /test/samples/basic/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Vector2", 6 | "add", 7 | "multiply" 8 | ], 9 | "sources": [ 10 | "../input/vectors.d.ts", 11 | "../input/index.js", 12 | "../input/subpackage/multiply.js" 13 | ], 14 | "sourcesContent": [ 15 | null, 16 | null, 17 | null 18 | ], 19 | "mappings": ";;kBACiBA,OAAOA;;;;;;;;;;;iBCKRC,GAAGA;;;;;;;;;iBCAHC,QAAQA" 20 | } -------------------------------------------------------------------------------- /test/samples/treeshaking-inline-import/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'treeshaking-inline-import' { 2 | /** 3 | * Add two vectors 4 | * */ 5 | export function add(a: Vector2, b: Vector2): Vector2; 6 | /** A vector with two components */ 7 | interface Vector2 { 8 | /** The x component */ 9 | x: number; 10 | /** The y component */ 11 | y: number; 12 | } 13 | 14 | export {}; 15 | } 16 | 17 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "checkJs": true, 5 | "declaration": true, 6 | "declarationDir": "types", 7 | "declarationMap": true, 8 | "emitDeclarationOnly": true, 9 | "module": "esnext", 10 | "target": "esnext", 11 | "moduleResolution": "bundler", 12 | "paths": { 13 | "#lib": ["./samples/path-config/input/lib.d.ts"] 14 | } 15 | }, 16 | "exclude": ["**/actual/"] 17 | } 18 | -------------------------------------------------------------------------------- /test/samples/basic/output ^5.5/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "Vector2", 6 | "add", 7 | "multiply" 8 | ], 9 | "sources": [ 10 | "../input/vectors.d.ts", 11 | "../input/index.js", 12 | "../input/subpackage/multiply.js" 13 | ], 14 | "sourcesContent": [ 15 | null, 16 | null, 17 | null 18 | ], 19 | "mappings": ";;kBACiBA,OAAOA;;;;;;;;;;;iBCKRC,GAAGA;;;;;;;;;iBCAHC,QAAQA" 20 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "checkJs": true, 5 | "declaration": true, 6 | "declarationDir": "types", 7 | "declarationMap": true, 8 | "emitDeclarationOnly": true, 9 | "noUnusedLocals": true, 10 | "module": "esnext", 11 | "target": "esnext", 12 | "moduleResolution": "bundler", 13 | "skipLibCheck": true, 14 | "strict": true 15 | }, 16 | "include": ["src", "scripts", "test/test.js"] 17 | } 18 | -------------------------------------------------------------------------------- /test/samples/no-renames/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'no-renames' { 2 | export type X = true; 3 | export function error(): void; 4 | export interface Foo { 5 | get bar(): number; 6 | set bar(x: number); 7 | } 8 | export type Y = Namespace.X; 9 | export namespace Namespace { 10 | interface X { 11 | error(): string; 12 | } 13 | } 14 | export function bar(): void; 15 | 16 | export {}; 17 | } 18 | 19 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/namespace-exports/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'namespace-exports' { 2 | export type X = Namespace.X; 3 | namespace Namespace { 4 | interface X { 5 | x: string; 6 | } 7 | interface Y { 8 | y: string; 9 | } 10 | } 11 | export namespace NamespaceWithDeps { 12 | interface Z { 13 | z: Dependency; 14 | } 15 | } 16 | interface Dependency { 17 | name: string; 18 | } 19 | 20 | export {}; 21 | } 22 | 23 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/namespace-exports/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "X", 6 | "Namespace", 7 | "NamespaceWithDeps", 8 | "Dependency" 9 | ], 10 | "sources": [ 11 | "../input/index.ts", 12 | "../input/namespace.ts", 13 | "../input/dependency.ts" 14 | ], 15 | "sourcesContent": [ 16 | null, 17 | null, 18 | null 19 | ], 20 | "mappings": ";aAEYA,CAACA;WCAIC,SAASA;;;;;;;;kBAUTC,iBAAiBA;;;;;WCZjBC,UAAUA" 21 | } -------------------------------------------------------------------------------- /test/samples/jsdoc-import/output ^5.5/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'jsdoc-import' { 2 | /** 3 | * Add two vectors 4 | * @param a the first vector 5 | * @param b the second vector 6 | * */ 7 | export function add(a: Vector2, b: Vector2): Vector2; 8 | /** A vector with two components */ 9 | interface Vector2 { 10 | /** The x component */ 11 | x: number; 12 | /** The y component */ 13 | y: number; 14 | } 15 | 16 | export {}; 17 | } 18 | 19 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/path-config/output 5.0 - 5.1/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'path-config' { 2 | export function foo(input: Input): Output; 3 | export function overload(input: Input): Output; 4 | export function overload(input: string): Output; 5 | 6 | export function foo2(foo: Foo): void; 7 | export type Foo = { 8 | foo: Input; 9 | }; 10 | type Input = number; 11 | type Output = number; 12 | export function foo_nested(input: Input): Output; 13 | 14 | export {}; 15 | } 16 | 17 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/ts/input/index.ts: -------------------------------------------------------------------------------- 1 | /** A vector with two components */ 2 | export interface Vector2 { 3 | /** The x component */ 4 | x: number; 5 | /** The y component */ 6 | y: number; 7 | } 8 | 9 | /** A vector with three components */ 10 | export interface Vector3 extends Vector2 { 11 | /** The z component */ 12 | z: number; 13 | } 14 | 15 | /** 16 | * Add two vectors 17 | */ 18 | export function add(a: Vector2, b: Vector2): Vector2 { 19 | return { 20 | x: a.x + b.x, 21 | y: a.y + b.y 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /test/samples/path-config/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'path-config' { 2 | export function foo(input: Input): Output; 3 | 4 | export function overload(input: Input): Output; 5 | 6 | export function overload(input: string): Output; 7 | 8 | export function foo2(foo: Foo): void; 9 | export type Foo = { 10 | foo: Input; 11 | }; 12 | type Input = number; 13 | type Output = number; 14 | export function foo_nested(input: Input): Output; 15 | 16 | export {}; 17 | } 18 | 19 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/basic/input/subpackage/multiply.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Multiply two vectors 3 | * @param {import('basic').Vector2} a 4 | * @param {import('basic').Vector2} b 5 | * @returns {import('basic').Vector2} 6 | */ 7 | export function multiply(a, b) { 8 | return { 9 | x: multiply_numbers(a.x, b.x), 10 | y: multiply_numbers(a.y, b.y) 11 | }; 12 | } 13 | 14 | /** 15 | * Multiply two numbers 16 | * @param {number} a 17 | * @param {number} b 18 | */ 19 | function multiply_numbers(a, b) { 20 | return a * b; 21 | } 22 | -------------------------------------------------------------------------------- /test/samples/path-config/output 5.0 - 5.1/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo", 6 | "overload", 7 | "foo2", 8 | "Input", 9 | "Output", 10 | "foo_nested" 11 | ], 12 | "sources": [ 13 | "../input/index.js", 14 | "../input/lib.d.ts", 15 | "../input/nested/file.js" 16 | ], 17 | "sourcesContent": [ 18 | null, 19 | null, 20 | null 21 | ], 22 | "mappings": ";iBAMgBA,GAAGA;iBASfC,QAAQA;iBAARA,QAAQA;;iBAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;iBCGFC,UAAUA" 23 | } -------------------------------------------------------------------------------- /test/samples/path-config/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "foo", 6 | "overload", 7 | "foo2", 8 | "Input", 9 | "Output", 10 | "foo_nested" 11 | ], 12 | "sources": [ 13 | "../input/index.js", 14 | "../input/lib.d.ts", 15 | "../input/nested/file.js" 16 | ], 17 | "sourcesContent": [ 18 | null, 19 | null, 20 | null 21 | ], 22 | "mappings": ";iBAMgBA,GAAGA;;iBASfC,QAAQA;;iBAARA,QAAQA;;iBAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;iBCGFC,UAAUA" 23 | } 24 | -------------------------------------------------------------------------------- /test/samples/no-renames/output/index.d.ts.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "index.d.ts", 4 | "names": [ 5 | "X", 6 | "error", 7 | "Foo", 8 | "Y", 9 | "Namespace", 10 | "bar" 11 | ], 12 | "sources": [ 13 | "../input/index.ts", 14 | "../input/type.ts", 15 | "../input/namespace.ts", 16 | "../input/function.ts" 17 | ], 18 | "sourcesContent": [ 19 | null, 20 | null, 21 | null, 22 | null 23 | ], 24 | "mappings": ";aAEYA,CAACA;iBACGC,KAAKA;kBAEJC,GAAGA;;;;aCHRC,CAACA;kBCFIC,SAASA;;;;;iBCAVC,GAAGA" 25 | } -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /test/samples/basic/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'basic' { 2 | /** A vector with two components */ 3 | export interface Vector2 { 4 | /** The x component */ 5 | x: number; 6 | /** The y component */ 7 | y: number; 8 | } 9 | /** 10 | * Add two vectors 11 | * @param a the first vector 12 | * @param b the second vector 13 | * */ 14 | export function add(a: Vector2, b: Vector2): Vector2; 15 | 16 | export {}; 17 | } 18 | 19 | declare module 'basic/subpackage' { 20 | /** 21 | * Multiply two vectors 22 | * */ 23 | export function multiply(a: import('basic').Vector2, b: import('basic').Vector2): import('basic').Vector2; 24 | 25 | export {}; 26 | } 27 | 28 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/basic/output ^5.5/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'basic' { 2 | /** A vector with two components */ 3 | export interface Vector2 { 4 | /** The x component */ 5 | x: number; 6 | /** The y component */ 7 | y: number; 8 | } 9 | /** 10 | * Add two vectors 11 | * @param a the first vector 12 | * @param b the second vector 13 | * */ 14 | export function add(a: Vector2, b: Vector2): Vector2; 15 | 16 | export {}; 17 | } 18 | 19 | declare module 'basic/subpackage' { 20 | /** 21 | * Multiply two vectors 22 | * */ 23 | export function multiply(a: import("basic").Vector2, b: import("basic").Vector2): import("basic").Vector2; 24 | 25 | export {}; 26 | } 27 | 28 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/ts/output/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'ts' { 2 | /** A vector with two components */ 3 | export interface Vector2 { 4 | /** The x component */ 5 | x: number; 6 | /** The y component */ 7 | y: number; 8 | } 9 | /** A vector with three components */ 10 | export interface Vector3 extends Vector2 { 11 | /** The z component */ 12 | z: number; 13 | } 14 | /** 15 | * Add two vectors 16 | */ 17 | export function add(a: Vector2, b: Vector2): Vector2; 18 | 19 | export {}; 20 | } 21 | 22 | declare module 'ts/subpackage' { 23 | import type { Vector2 } from 'ts'; 24 | /** 25 | * Multiply two vectors 26 | */ 27 | export function multiply(a: Vector2, b: Vector2): Vector2; 28 | 29 | export {}; 30 | } 31 | 32 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /test/samples/path-config/input/index.js: -------------------------------------------------------------------------------- 1 | export { foo_nested } from './nested/file.js'; 2 | 3 | /** 4 | * @param {import('#lib').Input} input 5 | * @returns {import('#lib').Output} 6 | */ 7 | export function foo(input) { 8 | return input * 2; 9 | } 10 | 11 | /** 12 | * @overload 13 | * @param {import('#lib').Input} input 14 | * @returns {import('#lib').Output} 15 | * 16 | * @overload 17 | * @param {string} input 18 | * @returns {import('#lib').Output} 19 | * 20 | * @param {string | import('#lib').Input} input 21 | */ 22 | export function overload(input) { 23 | const input_num = typeof input === 'string' ? parseInt(input) : input; 24 | return input_num * 2; 25 | } 26 | 27 | /** 28 | * @typedef {Object} Foo 29 | * @property {import('#lib').Input} foo 30 | * @param {Foo} foo 31 | */ 32 | export function foo2(foo) {} 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 [these people](https://github.com/Rich-Harris/dts-buddy/graphs/contributors) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: {} 9 | jobs: 10 | release: 11 | # prevents this action from running on forks 12 | if: github.repository == 'Rich-Harris/dts-buddy' 13 | permissions: 14 | contents: write # to create release (changesets/action) 15 | id-token: write # OpenID Connect token needed for provenance 16 | pull-requests: write # to create pull request (changesets/action) 17 | name: Release 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout Repo 21 | uses: actions/checkout@v4 22 | with: 23 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits 24 | fetch-depth: 0 25 | - uses: pnpm/action-setup@v4 26 | - name: Setup Node.js 27 | uses: actions/setup-node@v4 28 | with: 29 | node-version: 24.x 30 | cache: pnpm 31 | 32 | - name: Install 33 | run: pnpm install --frozen-lockfile 34 | 35 | - name: Create Release Pull Request or Publish to npm 36 | id: changesets 37 | uses: changesets/action@v1 38 | with: 39 | publish: pnpm changeset:publish 40 | version: pnpm changeset:version 41 | env: 42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | NPM_CONFIG_PROVENANCE: true 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dts-buddy", 3 | "version": "0.6.2", 4 | "description": "A tool for creating .d.ts bundles", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/Rich-Harris/dts-buddy" 8 | }, 9 | "license": "MIT", 10 | "type": "module", 11 | "dependencies": { 12 | "@jridgewell/source-map": "^0.3.5", 13 | "@jridgewell/sourcemap-codec": "^1.4.15", 14 | "kleur": "^4.1.5", 15 | "locate-character": "^3.0.0", 16 | "magic-string": "^0.30.4", 17 | "sade": "^1.8.1", 18 | "tinyglobby": "^0.2.10", 19 | "ts-api-utils": "^1.0.3" 20 | }, 21 | "peerDependencies": { 22 | "typescript": ">=5.0.4 <5.9" 23 | }, 24 | "devDependencies": { 25 | "@changesets/cli": "^2.28.1", 26 | "@types/node": "^20.7.2", 27 | "@types/semver": "^7.5.3", 28 | "prettier": "^3.0.3", 29 | "semver": "^7.5.4", 30 | "typescript": "~5.8.3", 31 | "uvu": "^0.5.6" 32 | }, 33 | "scripts": { 34 | "changeset:version": "changeset version", 35 | "changeset:publish": "changeset publish", 36 | "prepublishOnly": "node src/cli.js --debug debug && tsc types/index.d.ts --esModuleInterop", 37 | "test": "node test/test.js", 38 | "check": "tsc --noEmit --emitDeclarationOnly false", 39 | "lint": "prettier --ignore-path .gitignore --ignore-path .prettierignore --cache --check .", 40 | "format": "pnpm lint --write" 41 | }, 42 | "exports": { 43 | ".": { 44 | "types": "./types/index.d.ts", 45 | "import": "./src/index.js" 46 | } 47 | }, 48 | "types": "./types/index.d.ts", 49 | "files": [ 50 | "src", 51 | "types" 52 | ], 53 | "bin": "./src/cli.js", 54 | "packageManager": "pnpm@9.4.0" 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | # cancel in-progress runs on new commits to same PR (gitub.event.number) 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | Checks: 16 | runs-on: ubuntu-latest 17 | timeout-minutes: 5 18 | steps: 19 | - run: git config --global core.autocrlf false 20 | - uses: actions/checkout@v4 21 | - uses: pnpm/action-setup@v4 22 | - uses: actions/setup-node@v3 23 | with: 24 | node-version: 18 25 | cache: pnpm 26 | - run: pnpm install --frozen-lockfile 27 | - name: lint 28 | run: pnpm lint 29 | - name: check 30 | if: ${{ !cancelled() }} # allows checks to run if one fails so we can put them all in the same job 31 | run: pnpm check 32 | Tests: 33 | runs-on: ${{ matrix.os }} 34 | timeout-minutes: 10 35 | strategy: 36 | fail-fast: false 37 | matrix: 38 | node: [20, 22] 39 | os: [ubuntu-latest] 40 | typescript: ['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8'] 41 | include: 42 | - node: 18 43 | os: ubuntu-latest 44 | typescript: '5.0' 45 | - node: 18 46 | os: windows-latest 47 | typescript: '5.0' 48 | - node: 22 49 | os: windows-latest 50 | typescript: '5.7' 51 | steps: 52 | - run: git config --global core.autocrlf false 53 | - uses: actions/checkout@v4 54 | - uses: pnpm/action-setup@v4 55 | - uses: actions/setup-node@v3 56 | with: 57 | node-version: ${{ matrix.node }} 58 | cache: pnpm 59 | - run: pnpm install --frozen-lockfile 60 | - run: pnpm update typescript@~${{ matrix.typescript }} 61 | - name: test 62 | run: pnpm test 63 | -------------------------------------------------------------------------------- /src/types.d.ts: -------------------------------------------------------------------------------- 1 | import { SourceMapMappings } from '@jridgewell/sourcemap-codec'; 2 | import { Location } from 'locate-character'; 3 | import { SourceFile } from 'typescript'; 4 | 5 | interface Reference { 6 | module: string; 7 | name: string; 8 | } 9 | 10 | interface Declaration { 11 | module: string; 12 | name: string; 13 | alias: string; 14 | /** 15 | * Whether this declaration should have an `export` modifier in the output 16 | */ 17 | export: boolean; 18 | /** 19 | * Whether this declaration should have a `default` modifier in the output 20 | */ 21 | default: boolean; 22 | external: boolean; 23 | included: boolean; 24 | dependencies: Reference[]; 25 | /** 26 | * The name we'd like to use to refer to this binding. 27 | * Only applies to default imports from external modules 28 | */ 29 | preferred_alias: string; 30 | } 31 | 32 | interface Binding { 33 | id: string; 34 | external: boolean; 35 | name: string; 36 | } 37 | 38 | interface ModuleReference { 39 | id: string; 40 | external: boolean; 41 | } 42 | 43 | interface Module { 44 | file: string; 45 | dts: string; 46 | ast: SourceFile; 47 | locator: (pos: number) => Location | undefined; 48 | source: null | { 49 | code: string; 50 | map: any; // TODO 51 | mappings: SourceMapMappings; 52 | }; 53 | dependencies: string[]; 54 | globals: string[]; 55 | references: Set; 56 | declarations: Map; 57 | imports: Map; 58 | import_all: Map; 59 | export_from: Map; 60 | export_all: ModuleReference[]; 61 | ambient_imports: ModuleReference[]; 62 | 63 | /** A map of exports */ 64 | exports: Map; 65 | } 66 | 67 | interface Namespace { 68 | declarations: Map; 69 | references: Set; 70 | exports: Map; 71 | } 72 | 73 | interface Mapping { 74 | source: string; 75 | line: number; 76 | column: number; 77 | } 78 | 79 | export { Binding, Declaration, Mapping, Module, ModuleReference, Namespace }; 80 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import { globSync } from 'tinyglobby'; 3 | import { test } from 'uvu'; 4 | import * as assert from 'uvu/assert'; 5 | import { createBundle } from '../src/index.js'; 6 | import * as semver from 'semver'; 7 | import ts from 'typescript'; 8 | 9 | const filter = process.argv[2]; 10 | 11 | for (const sample of fs.readdirSync('test/samples')) { 12 | if (filter && !sample.includes(filter)) continue; 13 | if (sample.startsWith('.')) continue; 14 | 15 | test(sample, async () => { 16 | const dir = `test/samples/${sample}`; 17 | 18 | /** @type {Record} */ 19 | const modules = {}; 20 | 21 | const compilerOptions = { 22 | /** @type {Record} */ 23 | paths: {}, 24 | ...(fs.existsSync(`${dir}/options.json`) 25 | ? JSON.parse(fs.readFileSync(`${dir}/options.json`, 'utf-8')) 26 | : {}) 27 | }; 28 | 29 | for (const file of globSync('**', { cwd: `${dir}/input`, onlyFiles: true })) { 30 | const parts = file.split(/[\/\\]/); 31 | const basename = parts.pop(); 32 | 33 | if (basename === 'index.js' || basename === 'index.ts' || basename === 'types.d.ts') { 34 | const name = [sample, ...parts].join('/'); 35 | modules[name] = `${dir}/input/${file}`; 36 | compilerOptions.paths[name] = [`./samples/${sample}/input/${file}`]; 37 | } 38 | } 39 | 40 | fs.rmSync(`${dir}/actual`, { recursive: true, force: true }); 41 | fs.rmSync(`${dir}/debug`, { recursive: true, force: true }); 42 | 43 | await createBundle({ 44 | project: 'test/tsconfig.json', 45 | modules, 46 | output: `${dir}/actual/index.d.ts`, 47 | debug: `${dir}/debug`, 48 | include: [`samples/${sample}/input`], 49 | compilerOptions 50 | }); 51 | 52 | let output_dir = 'output'; 53 | for (const candidate of fs.readdirSync(dir)) { 54 | if (!candidate.startsWith('output ')) continue; 55 | const range = candidate.slice(7); 56 | 57 | if (semver.satisfies(ts.version.split('-')[0], range)) { 58 | output_dir = candidate; 59 | break; 60 | } 61 | } 62 | 63 | const actual = globSync('**', { cwd: `${dir}/actual`, onlyFiles: true }).sort(); 64 | const output = globSync('**', { cwd: `${dir}/${output_dir}`, onlyFiles: true }).sort(); 65 | 66 | assert.equal(actual, output); 67 | 68 | for (const file of actual) { 69 | assert.equal( 70 | fs.readFileSync(`${dir}/actual/${file}`, 'utf-8').trim(), 71 | fs.readFileSync(`${dir}/${output_dir}/${file}`, 'utf-8').trim(), 72 | file 73 | ); 74 | } 75 | }); 76 | } 77 | 78 | test.run(); 79 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import fs from 'node:fs'; 3 | import path from 'node:path'; 4 | import sade from 'sade'; 5 | import c from 'kleur'; 6 | import { createBundle } from './index.js'; 7 | 8 | const dts_buddy_pkg = JSON.parse( 9 | fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8') 10 | ); 11 | 12 | /** @param {string} message */ 13 | function exit(message) { 14 | console.error(c.bold().red(message)); 15 | process.exit(1); 16 | } 17 | 18 | /** @param {string} message */ 19 | function warn(message) { 20 | console.error(c.bold().yellow(message)); 21 | } 22 | 23 | const program = sade('dts-buddy [bundle]', true) 24 | .version(dts_buddy_pkg.version) 25 | .option('--project, -p', 'The location of your TypeScript configuration', 'tsconfig.json') 26 | .option('--module, -m', 'Each entry point, as : (can be used multiple times)') 27 | .option('--debug', 'Directory to emit .d.ts files for debugging') 28 | .action(async (output, opts) => { 29 | if (!fs.existsSync('package.json')) { 30 | exit('No package.json found'); 31 | } 32 | 33 | const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); 34 | if (!output) output = pkg.types ?? 'index.d.ts'; 35 | 36 | /** @type {Record} */ 37 | const modules = {}; 38 | 39 | if (opts.module) { 40 | const entries = Array.isArray(opts.module) ? opts.module : [opts.module]; 41 | for (const entry of entries) { 42 | const [id, path] = entry.split(':'); 43 | if (!id || !path) { 44 | exit(`Invalid module entry: ${entry}`); 45 | } 46 | modules[id] = path; 47 | } 48 | } else { 49 | if (!pkg.exports) { 50 | exit('No "exports" field in package.json'); 51 | } 52 | 53 | for (const [key, value] of Object.entries(pkg.exports)) { 54 | if (key[0] !== '.') continue; 55 | 56 | const entry = value.import ?? value.default; 57 | if (typeof entry === 'string') { 58 | modules[pkg.name + key.slice(1)] = entry; 59 | } else { 60 | warn(`Skipping pkg.exports["${key}"] — expected an "import" or "default" string`); 61 | } 62 | } 63 | 64 | if (Object.keys(modules).length === 0) { 65 | if (typeof pkg.exports === 'string') { 66 | modules[pkg.name] = pkg.exports; 67 | } else if (pkg.exports['import'] || pkg.exports['default']) { 68 | modules[pkg.name] = pkg.exports['import'] ?? pkg.exports['default']; 69 | } else { 70 | exit('No entry points found in pkg.exports'); 71 | } 72 | } 73 | } 74 | 75 | await createBundle({ 76 | output, 77 | modules, 78 | project: opts.project, 79 | debug: opts.debug 80 | }); 81 | 82 | const relative = path.relative(process.cwd(), output); 83 | console.error(`Wrote ${c.bold().cyan(relative)} and ${c.bold().cyan(relative + '.map')}\n`); 84 | }); 85 | 86 | program.parse(process.argv); 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dts-buddy 2 | 3 | A tool for creating `.d.ts` bundles. 4 | 5 | ## Why? 6 | 7 | If you're creating a package with subpackages (i.e. you can import from `my-lib` but also `my-lib/subpackage`), correctly exposing types to your users in a way that works everywhere is [difficult difficult lemon difficult](https://www.youtube.com/watch?v=7mAFiPVs3tM). 8 | 9 | The TypeScript team recommends a [variety of strategies](https://github.com/andrewbranch/example-subpath-exports-ts-compat/tree/main) but they all involve adding a bunch of otherwise useless files to your package. 10 | 11 | One thing that works everywhere is `declare module` — if you expose a file like this... 12 | 13 | ```ts 14 | declare module 'my-lib' { 15 | /** 16 | * Add two numbers 17 | */ 18 | export function add(a: number, b: number): number; 19 | } 20 | 21 | declare module 'my-lib/subpackage' { 22 | /** 23 | * Multiply two numbers 24 | */ 25 | export function multiply(a: number, b: number): number; 26 | } 27 | ``` 28 | 29 | ...then everyone will get autocompletion and typechecking for those functions. For bonus points, it should include a `.d.ts.map` file that allows 'go to definition' to take you to the original source. (This rules out hand-authoring the file, which you shouldn't be doing anyway.) 30 | 31 | There are other benefits to this approach — you end up with smaller packages, and TypeScript has less work to do on startup, making everything quicker for your users. 32 | 33 | Unfortunately, I couldn't find a tool for generating `.d.ts` bundles, at least not one that worked. `dts-buddy` aims to fill the gap. 34 | 35 | ## But really, why? 36 | 37 | For [SvelteKit](https://kit.svelte.dev), where for a long time we hand-authored an `ambient.d.ts` file containing `declare module` blocks for subpackages, and _also_ had an `index.d.ts` file for the main types that had to duplicate the definitions of certain functions. Every time we changed anything, we had to update things in multiple places, and contributing to the codebase was unnecessarily difficult. 38 | 39 | An extra dimension is that we have virtual modules like `$app/environment`, which can't be expressed using any of the techniques suggested by the TypeScript team. 40 | 41 | `dts-buddy` means we can automate generation of all our type definitions, using the source as the, well, source of truth. 42 | 43 | ## How do I use it? 44 | 45 | Pick a place to write your `.d.ts` file to — e.g. `types/index.d.ts` — then add it to your `package.json` both as the top-level `types` property and the `types` value of each entry in your `exports` map. Add a `prepublishOnly` step to your `scripts`: 46 | 47 | ```diff 48 | { 49 | "name": "my-lib", 50 | "version": "1.0.0", 51 | "type": "module", 52 | + "types": "./types/index.d.ts", 53 | "files": [ 54 | "src", 55 | + "types" 56 | ], 57 | "exports": { 58 | ".": { 59 | + "types": "./types/index.d.ts", 60 | "import": "./src/index.js" 61 | }, 62 | "./subpackage": { 63 | + "types": "./types/index.d.ts", 64 | "import": "./src/subpackage.js" 65 | } 66 | }, 67 | "scripts": { 68 | + "prepublishOnly": "dts-buddy" 69 | } 70 | } 71 | ``` 72 | 73 | `dts-buddy` will infer the entry points and the output location from your `package.json`. 74 | 75 | In some cases you may need to specify the entry points and output location manually (for example, you want to use a `.d.ts` file that re-exports from your `.js` file as an entry point), in which case: 76 | 77 | ``` 78 | dts-buddy types/index.d.ts -m my-lib:src/index.js -m my-lib/subpackage:src/subpackage.js 79 | ``` 80 | 81 | You can also use the JavaScript API directly: 82 | 83 | ```js 84 | // scripts/generate-dts-bundle.js 85 | import { createBundle } from 'dts-buddy'; 86 | 87 | await createBundle({ 88 | project: 'tsconfig.json', 89 | output: 'types/index.d.ts', 90 | modules: { 91 | 'my-lib': 'src/index.js', 92 | 'my-lib/subpackage': 'src/subpackage.js' 93 | } 94 | }); 95 | ``` 96 | 97 | Note that the result will also be treeshaken — your .d.ts bundle will only include public types. 98 | 99 | ## Any other benefits over using `tsc`? 100 | 101 | In large codebases, it's convenient to use the `"paths"` option in your `tsconfig.json` so that you can do things like this... 102 | 103 | ```js 104 | /** @type {import('#types').Thing} */ 105 | let thing = { ... }; 106 | ``` 107 | 108 | ...instead of this: 109 | 110 | ```js 111 | /** @type {import('../../../../../types.d.ts').Thing} */ 112 | let thing = { ... }; 113 | ``` 114 | 115 | Unfortunately, `tsc` ignores `"paths"` when emitting declaration files ([docs](https://www.typescriptlang.org/tsconfig/#paths)), which breaks stuff. `dts-buddy` fixes it. 116 | 117 | ## License 118 | 119 | MIT 120 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # dts-buddy changelog 2 | 3 | ## 0.6.2 4 | 5 | ### Patch Changes 6 | 7 | - dd96e67: fix: don't treat accessors as references 8 | 9 | ## 0.6.1 10 | 11 | ### Patch Changes 12 | 13 | - 25f4f9c: fix: follow directory imports 14 | - f372987: feat: support TypeScript 5.8 15 | 16 | ## 0.6.0 17 | 18 | ### Minor Changes 19 | 20 | - 87276ef: feat: support `export { ... as default } from ...` 21 | 22 | ### Patch Changes 23 | 24 | - 87276ef: fix: improve sourcemaps 25 | 26 | ## 0.5.5 27 | 28 | ### Patch Changes 29 | 30 | - f50918d: feat: upgrade to tinyglobby 31 | 32 | ## 0.5.4 33 | 34 | - Support TypeScript 5.6 and 5.7 ([#91](https://github.com/Rich-Harris/dts-buddy/pull/91)) 35 | 36 | ## 0.5.3 37 | 38 | - Support `import * as X` imports ([#89](https://github.com/Rich-Harris/dts-buddy/pull/89)) 39 | - Fix deduplication logic to rename exports in fewer cases ([#89](https://github.com/Rich-Harris/dts-buddy/pull/89)) 40 | - Recognize import dependencies within namespaces ([#89](https://github.com/Rich-Harris/dts-buddy/pull/89)) 41 | 42 | ## 0.5.2 43 | 44 | - Support stripping internal types using `@internal` JSDoc tags ([#87](https://github.com/Rich-Harris/dts-buddy/pull/87)) 45 | 46 | ## 0.5.1 47 | 48 | - Use more TypeScript-friendly way of preventing unintended exports ([#85](https://github.com/Rich-Harris/dts-buddy/pull/85)) 49 | 50 | ## 0.5.0 51 | 52 | - Prevent unintended exports ([#82](https://github.com/Rich-Harris/dts-buddy/pull/82)) 53 | 54 | ## 0.4.7 55 | 56 | - Preserve renamed exports ([#78](https://github.com/Rich-Harris/dts-buddy/pull/78)) 57 | - Avoid conflicts with globals ([#78](https://github.com/Rich-Harris/dts-buddy/pull/78)) 58 | 59 | ## 0.4.6 60 | 61 | - Handle namespaces ([#77](https://github.com/Rich-Harris/dts-buddy/pull/77)) 62 | 63 | ## 0.4.5 64 | 65 | - Support TypeScript 5.4 ([#76](https://github.com/Rich-Harris/dts-buddy/pull/76)) 66 | 67 | ## 0.4.4 68 | 69 | - Handle `.jsx` and `.tsx` ([#72](https://github.com/Rich-Harris/dts-buddy/pull/72)) 70 | - Allow `paths` to be nulled out ([#73](https://github.com/Rich-Harris/dts-buddy/pull/73)) 71 | - Handle overloads ([#74](https://github.com/Rich-Harris/dts-buddy/pull/74)) 72 | 73 | ## 0.4.3 74 | 75 | - Fix path resolution on Windows ([#71](https://github.com/Rich-Harris/dts-buddy/pull/71)) 76 | 77 | ## 0.4.2 78 | 79 | - Support path rewriting in `typedef`, `overload` and `callback` tags ([#68](https://github.com/Rich-Harris/dts-buddy/pull/68)) 80 | - Preserve type expressions in JSDoc annotations ([#69](https://github.com/Rich-Harris/dts-buddy/pull/69)) 81 | 82 | ## 0.4.1 83 | 84 | - Support TypeScript 5.3 ([#67](https://github.com/Rich-Harris/dts-buddy/pull/67)) 85 | 86 | ## 0.4.0 87 | 88 | - Replace path aliases ([#65](https://github.com/Rich-Harris/dts-buddy/pull/65)) 89 | 90 | ## 0.3.0 91 | 92 | - Make `typescript` a peer dependency ([#58](https://github.com/Rich-Harris/dts-buddy/pull/58)) 93 | 94 | ## 0.2.5 95 | 96 | - Handle enum declarations ([#57](https://github.com/Rich-Harris/dts-buddy/pull/57)) 97 | 98 | ## 0.2.4 99 | 100 | - Rename external imports as necessary ([#54](https://github.com/Rich-Harris/dts-buddy/pull/54)) 101 | 102 | ## 0.2.3 103 | 104 | - Ignore missing sourcemap segments ([#51](https://github.com/Rich-Harris/dts-buddy/pull/51)) 105 | 106 | ## 0.2.2 107 | 108 | - Correctly re-export declarations regardless of inclusion order ([#49](https://github.com/Rich-Harris/dts-buddy/pull/49)) 109 | 110 | ## 0.2.1 111 | 112 | - Include all project files by default ([#48](https://github.com/Rich-Harris/dts-buddy/pull/48)) 113 | 114 | ## 0.2.0 115 | 116 | - Use TypeScript to parse config, rather than `eval` ([#36](https://github.com/Rich-Harris/dts-buddy/pull/36)) 117 | 118 | ## 0.1.14 119 | 120 | - Improve error message when encountering unknown node types ([#39](https://github.com/Rich-Harris/dts-buddy/pull/39)) 121 | - Add license info ([#38](https://github.com/Rich-Harris/dts-buddy/pull/38)) 122 | 123 | ## 0.1.13 124 | 125 | - Allow `modules` to be specified via the CLI ([#35](https://github.com/Rich-Harris/dts-buddy/pull/35)) 126 | 127 | ## 0.1.12 128 | 129 | - Remove `declare module` blocks ([#33](https://github.com/Rich-Harris/dts-buddy/pull/33)) 130 | 131 | ## 0.1.11 132 | 133 | - Handle default exports ([#32](https://github.com/Rich-Harris/dts-buddy/pull/32)) 134 | 135 | ## 0.1.10 136 | 137 | - Override `lib` option ([#31](https://github.com/Rich-Harris/dts-buddy/pull/31)) 138 | 139 | ## 0.1.9 140 | 141 | - Use reference directives for external ambient imports ([#29](https://github.com/Rich-Harris/dts-buddy/pull/29)) 142 | 143 | ## 0.1.8 144 | 145 | - Include external ambient imports ([#27](https://github.com/Rich-Harris/dts-buddy/pull/27)) 146 | 147 | ## 0.1.7 148 | 149 | - Bump `locate-character` dependency 150 | 151 | ## 0.1.6 152 | 153 | - Preserve descriptions in JSDoc comments, remove brackets from parameters 154 | 155 | ## 0.1.5 156 | 157 | - Always preserve JSDoc comments with `@default`, `@deprecated` and `@example` tags 158 | 159 | ## 0.1.4 160 | 161 | - Prevent unnecessary `_1` suffixes 162 | 163 | ## 0.1.3 164 | 165 | - Preserve `@deprecated` tags 166 | - More forgiving `pkg.exports` parsing in CLI 167 | - Use `ts-api-utils` instead of brittle `node.kind` checks 168 | 169 | ## 0.1.2 170 | 171 | - Work on Windows 172 | 173 | ## 0.1.1 174 | 175 | - Ensure inline dependencies are correctly marked 176 | 177 | ## 0.1.0 178 | 179 | - Treeshaking 180 | - Robust renaming 181 | 182 | ## 0.0.10 183 | 184 | - Ignore `outDir` setting 185 | 186 | ## 0.0.9 187 | 188 | - Warn instead of failing on invalid `pkg.exports` entries 189 | 190 | ## 0.0.8 191 | 192 | - Preserve `@example` and `@default` tags 193 | 194 | ## 0.0.7 195 | 196 | - Include `types` in `pkg.files` 197 | 198 | ## 0.0.6 199 | 200 | - Tidier output 201 | 202 | ## 0.0.5 203 | 204 | - Remove unwanted `declare` keywords from `.d.ts` output 205 | 206 | ## 0.0.4 207 | 208 | - Add a CLI 209 | 210 | ## 0.0.3 211 | 212 | - Generate declaration maps 213 | 214 | ## 0.0.2 215 | 216 | - Only export things that are exported 217 | 218 | ## 0.0.1 219 | 220 | - First release 221 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import path from 'node:path'; 3 | import ts from 'typescript'; 4 | import MagicString from 'magic-string'; 5 | import { getLocator } from 'locate-character'; 6 | import { SourceMapGenerator } from '@jridgewell/source-map'; 7 | import { 8 | clean_jsdoc, 9 | get_input_files, 10 | get_jsdoc_imports, 11 | is_declaration, 12 | parse_tsconfig, 13 | resolve_dts, 14 | walk, 15 | write 16 | } from './utils.js'; 17 | import { create_module_declaration } from './create-module-declaration.js'; 18 | 19 | /** 20 | * @param {{ 21 | * output: string; 22 | * modules: Record; 23 | * project?: string; 24 | * compilerOptions?: ts.CompilerOptions; 25 | * include?: string[]; 26 | * exclude?: string[]; 27 | * debug?: string; 28 | * }} options 29 | * @returns {Promise} 30 | */ 31 | export async function createBundle(options) { 32 | const project = options.project ?? 'tsconfig.json'; 33 | const output = path.resolve(options.output); 34 | const debug = options.debug && path.resolve(options.debug); 35 | 36 | /** @type {Record} */ 37 | const modules = {}; 38 | for (const id in options.modules) { 39 | modules[id] = path.resolve(options.modules[id]).replace(/(\.d\.ts|\.js|\.ts)$/, '.d.ts'); 40 | } 41 | 42 | const cwd = path.resolve(path.dirname(project)); 43 | const tsconfig = parse_tsconfig(project); 44 | 45 | const input = get_input_files( 46 | cwd, 47 | options.include ?? tsconfig.include ?? ['**'], 48 | options.exclude ?? tsconfig.exclude ?? [] 49 | ); 50 | 51 | const original_cwd = process.cwd(); 52 | process.chdir(cwd); 53 | 54 | try { 55 | const baseUrl = 56 | tsconfig.compilerOptions?.baseUrl ?? options.compilerOptions?.baseUrl 57 | ? path.resolve(original_cwd, options.compilerOptions?.baseUrl ?? '.') 58 | : cwd; 59 | 60 | const paths = { 61 | ...tsconfig.compilerOptions?.paths, 62 | ...options.compilerOptions?.paths 63 | }; 64 | 65 | /** @type {ts.CompilerOptions} */ 66 | const compilerOptions = { 67 | ...tsconfig.compilerOptions, 68 | ...options.compilerOptions, 69 | baseUrl, 70 | allowJs: true, 71 | checkJs: true, 72 | declaration: true, 73 | declarationDir: undefined, 74 | declarationMap: true, 75 | emitDeclarationOnly: true, 76 | lib: undefined, 77 | noEmit: false, 78 | noEmitOnError: false, 79 | outDir: undefined, 80 | paths 81 | }; 82 | 83 | for (const key in paths) { 84 | paths[key] = paths[key].map((p) => path.resolve(baseUrl, p)); 85 | } 86 | 87 | // if `compilerOptions.paths` is used, we need to update the source before TypeScript sees it, 88 | // otherwise the unresolved aliases will be present in the output 89 | const paths_to_replace = Object.keys(paths).filter((key) => !(key in modules)); 90 | 91 | const paths_regex = new RegExp( 92 | `(['"])(${paths_to_replace 93 | .map((path) => path.replace(/[-[\]{}()+?.,\\^$|#\s]/g, '\\$&').replace(/\*/g, '(.+)')) 94 | .join('|')})\\1` 95 | ); 96 | 97 | /** @type {Record} */ 98 | const created = {}; 99 | const host = ts.createCompilerHost(compilerOptions); 100 | host.writeFile = (file, contents) => (created[file.replace(/\//g, path.sep)] = contents); 101 | host.readFile = (file) => { 102 | file = file.replace(/\//g, path.sep); 103 | 104 | const contents = fs.readFileSync(file, 'utf-8'); 105 | 106 | if (!input.includes(file)) return contents; 107 | if (!paths_regex.test(contents)) return contents; 108 | 109 | const code = new MagicString(contents); 110 | const ast = ts.createSourceFile( 111 | file, 112 | contents, 113 | ts.ScriptTarget.Latest, 114 | false, 115 | ts.ScriptKind.TS 116 | ); 117 | 118 | /** @param {import('typescript').Node} node */ 119 | function replace_path(node) { 120 | const imported = node.getText(ast); 121 | const match = paths_regex.exec(imported); 122 | 123 | if (!match) return; 124 | 125 | const replacements = paths[match[2]]; 126 | const substitution = match[3]; 127 | 128 | /** @type {string | null} */ 129 | let replacement = null; 130 | 131 | for (const candidate of replacements) { 132 | const substituted = candidate.replace('*', substitution); 133 | 134 | if (input.includes(substituted)) { 135 | replacement = substituted; 136 | break; 137 | } 138 | 139 | const extensionless = substituted.replace(/\.((d\.)?ts|js)$/, ''); 140 | for (const extension of ['.d.ts', '.ts', '.js']) { 141 | if (input.includes(extensionless + extension)) { 142 | replacement = extensionless + extension; 143 | break; 144 | } 145 | } 146 | } 147 | 148 | if (replacement) { 149 | let relative = path.relative(path.dirname(file), replacement).replaceAll('\\', '/'); 150 | if (relative[0] !== '.') relative = `./${relative}`; 151 | 152 | code.overwrite(node.pos, node.end, `${match[1]}${relative}${match[1]}`); 153 | } 154 | } 155 | 156 | ts.forEachChild(ast, (node) => { 157 | walk(node, (node) => { 158 | if (ts.isImportDeclaration(node)) { 159 | replace_path(node.moduleSpecifier); 160 | } 161 | 162 | if (ts.isExportDeclaration(node) && node.moduleSpecifier) { 163 | replace_path(node.moduleSpecifier); 164 | } 165 | 166 | for (const source of get_jsdoc_imports(node)) { 167 | replace_path(source); 168 | } 169 | }); 170 | }); 171 | 172 | return code.toString(); 173 | }; 174 | 175 | const program = ts.createProgram(input, compilerOptions, host); 176 | program.emit(); 177 | 178 | if (debug) { 179 | for (const file in created) { 180 | const relative = path.relative(cwd, file); 181 | const dest = path.join(debug, relative); 182 | write(dest, created[file]); 183 | } 184 | 185 | for (const file of input) { 186 | if (!file.endsWith('.d.ts')) continue; 187 | const relative = path.relative(cwd, file); 188 | const dest = path.join(debug, relative); 189 | write(dest, fs.readFileSync(file, 'utf-8')); 190 | } 191 | } 192 | 193 | let types = ''; 194 | 195 | /** @type {Map>} */ 196 | const all_mappings = new Map(); 197 | 198 | /** @type {Set} */ 199 | const ambient_modules = new Set(); 200 | 201 | /** @type {Set} */ 202 | const external_ambient_modules = new Set(); 203 | 204 | let first = true; 205 | 206 | /** 207 | * @param {string} file 208 | * @param {string} specifier 209 | * @returns {string | null} 210 | */ 211 | function resolve(file, specifier) { 212 | // if a module imports from another module we're declaring, 213 | // leave the import intact 214 | if (specifier in modules) { 215 | return null; 216 | } 217 | 218 | // resolve relative imports and aliases (from tsconfig.paths) 219 | return specifier.startsWith('.') 220 | ? resolve_dts(path.dirname(file), specifier) 221 | : compilerOptions.paths?.[specifier]?.[0] ?? null; 222 | } 223 | 224 | for (const id in modules) { 225 | if (!first) types += '\n\n'; 226 | first = false; 227 | 228 | const { content, mappings, ambient } = create_module_declaration( 229 | id, 230 | modules[id], 231 | created, 232 | resolve, 233 | compilerOptions 234 | ); 235 | 236 | types += content; 237 | all_mappings.set(id, mappings); 238 | for (const dep of ambient) { 239 | if (dep.external) { 240 | external_ambient_modules.add(dep.id); 241 | } else { 242 | ambient_modules.add(dep.id); 243 | } 244 | } 245 | } 246 | 247 | for (const file of ambient_modules) { 248 | // clean up ambient module then inject wholesale 249 | // TODO do we need sourcemaps here? 250 | const dts = created[file] ?? fs.readFileSync(file, 'utf8'); 251 | const result = new MagicString(dts); 252 | 253 | const index = dts.indexOf('//# sourceMappingURL='); 254 | if (index !== -1) result.remove(index, dts.length); 255 | 256 | const ast = ts.createSourceFile(file, dts, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS); 257 | 258 | ts.forEachChild(ast, (node) => { 259 | if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) { 260 | walk(node, (node) => { 261 | clean_jsdoc(node, result); 262 | }); 263 | } 264 | }); 265 | 266 | types += result.trim().toString(); 267 | } 268 | 269 | if (external_ambient_modules.size > 0) { 270 | const imports = Array.from(external_ambient_modules) 271 | .map((id) => `/// `) 272 | .join('\n'); 273 | 274 | types = `${imports}\n\n${types}`; 275 | } 276 | 277 | // finally, add back exports as appropriate 278 | const ast = ts.createSourceFile(output, types, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS); 279 | const magic_string = new MagicString(types); 280 | const locator = getLocator(types, { offsetLine: 1 }); 281 | const smg = new SourceMapGenerator({ file: path.basename(output) }); 282 | 283 | /** @type {Set} */ 284 | const sources = new Set(); 285 | 286 | ts.forEachChild(ast, (node) => { 287 | if (ts.isModuleDeclaration(node)) { 288 | if (!node.body) return; 289 | 290 | const name = node.name.text; 291 | 292 | const mappings = all_mappings.get(name); 293 | 294 | node.body.forEachChild((node) => { 295 | if (is_declaration(node)) { 296 | const identifier = ts.isVariableStatement(node) 297 | ? ts.getNameOfDeclaration(node.declarationList.declarations[0]) 298 | : ts.getNameOfDeclaration(node); 299 | 300 | if (identifier) { 301 | const name = identifier.getText(ast); 302 | 303 | const mapping = mappings?.get(name); 304 | 305 | if (mapping) { 306 | const start = identifier.getStart(ast); 307 | const location = locator(start); 308 | 309 | if (location) { 310 | let { line, column } = location; 311 | 312 | const relative = path 313 | .relative(path.dirname(output), mapping.source) 314 | .replace(/\\/g, '/'); 315 | 316 | smg.addMapping({ 317 | generated: { line, column }, 318 | original: { line: mapping.line, column: mapping.column }, 319 | source: relative, 320 | name 321 | }); 322 | 323 | smg.addMapping({ 324 | generated: { line, column: column + name.length }, 325 | original: { line: mapping.line, column: mapping.column + name.length }, 326 | source: relative, 327 | name 328 | }); 329 | 330 | sources.add(mapping.source); 331 | } 332 | } 333 | } 334 | } 335 | }); 336 | } 337 | }); 338 | 339 | // for (const source of sources) { 340 | // smg.setSourceContent( 341 | // path.relative(path.dirname(output), source), 342 | // fs.readFileSync(source, 'utf8') 343 | // ); 344 | // } 345 | 346 | const comment = `//# sourceMappingURL=${path.basename(output)}.map`; 347 | magic_string.append(`\n\n${comment}`); 348 | 349 | write(output, magic_string.toString()); 350 | 351 | write(`${output}.map`, JSON.stringify(smg.toJSON(), null, '\t')); 352 | } finally { 353 | process.chdir(original_cwd); 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /src/create-module-declaration.js: -------------------------------------------------------------------------------- 1 | /** @import { Binding, Declaration, Mapping, Module, ModuleReference } from './types' */ 2 | import path from 'node:path'; 3 | import ts from 'typescript'; 4 | import * as tsu from 'ts-api-utils'; 5 | import MagicString from 'magic-string'; 6 | import { 7 | clean_jsdoc, 8 | get_dts, 9 | is_declaration, 10 | is_internal, 11 | is_reference, 12 | resolve_dts, 13 | walk 14 | } from './utils.js'; 15 | 16 | /** 17 | * @param {string} id 18 | * @param {string} entry 19 | * @param {Record} created 20 | * @param {(file: string, specifier: string) => string | null} resolve 21 | * @param {{ stripInternal?: boolean }} options 22 | * @returns {{ 23 | * content: string; 24 | * mappings: Map; 25 | * ambient: ModuleReference[]; 26 | * }} 27 | */ 28 | export function create_module_declaration(id, entry, created, resolve, options) { 29 | let content = ''; 30 | 31 | /** @type {Map} */ 32 | const mappings = new Map(); 33 | 34 | /** @type {ModuleReference[]} */ 35 | const ambient = []; 36 | 37 | /** @type {Record>} */ 38 | const external_imports = {}; 39 | 40 | /** @type {Record>} */ 41 | const external_import_alls = {}; 42 | 43 | /** @type {Record>} */ 44 | const external_export_from = {}; 45 | 46 | /** @type {Set} */ 47 | const external_export_all_from = new Set(); 48 | 49 | /** @type {Map} */ 50 | const bundle = new Map(); 51 | 52 | /** @type {Map>} */ 53 | const traced = new Map(); 54 | 55 | /** @type {Set} */ 56 | const exports = new Set(); 57 | 58 | /** @type {Set} */ 59 | const reserved = new Set(['default']); 60 | 61 | /** @type {string[]} */ 62 | const export_specifiers = []; 63 | 64 | // step 1 — discover which modules are included in the bundle 65 | { 66 | const included = new Set([entry]); 67 | 68 | for (const file of included) { 69 | const module = get_dts(file, created, resolve, options); 70 | 71 | for (const name of module.globals) { 72 | reserved.add(name); 73 | } 74 | 75 | for (const dep of module.dependencies) { 76 | included.add(dep); 77 | } 78 | 79 | for (const dep of module.ambient_imports) { 80 | ambient.push(dep); 81 | } 82 | 83 | for (const [name, binding] of module.imports) { 84 | if (binding.external) { 85 | (external_imports[binding.id] ??= {})[binding.name] ??= create_external_declaration( 86 | binding, 87 | name 88 | ); 89 | } 90 | } 91 | 92 | for (const [name, binding] of module.import_all) { 93 | if (binding.external) { 94 | (external_import_alls[binding.id] ??= {})[binding.name] ??= create_external_declaration( 95 | binding, 96 | name 97 | ); 98 | } 99 | } 100 | 101 | for (const [name, binding] of module.export_from) { 102 | if (binding.external) { 103 | (external_export_from[binding.id] ??= {})[binding.name] ??= create_external_declaration( 104 | binding, 105 | name 106 | ); 107 | } 108 | } 109 | 110 | for (const binding of module.export_all.values()) { 111 | if (binding.external) { 112 | external_export_all_from.add(binding.id); 113 | } 114 | } 115 | 116 | bundle.set(file, module); 117 | traced.set(file, new Map()); 118 | } 119 | 120 | /** @type {Set} */ 121 | const modules_to_export_all_from = new Set([/** @type {Module} */ (bundle.get(entry))]); 122 | 123 | for (const module of modules_to_export_all_from) { 124 | for (const exported of module.exports.keys()) { 125 | exports.add(exported); 126 | } 127 | 128 | for (const exported of module.export_from.keys()) { 129 | exports.add(exported); 130 | } 131 | 132 | for (const next of module.export_all) { 133 | const m = bundle.get(next.id); 134 | if (m) modules_to_export_all_from.add(m); 135 | } 136 | } 137 | } 138 | 139 | // step 2 - treeshaking 140 | { 141 | /** @type {Set} */ 142 | const names = new Set(reserved); 143 | 144 | /** @type {Set} */ 145 | const declarations = new Set(); 146 | 147 | /** @param {string} name */ 148 | function get_name(name) { 149 | let i = 1; 150 | while (names.has(name)) { 151 | name = `${name}_${i++}`; 152 | } 153 | 154 | names.add(name); 155 | return name; 156 | } 157 | 158 | /** 159 | * @param {Declaration} declaration 160 | */ 161 | const mark = (declaration) => { 162 | if (declaration.included) return; 163 | 164 | declarations.add(declaration); 165 | declaration.included = true; 166 | 167 | for (const { module, name } of declaration.dependencies) { 168 | const dependency = trace(module, name); 169 | mark(dependency); 170 | } 171 | }; 172 | 173 | for (const name of exports) { 174 | const declaration = trace_export(entry, name); 175 | if (declaration) { 176 | declaration.alias = get_name(reserved.has(name) ? declaration.name : name); 177 | mark(declaration); 178 | 179 | if (name === 'default') { 180 | declaration.default = true; 181 | } else if (declaration.alias !== name) { 182 | export_specifiers.push(`${declaration.alias} as ${name}`); 183 | } else { 184 | declaration.export = true; 185 | } 186 | } else { 187 | throw new Error('Something strange happened'); 188 | } 189 | } 190 | 191 | // provide a name for declarations that are included but not exported 192 | for (const declaration of declarations) { 193 | if (!declaration.alias) { 194 | declaration.alias = get_name(declaration.preferred_alias || declaration.name); 195 | } 196 | } 197 | } 198 | 199 | // step 3 - generate code 200 | { 201 | content += `declare module '${id}' {`; 202 | 203 | // inject imports from external modules 204 | for (const id in external_imports) { 205 | const specifiers = []; 206 | 207 | for (const name in external_imports[id]) { 208 | const declaration = external_imports[id][name]; 209 | if (declaration.included) { 210 | specifiers.push(name === declaration.alias ? name : `${name} as ${declaration.alias}`); 211 | } 212 | } 213 | 214 | if (specifiers.length > 0) { 215 | content += `\n\timport type { ${specifiers.join(', ')} } from '${id}';`; 216 | } 217 | } 218 | 219 | for (const id in external_import_alls) { 220 | for (const name in external_import_alls[id]) { 221 | content += `\n\timport * as ${name} from '${id}';`; // TODO could this have been aliased? 222 | } 223 | } 224 | 225 | for (const id in external_export_from) { 226 | const specifiers = Object.keys(external_export_from[id]).map((name) => { 227 | // this is a bit of a hack, but it makes life easier 228 | exports.delete(name); 229 | 230 | const declaration = external_export_from[id][name]; 231 | return name === declaration.alias ? name : `${name} as ${declaration.alias}`; 232 | }); 233 | 234 | content += `\n\texport { ${specifiers.join(', ')} } from '${id}';`; 235 | } 236 | 237 | // second pass — editing 238 | for (const module of bundle.values()) { 239 | const result = new MagicString(module.dts); 240 | 241 | const index = module.dts.indexOf('//# sourceMappingURL='); 242 | if (index !== -1) result.remove(index, module.dts.length); 243 | 244 | if (module.import_all.size > 0) { 245 | // remove the leading `Foo.` from references to `import * as Foo` namespace imports 246 | walk(module.ast, (node) => { 247 | if (is_reference(node) && ts.isQualifiedName(node.parent)) { 248 | const binding = module.import_all.get(node.getText(module.ast)); 249 | if (binding) { 250 | result.remove(node.pos, result.original.indexOf('.', node.end) + 1); 251 | const declaration = bundle 252 | .get(binding.id) 253 | ?.declarations.get(node.parent.right.getText(module.ast)); 254 | if (declaration?.alias) { 255 | result.overwrite(node.parent.right.pos, node.parent.right.end, declaration.alias); 256 | } 257 | } 258 | } 259 | }); 260 | } 261 | 262 | ts.forEachChild(module.ast, (node) => { 263 | if ( 264 | ts.isImportDeclaration(node) || 265 | ts.isExportDeclaration(node) || 266 | ts.isExportAssignment(node) 267 | ) { 268 | result.remove(node.pos, node.end); 269 | return; 270 | } 271 | 272 | // remove `declare module 'foo'` 273 | if ( 274 | ts.isModuleDeclaration(node) && 275 | !tsu.isNamespaceDeclaration(node) && 276 | node.modifiers?.some((modifier) => tsu.isDeclareKeyword(modifier)) 277 | ) { 278 | result.remove(node.pos, node.end); 279 | return; 280 | } 281 | 282 | if (!is_declaration(node)) { 283 | return; 284 | } 285 | 286 | if (is_internal(node) && options.stripInternal) { 287 | result.remove(node.pos, node.end); 288 | } 289 | 290 | const identifier = /** @type {ts.DeclarationName} */ ( 291 | ts.isVariableStatement(node) 292 | ? ts.getNameOfDeclaration(node.declarationList.declarations[0]) 293 | : ts.getNameOfDeclaration(node) 294 | ); 295 | 296 | const name = identifier.getText(module.ast); 297 | 298 | const declaration = /** @type {Declaration} */ (module.declarations.get(name)); 299 | 300 | if (!declaration.included) { 301 | result.remove(node.pos, node.end); 302 | return; 303 | } 304 | 305 | // special case — TS turns `export default 42` into `const _default: 42; export default _default` — 306 | // the `export default` assignment is already taken care of, we just need to remove the `const _default:` 307 | if (declaration.default && ts.isVariableStatement(node)) { 308 | result.remove( 309 | node.getStart(), 310 | /** @type {ts.TypeNode} */ (node.declarationList.declarations[0].type).getStart() 311 | ); 312 | } 313 | 314 | const modifiers = declaration.default 315 | ? 'export default ' 316 | : declaration.export 317 | ? 'export ' 318 | : ''; 319 | 320 | if (node.modifiers) { 321 | let end = node.modifiers[node.modifiers.length - 1].end; 322 | while (/\s/.test(result.original[end])) end += 1; 323 | result.overwrite(node.getStart(), end, modifiers); 324 | } else if (modifiers) { 325 | result.prependRight(node.getStart(), modifiers); 326 | } 327 | 328 | const loc = module.locator(identifier.getStart(module.ast)); 329 | 330 | if (loc) { 331 | // the sourcemaps generated by TypeScript are very inaccurate, borderline useless. 332 | // we need to fix them up here. TODO is it only inaccurate in the JSDoc case? 333 | const segments = module.source?.mappings?.[loc.line - 1]; 334 | 335 | if (module.source && segments) { 336 | // find the segments immediately before and after the generated column 337 | const index = segments.findIndex((segment) => segment[0] >= loc.column); 338 | 339 | const a = segments[index - 1] ?? segments[0]; 340 | if (a) { 341 | let l = /** @type {number} */ (a[2]); 342 | 343 | const source_line = module.source.code.split('\n')[l]; 344 | const regex = new RegExp(`\\b${name}\\b`); 345 | const match = regex.exec(source_line); 346 | 347 | if (match) { 348 | const mapping = { 349 | source: path.resolve(path.dirname(module.file), module.source.map.sources[0]), 350 | line: l + 1, 351 | column: match.index 352 | }; 353 | mappings.set(name, /** @type {Mapping} */ (mapping)); 354 | } else { 355 | // TODO figure out how to repair sourcemaps in this case 356 | } 357 | } else { 358 | // TODO how does this happen? 359 | } 360 | } else { 361 | mappings.set(name, { 362 | source: module.file, 363 | line: loc.line, 364 | column: loc.column 365 | }); 366 | } 367 | } 368 | 369 | walk(node, (node) => { 370 | if (ts.isPropertySignature(node) && is_internal(node) && options.stripInternal) { 371 | result.remove(node.pos, node.end); 372 | return false; 373 | } 374 | 375 | // We need to include the declarations because if references to them have changed, we need to update the declarations, too 376 | if (is_reference(node, true)) { 377 | const name = node.getText(module.ast); 378 | 379 | const { alias } = trace(module.file, name); 380 | 381 | if (alias !== name) { 382 | result.overwrite(node.getStart(module.ast), node.getEnd(), alias); 383 | } 384 | } 385 | 386 | // `import('./foo').Foo` -> `Foo` 387 | if ( 388 | ts.isImportTypeNode(node) && 389 | ts.isLiteralTypeNode(node.argument) && 390 | ts.isStringLiteral(node.argument.literal) && 391 | node.argument.literal.text.startsWith('.') 392 | ) { 393 | // follow import 394 | const resolved = resolve_dts(path.dirname(module.file), node.argument.literal.text); 395 | 396 | // included.add(resolved); 397 | // remove the `import(...)` 398 | if (node.qualifier) { 399 | const name = node.qualifier.getText(module.ast); 400 | const declaration = trace(resolved, name); 401 | 402 | result.overwrite(node.getStart(module.ast), node.qualifier.end, declaration.alias); 403 | } else { 404 | throw new Error('TODO'); 405 | } 406 | } 407 | 408 | clean_jsdoc(node, result); 409 | }); 410 | }); 411 | 412 | const mod = result 413 | .trim() 414 | .indent() 415 | .toString() 416 | .replace(/^( )+/gm, (match) => '\t'.repeat(match.length / 4)); 417 | 418 | if (mod) content += '\n' + mod; 419 | } 420 | 421 | // finally, export any bindings that are exported from external modules 422 | 423 | for (const name of exports) { 424 | const declaration = trace_export(entry, name); 425 | if (declaration?.external) { 426 | export_specifiers.push(declaration.alias); 427 | } 428 | } 429 | 430 | // Always add an export { .. } statement, even if there are no exports. This ensures 431 | // that only the public types are exposed to consumers of the declaration file. Due to some 432 | // old TypeScript inconsistency, omitting the export statement would expose all types. 433 | if (export_specifiers.length > 0) { 434 | content += `\n\n\texport { ${export_specifiers.join(', ')} };`; 435 | } else { 436 | content += '\n\n\texport {};'; 437 | } 438 | 439 | content += `\n}`; 440 | } 441 | 442 | /** 443 | * @param {string} module_id 444 | * @param {string} name 445 | * @returns {Declaration | null} 446 | */ 447 | function trace_export(module_id, name) { 448 | if (module_id === id) { 449 | return trace_export(entry, name); 450 | } 451 | 452 | const module = bundle.get(module_id); 453 | if (module) { 454 | const local = module.exports.get(name); 455 | if (local) { 456 | return trace(module_id, local); 457 | } 458 | 459 | const binding = module.export_from.get(name); 460 | if (binding) { 461 | return trace_export(binding.id, binding.name); 462 | } 463 | 464 | for (const reference of module.export_all) { 465 | const declaration = trace_export(reference.id, name); 466 | if (declaration) return declaration; 467 | } 468 | } else { 469 | const declaration = 470 | external_imports[module_id]?.[name] ?? 471 | external_import_alls[module_id]?.[name] ?? 472 | external_export_from[module_id]?.[name]; 473 | 474 | if (declaration) return declaration; 475 | } 476 | 477 | return null; 478 | } 479 | 480 | /** 481 | * @param {string} id 482 | * @param {string} name 483 | * @returns {Declaration} 484 | */ 485 | function trace(id, name) { 486 | const cache = traced.get(id); 487 | 488 | if (!cache) { 489 | // this means we're dealing with an external module 490 | return ( 491 | external_imports[id]?.[name] ?? 492 | external_import_alls[id]?.[name] ?? 493 | external_export_from[id]?.[name] 494 | ); 495 | } 496 | 497 | if (cache.has(name)) { 498 | return /** @type {Declaration} */ (cache.get(name)); 499 | } 500 | 501 | const module = bundle.get(id); 502 | if (module) { 503 | const declaration = module.declarations.get(name); 504 | if (declaration) { 505 | cache.set(name, declaration); 506 | return declaration; 507 | } 508 | 509 | const binding = module.imports.get(name) ?? module.export_from.get(name); 510 | if (binding) { 511 | const declaration = trace_export(binding.id, binding.name); 512 | if (declaration) return declaration; 513 | } 514 | 515 | for (const reference of module.export_all) { 516 | const declaration = trace_export(reference.id, name); 517 | if (declaration) { 518 | cache.set(name, declaration); 519 | return declaration; 520 | } 521 | } 522 | 523 | // otherwise it's presumably a built-in 524 | return { 525 | module: '', 526 | external: false, 527 | included: true, 528 | export: false, 529 | default: false, 530 | name, 531 | alias: name, 532 | dependencies: [], 533 | preferred_alias: '' 534 | }; 535 | } else { 536 | throw new Error('TODO external imports'); 537 | } 538 | } 539 | 540 | return { 541 | content, 542 | mappings, 543 | ambient 544 | }; 545 | } 546 | 547 | /** 548 | * @param {Binding} binding 549 | * @param {string} alias 550 | * @returns {Declaration} 551 | */ 552 | function create_external_declaration(binding, alias) { 553 | return { 554 | module: binding.id, 555 | name: binding.name, 556 | alias: '', 557 | export: false, 558 | default: false, 559 | external: true, 560 | included: false, 561 | dependencies: [], 562 | preferred_alias: alias 563 | }; 564 | } 565 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | /** @import { Binding, Declaration, Module, Namespace } from './types' */ 2 | import fs from 'node:fs'; 3 | import path from 'node:path'; 4 | import { globSync } from 'tinyglobby'; 5 | import ts from 'typescript'; 6 | import * as tsu from 'ts-api-utils'; 7 | import { getLocator } from 'locate-character'; 8 | import { decode } from '@jridgewell/sourcemap-codec'; 9 | 10 | const preserved_jsdoc_tags = new Set(['default', 'deprecated', 'example']); 11 | 12 | /** @param {ts.Node} node */ 13 | export function get_jsdoc(node) { 14 | const { jsDoc } = /** @type {{ jsDoc?: ts.JSDoc[] }} */ (/** @type {*} */ (node)); 15 | return jsDoc; 16 | } 17 | 18 | /** @param {ts.Node} node */ 19 | export function is_internal(node) { 20 | const jsdoc = get_jsdoc(node); 21 | 22 | if (jsdoc) { 23 | for (const jsDoc of jsdoc) { 24 | if (jsDoc.tags?.some((tag) => tag.tagName.escapedText === 'internal')) { 25 | return true; 26 | } 27 | } 28 | } 29 | 30 | return false; 31 | } 32 | 33 | /** @param {ts.Node} node */ 34 | export function get_jsdoc_imports(node) { 35 | /** @type {import('typescript').TypeNode[]} */ 36 | const imports = []; 37 | 38 | const jsdoc = get_jsdoc(node); 39 | for (const comment of jsdoc ?? []) { 40 | for (const tag of comment.tags ?? []) { 41 | collect_jsdoc_imports(tag, imports); 42 | } 43 | } 44 | 45 | return imports; 46 | } 47 | 48 | /** 49 | * 50 | * @param {ts.JSDocTag} node 51 | * @param {ts.TypeNode[]} imports 52 | */ 53 | function collect_jsdoc_imports(node, imports) { 54 | const type_expression = /** @type {ts.JSDocTag & { typeExpression?: ts.Node}} */ (node) 55 | .typeExpression; 56 | 57 | if (type_expression) { 58 | /** 59 | * @type {ts.JSDocTag[]} 60 | */ 61 | const sub_tags = []; 62 | 63 | if (ts.isJSDocTypeLiteral(type_expression)) { 64 | sub_tags.push(...(type_expression.jsDocPropertyTags ?? [])); 65 | } else if (ts.isJSDocSignature(type_expression)) { 66 | sub_tags.push(...type_expression.parameters, ...(type_expression.typeParameters ?? [])); 67 | if (type_expression.type) { 68 | sub_tags.push(type_expression.type); 69 | } 70 | } else if (ts.isJSDocTypeExpression(type_expression)) { 71 | walk(type_expression.type, (node) => { 72 | if (ts.isImportTypeNode(node)) { 73 | imports.push(node.argument); 74 | } 75 | }); 76 | } 77 | 78 | for (const sub_tag of sub_tags) { 79 | collect_jsdoc_imports(sub_tag, imports); 80 | } 81 | } 82 | } 83 | 84 | /** 85 | * @param {ts.Node} node 86 | * @param {import('magic-string').default} code 87 | */ 88 | export function clean_jsdoc(node, code) { 89 | const jsdoc = get_jsdoc(node); 90 | 91 | if (jsdoc) { 92 | for (const jsDoc of jsdoc) { 93 | let should_keep = !!jsDoc.comment; 94 | 95 | jsDoc.tags?.forEach((tag) => { 96 | const type = /** @type {string} */ (tag.tagName.escapedText); 97 | 98 | // @ts-ignore 99 | const name = /** @type {ts.Identifier | undefined} */ (tag.name); 100 | if (name) { 101 | // @ts-ignore 102 | if (tag.isBracketed) { 103 | // in JSDoc, we might have an optional [foo] parameter. in a .d.ts context, 104 | // the brackets cause the parameter to be interpreted as a comment, 105 | // so we have to remove them 106 | let a = name.pos - 1; 107 | let b = name.end; 108 | 109 | while (code.original[a] === ' ') a -= 1; 110 | while (code.original[b] === ' ') b += 1; 111 | 112 | code.remove(a, name.pos); 113 | code.remove(name.end, b + 1); 114 | } 115 | } 116 | 117 | if (tag.comment) { 118 | should_keep = true; 119 | 120 | if (type === 'param' || type === 'returns') { 121 | const typeExpression = /** @type {ts.JSDocTypeExpression | undefined} */ ( 122 | // @ts-ignore 123 | tag.typeExpression 124 | ); 125 | 126 | if (typeExpression) { 127 | // turn `@param {string} foo description` into `@param foo description` 128 | let a = typeExpression.pos; 129 | let b = typeExpression.end; 130 | 131 | while (code.original[b] === ' ') b += 1; 132 | code.remove(a, b); 133 | } 134 | } 135 | } else if (preserved_jsdoc_tags.has(type)) { 136 | should_keep = true; 137 | } else { 138 | code.remove(tag.pos, tag.end); 139 | } 140 | }); 141 | 142 | if (!should_keep) { 143 | code.remove(jsDoc.pos, jsDoc.end); 144 | } 145 | } 146 | } 147 | } 148 | 149 | /** 150 | * @param {string} cwd 151 | * @param {string[]} include 152 | * @param {string[]} exclude 153 | * @returns {string[]} 154 | */ 155 | export function get_input_files(cwd, include, exclude) { 156 | /** @type {Set} */ 157 | const included = new Set(); 158 | 159 | for (const pattern of include) { 160 | for (const file of globSync(pattern, { cwd })) { 161 | const resolved = path.resolve(cwd, file); 162 | if (fs.statSync(resolved).isDirectory()) { 163 | for (const file of globSync('**/*.{js,jsx,ts,tsx}', { cwd: resolved, ignore: exclude })) { 164 | included.add(path.resolve(resolved, file)); 165 | } 166 | } else { 167 | included.add(resolved); 168 | } 169 | } 170 | } 171 | 172 | return Array.from(included).map((file) => path.resolve(file)); 173 | } 174 | 175 | /** 176 | * @param {string} file 177 | * @param {string} contents 178 | */ 179 | export function write(file, contents) { 180 | try { 181 | fs.mkdirSync(path.dirname(file), { recursive: true }); 182 | } catch {} 183 | fs.writeFileSync(file, contents); 184 | } 185 | 186 | /** 187 | * @param {string} file 188 | * @param {Record} created 189 | * @param {(file: string, specifier: string) => string | null} resolve 190 | * @param {{ stripInternal?: boolean }} options 191 | */ 192 | export function get_dts(file, created, resolve, options) { 193 | const dts = created[file] ?? fs.readFileSync(file, 'utf8'); 194 | const ast = ts.createSourceFile(file, dts, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS); 195 | const locator = getLocator(dts, { offsetLine: 1 }); 196 | 197 | /** @type {Module} */ 198 | const module = { 199 | file, 200 | dts, 201 | ast, 202 | locator, 203 | source: null, 204 | dependencies: [], 205 | globals: [], 206 | references: new Set(), 207 | declarations: new Map(), 208 | imports: new Map(), 209 | exports: new Map(), 210 | export_from: new Map(), 211 | import_all: new Map(), 212 | export_all: [], 213 | ambient_imports: [] 214 | }; 215 | 216 | if (file in created) { 217 | const map = JSON.parse(created[file + '.map']); 218 | 219 | const source_file = path.resolve(path.dirname(file), map.sources[0]); 220 | const code = fs.readFileSync(source_file, 'utf8'); 221 | 222 | module.source = { 223 | code, 224 | map, 225 | mappings: decode(map.mappings) 226 | }; 227 | } 228 | 229 | /** @type {Module | Namespace} */ 230 | let current = module; 231 | 232 | /** @param {ts.Node} node */ 233 | function scan(node) { 234 | // follow imports 235 | if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) { 236 | if (node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) { 237 | const { text } = node.moduleSpecifier; 238 | const resolved = resolve(file, text); 239 | const external = !resolved; 240 | const id = resolved ?? text; 241 | 242 | // if a local module, and _not_ an ambient import, add it to dependencies 243 | if (!external && !(ts.isImportDeclaration(node) && !node.importClause)) { 244 | module.dependencies.push(id); 245 | } 246 | 247 | if (ts.isImportDeclaration(node)) { 248 | if (node.importClause) { 249 | // `import foo` 250 | if (node.importClause.name) { 251 | const name = node.importClause.name.getText(module.ast); 252 | module.imports.set(name, { 253 | id, 254 | external, 255 | name: 'default' 256 | }); 257 | } else if (node.importClause.namedBindings) { 258 | // `import * as foo` 259 | if (ts.isNamespaceImport(node.importClause.namedBindings)) { 260 | const name = node.importClause.namedBindings.name.getText(module.ast); 261 | module.import_all.set(name, { 262 | id, 263 | external, 264 | name 265 | }); 266 | } 267 | 268 | // `import { foo }`, `import { foo as bar }` 269 | else { 270 | node.importClause.namedBindings.elements.forEach((specifier) => { 271 | const local = specifier.name.getText(module.ast); 272 | 273 | module.imports.set(local, { 274 | id, 275 | external, 276 | name: specifier.propertyName?.getText(module.ast) ?? local 277 | }); 278 | }); 279 | } 280 | } 281 | } else { 282 | // assume this is an ambient module 283 | module.ambient_imports.push({ id, external }); 284 | } 285 | } 286 | 287 | if (ts.isExportDeclaration(node)) { 288 | if (node.exportClause && ts.isNamedExports(node.exportClause)) { 289 | // `export { foo as bar } from '...'` 290 | if (ts.isNamedExports(node.exportClause)) { 291 | node.exportClause.elements.forEach((specifier) => { 292 | const name = specifier.name.getText(module.ast); 293 | const local = specifier.propertyName 294 | ? specifier.propertyName.getText(module.ast) 295 | : name; 296 | 297 | module.export_from.set(name, { 298 | id, 299 | external, 300 | name: local 301 | }); 302 | }); 303 | } 304 | } else { 305 | // `export * as foo from '...'` 306 | if (node.exportClause) { 307 | // in this case, we need to generate an `export namespace` declaration 308 | const name = node.exportClause?.name?.getText(module.ast) ?? null; 309 | throw new Error(`TODO export * as ${name}`); 310 | } 311 | 312 | // `export * from '...'` 313 | module.export_all.push({ id, external }); 314 | } 315 | } 316 | } else if (ts.isExportDeclaration(node)) { 317 | if (node.exportClause && ts.isNamedExports(node.exportClause)) { 318 | // `export { foo as bar }` 319 | if (ts.isNamedExports(node.exportClause)) { 320 | node.exportClause.elements.forEach((specifier) => { 321 | const name = specifier.name.getText(module.ast); 322 | const local = specifier.propertyName 323 | ? specifier.propertyName.getText(module.ast) 324 | : name; 325 | 326 | module.exports.set(name, local); 327 | }); 328 | } 329 | } 330 | } 331 | 332 | return; 333 | } 334 | 335 | if (is_declaration(node)) { 336 | if (is_internal(node) && options.stripInternal) return; 337 | 338 | const identifier = ts.isVariableStatement(node) 339 | ? ts.getNameOfDeclaration(node.declarationList.declarations[0]) 340 | : ts.getNameOfDeclaration(node); 341 | 342 | if (!identifier) { 343 | throw new Error('TODO'); // unnamed default export? 344 | } 345 | 346 | const name = identifier.getText(module.ast); 347 | 348 | // in the case of overloads, declaration may already exist 349 | const existing = current.declarations.get(name); 350 | if (!existing) { 351 | current.declarations.set(name, { 352 | module: file, 353 | name, 354 | alias: '', 355 | export: false, 356 | default: false, 357 | included: false, 358 | external: false, 359 | dependencies: [], 360 | preferred_alias: '' 361 | }); 362 | } 363 | 364 | const declaration = /** @type {Declaration} */ (current.declarations.get(name)); 365 | 366 | const export_modifier = node.modifiers?.find((node) => tsu.isExportKeyword(node)); 367 | 368 | if (export_modifier) { 369 | const default_modifier = node.modifiers?.find((node) => tsu.isDefaultKeyword(node)); 370 | current.exports.set(default_modifier ? 'default' : name, name); 371 | } 372 | 373 | const params = new Set(); 374 | if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) { 375 | if (node.typeParameters) { 376 | for (const param of node.typeParameters) { 377 | params.add(param.name.getText(module.ast)); 378 | } 379 | } 380 | } 381 | 382 | if (tsu.isNamespaceDeclaration(node)) { 383 | const previous = current; 384 | current = { 385 | declarations: new Map(), 386 | references: new Set(), 387 | exports: new Map() 388 | }; 389 | 390 | node.body.forEachChild(scan); 391 | 392 | for (const name of current.references) { 393 | if (!current.declarations.has(name)) { 394 | previous.references.add(name); 395 | } 396 | } 397 | 398 | for (const inner of current.declarations.values()) { 399 | for (const inner_dep of inner.dependencies) { 400 | if ( 401 | !declaration.dependencies.some( 402 | (dep) => dep.name === inner_dep.name && dep.module === inner_dep.module 403 | ) 404 | ) { 405 | declaration.dependencies.push(inner_dep); 406 | } 407 | } 408 | } 409 | 410 | current = previous; 411 | } else { 412 | walk(node, (node) => { 413 | if (ts.isPropertySignature(node) && is_internal(node) && options.stripInternal) { 414 | return false; 415 | } 416 | 417 | // `import('./foo').Foo` -> `Foo` 418 | if ( 419 | ts.isImportTypeNode(node) && 420 | ts.isLiteralTypeNode(node.argument) && 421 | ts.isStringLiteral(node.argument.literal) 422 | ) { 423 | // follow import 424 | const resolved = resolve(file, node.argument.literal.text); 425 | if (resolved) { 426 | module.dependencies.push(resolved); 427 | 428 | if (node.qualifier) { 429 | // In the case of `import('./foo').Foo.Bar`, this contains `Foo.Bar`, 430 | // but we only want `Foo` (because we don't traverse into namespaces) 431 | let id = node.qualifier; 432 | while (ts.isQualifiedName(id)) { 433 | id = id.left; 434 | } 435 | declaration.dependencies.push({ 436 | module: resolved ?? node.argument.literal.text, 437 | name: id.getText(module.ast) 438 | }); 439 | } 440 | } 441 | } 442 | 443 | if (is_reference(node)) { 444 | const name = node.getText(module.ast); 445 | if (params.has(name)) return; 446 | 447 | current.references.add(name); 448 | 449 | if (name !== declaration.name) { 450 | // If this references an import * as X statement, we add a dependency to Y of the X.Y access 451 | if (module.import_all.has(name) && ts.isQualifiedName(node.parent)) { 452 | declaration.dependencies.push({ 453 | module: /** @type {Binding} */ (module.import_all.get(name)).id, 454 | name: node.parent.right.getText(module.ast) 455 | }); 456 | } else { 457 | declaration.dependencies.push({ 458 | module: file, 459 | name 460 | }); 461 | } 462 | } 463 | } 464 | }); 465 | } 466 | 467 | return; 468 | } 469 | 470 | if (ts.isExportAssignment(node)) { 471 | const name = node.expression.getText(module.ast); 472 | current.exports.set('default', name); 473 | return; 474 | } 475 | 476 | if (ts.isModuleDeclaration(node)) { 477 | return; 478 | } 479 | 480 | if (tsu.isEndOfFileToken(node)) return; 481 | 482 | if (ts.isEnumDeclaration(node)) return; 483 | 484 | // throw new Error(`Unimplemented node type ${ts.SyntaxKind[node.kind]}`); 485 | } 486 | 487 | ast.statements.forEach(scan); 488 | 489 | for (const name of module.references) { 490 | if (!module.declarations.has(name) && !module.imports.has(name)) { 491 | module.globals.push(name); 492 | } 493 | } 494 | 495 | return module; 496 | } 497 | 498 | /** 499 | * @param {string} from 500 | * @param {string} to 501 | */ 502 | export function resolve_dts(from, to) { 503 | const file = path.resolve(from, to); 504 | if (file.endsWith('.d.ts')) return file; 505 | if (file.endsWith('.ts')) return file.replace(/\.ts$/, '.d.ts'); 506 | if (file.endsWith('.js')) return file.replace(/\.js$/, '.d.ts'); 507 | if (file.endsWith('.jsx')) return file.replace(/\.jsx$/, '.d.ts'); 508 | if (file.endsWith('.tsx')) return file.replace(/\.tsx$/, '.d.ts'); 509 | if (fs.existsSync(file) && fs.statSync(file).isDirectory()) return file + '/index.d.ts'; 510 | return file + '.d.ts'; 511 | } 512 | 513 | /** 514 | * @param {ts.Node} node 515 | * @param {(node: ts.Node) => void | false} callback 516 | */ 517 | export function walk(node, callback) { 518 | const go_on = callback(node); 519 | if (go_on !== false) { 520 | ts.forEachChild(node, (child) => walk(child, callback)); 521 | } 522 | } 523 | 524 | /** 525 | * @param {ts.Node} node 526 | * @returns {node is 527 | * ts.InterfaceDeclaration | 528 | * ts.TypeAliasDeclaration | 529 | * ts.ClassDeclaration | 530 | * ts.FunctionDeclaration | 531 | * ts.VariableStatement | 532 | * ts.EnumDeclaration | 533 | * ts.ModuleDeclaration 534 | * } 535 | */ 536 | export function is_declaration(node) { 537 | return ( 538 | ts.isInterfaceDeclaration(node) || 539 | ts.isTypeAliasDeclaration(node) || 540 | ts.isClassDeclaration(node) || 541 | ts.isFunctionDeclaration(node) || 542 | ts.isVariableStatement(node) || 543 | ts.isEnumDeclaration(node) || 544 | tsu.isNamespaceDeclaration(node) 545 | ); 546 | } 547 | 548 | /** 549 | * @param {ts.Node} node 550 | * @param {boolean} [include_declarations] 551 | * @returns {node is ts.Identifier} 552 | */ 553 | export function is_reference(node, include_declarations = false) { 554 | if (!ts.isIdentifier(node)) return false; 555 | 556 | if (node.parent) { 557 | if (is_declaration(node.parent)) { 558 | if (ts.isVariableStatement(node.parent)) { 559 | return false; 560 | } 561 | 562 | return include_declarations && node.parent.name === node; 563 | } 564 | 565 | if (ts.isPropertyAccessExpression(node.parent)) return node === node.parent.expression; 566 | if (ts.isPropertyDeclaration(node.parent)) return node === node.parent.initializer; 567 | if (ts.isPropertyAssignment(node.parent)) return node === node.parent.initializer; 568 | if (ts.isMethodSignature(node.parent)) return node !== node.parent.name; 569 | 570 | if (ts.isImportTypeNode(node.parent)) return false; 571 | if (ts.isPropertySignature(node.parent)) return false; 572 | if (ts.isGetAccessor(node.parent)) return false; 573 | if (ts.isSetAccessor(node.parent)) return false; 574 | if (ts.isParameter(node.parent)) return false; 575 | if (ts.isMethodDeclaration(node.parent)) return false; 576 | if (ts.isLabeledStatement(node.parent)) return false; 577 | if (ts.isBreakOrContinueStatement(node.parent)) return false; 578 | if (ts.isEnumMember(node.parent)) return false; 579 | if (ts.isModuleDeclaration(node.parent)) return false; 580 | 581 | // Only X in X.Y.Z is a reference we care about 582 | if (ts.isQualifiedName(node.parent)) { 583 | return node.parent.left === node && ts.isIdentifier(node.parent.right); 584 | } 585 | 586 | // `const = { x: 1 }` inexplicably becomes `namespace a { let x: number; }` 587 | if (ts.isVariableDeclaration(node.parent)) { 588 | if (node === node.parent.initializer) return true; 589 | 590 | const ancestor = node.parent.parent?.parent?.parent?.parent; 591 | 592 | if (ancestor && tsu.isNamespaceDeclaration(node.parent.parent.parent.parent.parent)) { 593 | return false; 594 | } 595 | } 596 | } 597 | 598 | return true; 599 | } 600 | 601 | /** 602 | * parse tsconfig.json with typescript api 603 | * @param {string} tsconfig_file 604 | * @returns {{ 605 | * include: string[]|undefined, 606 | * exclude: string[]|undefined, 607 | * compilerOptions: ts.CompilerOptions 608 | * }} 609 | * @throws {Error} if ts api returns error diagnostics 610 | */ 611 | export function parse_tsconfig(tsconfig_file) { 612 | const { config, error: read_diagnostic } = ts.readConfigFile(tsconfig_file, ts.sys.readFile); 613 | if (read_diagnostic != null) { 614 | report_ts_errors(tsconfig_file, 'readConfigFile', [read_diagnostic]); 615 | } 616 | const { 617 | raw, 618 | options, 619 | errors: parse_diagnostics 620 | } = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(tsconfig_file)); 621 | report_ts_errors(tsconfig_file, 'parseJsonConfigFileContent', parse_diagnostics); 622 | // only returns what's needed later on 623 | return { 624 | include: raw.include, 625 | exclude: raw.exclude, 626 | compilerOptions: options 627 | }; 628 | } 629 | 630 | /** 631 | * log and throw error diagnostics 632 | * @param {string} tsconfig_file 633 | * @param {string} phase 634 | * @param {ts.Diagnostic[]} diagnostics 635 | */ 636 | function report_ts_errors(tsconfig_file, phase, diagnostics) { 637 | const errors = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error); 638 | if (errors.length > 0) { 639 | const msg = `parsing ${tsconfig_file} failed during ${phase}`; 640 | console.error( 641 | `${msg}\n`, 642 | ts.formatDiagnostics(diagnostics, { 643 | getCurrentDirectory: () => ts.sys.getCurrentDirectory(), 644 | getCanonicalFileName: (f) => f, 645 | getNewLine: () => '\n' 646 | }) 647 | ); 648 | throw new Error(msg); 649 | } 650 | } 651 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '9.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | importers: 8 | 9 | .: 10 | dependencies: 11 | '@jridgewell/source-map': 12 | specifier: ^0.3.5 13 | version: 0.3.5 14 | '@jridgewell/sourcemap-codec': 15 | specifier: ^1.4.15 16 | version: 1.4.15 17 | kleur: 18 | specifier: ^4.1.5 19 | version: 4.1.5 20 | locate-character: 21 | specifier: ^3.0.0 22 | version: 3.0.0 23 | magic-string: 24 | specifier: ^0.30.4 25 | version: 0.30.5 26 | sade: 27 | specifier: ^1.8.1 28 | version: 1.8.1 29 | tinyglobby: 30 | specifier: ^0.2.10 31 | version: 0.2.10 32 | ts-api-utils: 33 | specifier: ^1.0.3 34 | version: 1.0.3(typescript@5.8.3) 35 | devDependencies: 36 | '@changesets/cli': 37 | specifier: ^2.28.1 38 | version: 2.28.1 39 | '@types/node': 40 | specifier: ^20.7.2 41 | version: 20.8.6 42 | '@types/semver': 43 | specifier: ^7.5.3 44 | version: 7.5.3 45 | prettier: 46 | specifier: ^3.0.3 47 | version: 3.0.3 48 | semver: 49 | specifier: ^7.5.4 50 | version: 7.5.4 51 | typescript: 52 | specifier: ~5.8.3 53 | version: 5.8.3 54 | uvu: 55 | specifier: ^0.5.6 56 | version: 0.5.6 57 | 58 | packages: 59 | 60 | '@babel/runtime@7.26.9': 61 | resolution: {integrity: sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg==} 62 | engines: {node: '>=6.9.0'} 63 | 64 | '@changesets/apply-release-plan@7.0.10': 65 | resolution: {integrity: sha512-wNyeIJ3yDsVspYvHnEz1xQDq18D9ifed3lI+wxRQRK4pArUcuHgCTrHv0QRnnwjhVCQACxZ+CBih3wgOct6UXw==} 66 | 67 | '@changesets/assemble-release-plan@6.0.6': 68 | resolution: {integrity: sha512-Frkj8hWJ1FRZiY3kzVCKzS0N5mMwWKwmv9vpam7vt8rZjLL1JMthdh6pSDVSPumHPshTTkKZ0VtNbE0cJHZZUg==} 69 | 70 | '@changesets/changelog-git@0.2.1': 71 | resolution: {integrity: sha512-x/xEleCFLH28c3bQeQIyeZf8lFXyDFVn1SgcBiR2Tw/r4IAWlk1fzxCEZ6NxQAjF2Nwtczoen3OA2qR+UawQ8Q==} 72 | 73 | '@changesets/cli@2.28.1': 74 | resolution: {integrity: sha512-PiIyGRmSc6JddQJe/W1hRPjiN4VrMvb2VfQ6Uydy2punBioQrsxppyG5WafinKcW1mT0jOe/wU4k9Zy5ff21AA==} 75 | hasBin: true 76 | 77 | '@changesets/config@3.1.1': 78 | resolution: {integrity: sha512-bd+3Ap2TKXxljCggI0mKPfzCQKeV/TU4yO2h2C6vAihIo8tzseAn2e7klSuiyYYXvgu53zMN1OeYMIQkaQoWnA==} 79 | 80 | '@changesets/errors@0.2.0': 81 | resolution: {integrity: sha512-6BLOQUscTpZeGljvyQXlWOItQyU71kCdGz7Pi8H8zdw6BI0g3m43iL4xKUVPWtG+qrrL9DTjpdn8eYuCQSRpow==} 82 | 83 | '@changesets/get-dependents-graph@2.1.3': 84 | resolution: {integrity: sha512-gphr+v0mv2I3Oxt19VdWRRUxq3sseyUpX9DaHpTUmLj92Y10AGy+XOtV+kbM6L/fDcpx7/ISDFK6T8A/P3lOdQ==} 85 | 86 | '@changesets/get-release-plan@4.0.8': 87 | resolution: {integrity: sha512-MM4mq2+DQU1ZT7nqxnpveDMTkMBLnwNX44cX7NSxlXmr7f8hO6/S2MXNiXG54uf/0nYnefv0cfy4Czf/ZL/EKQ==} 88 | 89 | '@changesets/get-version-range-type@0.4.0': 90 | resolution: {integrity: sha512-hwawtob9DryoGTpixy1D3ZXbGgJu1Rhr+ySH2PvTLHvkZuQ7sRT4oQwMh0hbqZH1weAooedEjRsbrWcGLCeyVQ==} 91 | 92 | '@changesets/git@3.0.2': 93 | resolution: {integrity: sha512-r1/Kju9Y8OxRRdvna+nxpQIsMsRQn9dhhAZt94FLDeu0Hij2hnOozW8iqnHBgvu+KdnJppCveQwK4odwfw/aWQ==} 94 | 95 | '@changesets/logger@0.1.1': 96 | resolution: {integrity: sha512-OQtR36ZlnuTxKqoW4Sv6x5YIhOmClRd5pWsjZsddYxpWs517R0HkyiefQPIytCVh4ZcC5x9XaG8KTdd5iRQUfg==} 97 | 98 | '@changesets/parse@0.4.1': 99 | resolution: {integrity: sha512-iwksMs5Bf/wUItfcg+OXrEpravm5rEd9Bf4oyIPL4kVTmJQ7PNDSd6MDYkpSJR1pn7tz/k8Zf2DhTCqX08Ou+Q==} 100 | 101 | '@changesets/pre@2.0.2': 102 | resolution: {integrity: sha512-HaL/gEyFVvkf9KFg6484wR9s0qjAXlZ8qWPDkTyKF6+zqjBe/I2mygg3MbpZ++hdi0ToqNUF8cjj7fBy0dg8Ug==} 103 | 104 | '@changesets/read@0.6.3': 105 | resolution: {integrity: sha512-9H4p/OuJ3jXEUTjaVGdQEhBdqoT2cO5Ts95JTFsQyawmKzpL8FnIeJSyhTDPW1MBRDnwZlHFEM9SpPwJDY5wIg==} 106 | 107 | '@changesets/should-skip-package@0.1.2': 108 | resolution: {integrity: sha512-qAK/WrqWLNCP22UDdBTMPH5f41elVDlsNyat180A33dWxuUDyNpg6fPi/FyTZwRriVjg0L8gnjJn2F9XAoF0qw==} 109 | 110 | '@changesets/types@4.1.0': 111 | resolution: {integrity: sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==} 112 | 113 | '@changesets/types@6.1.0': 114 | resolution: {integrity: sha512-rKQcJ+o1nKNgeoYRHKOS07tAMNd3YSN0uHaJOZYjBAgxfV7TUE7JE+z4BzZdQwb5hKaYbayKN5KrYV7ODb2rAA==} 115 | 116 | '@changesets/write@0.4.0': 117 | resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==} 118 | 119 | '@jridgewell/gen-mapping@0.3.3': 120 | resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} 121 | engines: {node: '>=6.0.0'} 122 | 123 | '@jridgewell/resolve-uri@3.1.1': 124 | resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} 125 | engines: {node: '>=6.0.0'} 126 | 127 | '@jridgewell/set-array@1.1.2': 128 | resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} 129 | engines: {node: '>=6.0.0'} 130 | 131 | '@jridgewell/source-map@0.3.5': 132 | resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==} 133 | 134 | '@jridgewell/sourcemap-codec@1.4.15': 135 | resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} 136 | 137 | '@jridgewell/trace-mapping@0.3.19': 138 | resolution: {integrity: sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==} 139 | 140 | '@manypkg/find-root@1.1.0': 141 | resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} 142 | 143 | '@manypkg/get-packages@1.1.3': 144 | resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} 145 | 146 | '@nodelib/fs.scandir@2.1.5': 147 | resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} 148 | engines: {node: '>= 8'} 149 | 150 | '@nodelib/fs.stat@2.0.5': 151 | resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} 152 | engines: {node: '>= 8'} 153 | 154 | '@nodelib/fs.walk@1.2.8': 155 | resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} 156 | engines: {node: '>= 8'} 157 | 158 | '@types/node@12.20.55': 159 | resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} 160 | 161 | '@types/node@20.8.6': 162 | resolution: {integrity: sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==} 163 | 164 | '@types/semver@7.5.3': 165 | resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==} 166 | 167 | ansi-colors@4.1.3: 168 | resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} 169 | engines: {node: '>=6'} 170 | 171 | ansi-regex@5.0.1: 172 | resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} 173 | engines: {node: '>=8'} 174 | 175 | argparse@1.0.10: 176 | resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} 177 | 178 | array-union@2.1.0: 179 | resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} 180 | engines: {node: '>=8'} 181 | 182 | better-path-resolve@1.0.0: 183 | resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} 184 | engines: {node: '>=4'} 185 | 186 | braces@3.0.3: 187 | resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} 188 | engines: {node: '>=8'} 189 | 190 | chardet@0.7.0: 191 | resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} 192 | 193 | ci-info@3.9.0: 194 | resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} 195 | engines: {node: '>=8'} 196 | 197 | cross-spawn@7.0.6: 198 | resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} 199 | engines: {node: '>= 8'} 200 | 201 | dequal@2.0.3: 202 | resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} 203 | engines: {node: '>=6'} 204 | 205 | detect-indent@6.1.0: 206 | resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} 207 | engines: {node: '>=8'} 208 | 209 | diff@5.1.0: 210 | resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} 211 | engines: {node: '>=0.3.1'} 212 | 213 | dir-glob@3.0.1: 214 | resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} 215 | engines: {node: '>=8'} 216 | 217 | enquirer@2.4.1: 218 | resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} 219 | engines: {node: '>=8.6'} 220 | 221 | esprima@4.0.1: 222 | resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} 223 | engines: {node: '>=4'} 224 | hasBin: true 225 | 226 | extendable-error@0.1.7: 227 | resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} 228 | 229 | external-editor@3.1.0: 230 | resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} 231 | engines: {node: '>=4'} 232 | 233 | fast-glob@3.3.3: 234 | resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} 235 | engines: {node: '>=8.6.0'} 236 | 237 | fastq@1.19.0: 238 | resolution: {integrity: sha512-7SFSRCNjBQIZH/xZR3iy5iQYR8aGBE0h3VG6/cwlbrpdciNYBMotQav8c1XI3HjHH+NikUpP53nPdlZSdWmFzA==} 239 | 240 | fdir@6.4.2: 241 | resolution: {integrity: sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==} 242 | peerDependencies: 243 | picomatch: ^3 || ^4 244 | peerDependenciesMeta: 245 | picomatch: 246 | optional: true 247 | 248 | fill-range@7.1.1: 249 | resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} 250 | engines: {node: '>=8'} 251 | 252 | find-up@4.1.0: 253 | resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} 254 | engines: {node: '>=8'} 255 | 256 | fs-extra@7.0.1: 257 | resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} 258 | engines: {node: '>=6 <7 || >=8'} 259 | 260 | fs-extra@8.1.0: 261 | resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} 262 | engines: {node: '>=6 <7 || >=8'} 263 | 264 | glob-parent@5.1.2: 265 | resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} 266 | engines: {node: '>= 6'} 267 | 268 | globby@11.1.0: 269 | resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} 270 | engines: {node: '>=10'} 271 | 272 | graceful-fs@4.2.11: 273 | resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} 274 | 275 | human-id@4.1.1: 276 | resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==} 277 | hasBin: true 278 | 279 | iconv-lite@0.4.24: 280 | resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} 281 | engines: {node: '>=0.10.0'} 282 | 283 | ignore@5.3.2: 284 | resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} 285 | engines: {node: '>= 4'} 286 | 287 | is-extglob@2.1.1: 288 | resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} 289 | engines: {node: '>=0.10.0'} 290 | 291 | is-glob@4.0.3: 292 | resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} 293 | engines: {node: '>=0.10.0'} 294 | 295 | is-number@7.0.0: 296 | resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} 297 | engines: {node: '>=0.12.0'} 298 | 299 | is-subdir@1.2.0: 300 | resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} 301 | engines: {node: '>=4'} 302 | 303 | is-windows@1.0.2: 304 | resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} 305 | engines: {node: '>=0.10.0'} 306 | 307 | isexe@2.0.0: 308 | resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} 309 | 310 | js-yaml@3.14.1: 311 | resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} 312 | hasBin: true 313 | 314 | jsonfile@4.0.0: 315 | resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} 316 | 317 | kleur@4.1.5: 318 | resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} 319 | engines: {node: '>=6'} 320 | 321 | locate-character@3.0.0: 322 | resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} 323 | 324 | locate-path@5.0.0: 325 | resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} 326 | engines: {node: '>=8'} 327 | 328 | lodash.startcase@4.4.0: 329 | resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} 330 | 331 | lru-cache@6.0.0: 332 | resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} 333 | engines: {node: '>=10'} 334 | 335 | magic-string@0.30.5: 336 | resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==} 337 | engines: {node: '>=12'} 338 | 339 | merge2@1.4.1: 340 | resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} 341 | engines: {node: '>= 8'} 342 | 343 | micromatch@4.0.8: 344 | resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} 345 | engines: {node: '>=8.6'} 346 | 347 | mri@1.2.0: 348 | resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} 349 | engines: {node: '>=4'} 350 | 351 | os-tmpdir@1.0.2: 352 | resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} 353 | engines: {node: '>=0.10.0'} 354 | 355 | outdent@0.5.0: 356 | resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} 357 | 358 | p-filter@2.1.0: 359 | resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} 360 | engines: {node: '>=8'} 361 | 362 | p-limit@2.3.0: 363 | resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} 364 | engines: {node: '>=6'} 365 | 366 | p-locate@4.1.0: 367 | resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} 368 | engines: {node: '>=8'} 369 | 370 | p-map@2.1.0: 371 | resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} 372 | engines: {node: '>=6'} 373 | 374 | p-try@2.2.0: 375 | resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} 376 | engines: {node: '>=6'} 377 | 378 | package-manager-detector@0.2.9: 379 | resolution: {integrity: sha512-+vYvA/Y31l8Zk8dwxHhL3JfTuHPm6tlxM2A3GeQyl7ovYnSp1+mzAxClxaOr0qO1TtPxbQxetI7v5XqKLJZk7Q==} 380 | 381 | path-exists@4.0.0: 382 | resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} 383 | engines: {node: '>=8'} 384 | 385 | path-key@3.1.1: 386 | resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 387 | engines: {node: '>=8'} 388 | 389 | path-type@4.0.0: 390 | resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} 391 | engines: {node: '>=8'} 392 | 393 | picocolors@1.1.1: 394 | resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} 395 | 396 | picomatch@2.3.1: 397 | resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} 398 | engines: {node: '>=8.6'} 399 | 400 | picomatch@4.0.2: 401 | resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} 402 | engines: {node: '>=12'} 403 | 404 | pify@4.0.1: 405 | resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} 406 | engines: {node: '>=6'} 407 | 408 | prettier@2.8.8: 409 | resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} 410 | engines: {node: '>=10.13.0'} 411 | hasBin: true 412 | 413 | prettier@3.0.3: 414 | resolution: {integrity: sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==} 415 | engines: {node: '>=14'} 416 | hasBin: true 417 | 418 | queue-microtask@1.2.3: 419 | resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} 420 | 421 | read-yaml-file@1.1.0: 422 | resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} 423 | engines: {node: '>=6'} 424 | 425 | regenerator-runtime@0.14.1: 426 | resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} 427 | 428 | resolve-from@5.0.0: 429 | resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} 430 | engines: {node: '>=8'} 431 | 432 | reusify@1.0.4: 433 | resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} 434 | engines: {iojs: '>=1.0.0', node: '>=0.10.0'} 435 | 436 | run-parallel@1.2.0: 437 | resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} 438 | 439 | sade@1.8.1: 440 | resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} 441 | engines: {node: '>=6'} 442 | 443 | safer-buffer@2.1.2: 444 | resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} 445 | 446 | semver@7.5.4: 447 | resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} 448 | engines: {node: '>=10'} 449 | hasBin: true 450 | 451 | shebang-command@2.0.0: 452 | resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} 453 | engines: {node: '>=8'} 454 | 455 | shebang-regex@3.0.0: 456 | resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} 457 | engines: {node: '>=8'} 458 | 459 | signal-exit@4.1.0: 460 | resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} 461 | engines: {node: '>=14'} 462 | 463 | slash@3.0.0: 464 | resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} 465 | engines: {node: '>=8'} 466 | 467 | spawndamnit@3.0.1: 468 | resolution: {integrity: sha512-MmnduQUuHCoFckZoWnXsTg7JaiLBJrKFj9UI2MbRPGaJeVpsLcVBu6P/IGZovziM/YBsellCmsprgNA+w0CzVg==} 469 | 470 | sprintf-js@1.0.3: 471 | resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} 472 | 473 | strip-ansi@6.0.1: 474 | resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} 475 | engines: {node: '>=8'} 476 | 477 | strip-bom@3.0.0: 478 | resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} 479 | engines: {node: '>=4'} 480 | 481 | term-size@2.2.1: 482 | resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} 483 | engines: {node: '>=8'} 484 | 485 | tinyglobby@0.2.10: 486 | resolution: {integrity: sha512-Zc+8eJlFMvgatPZTl6A9L/yht8QqdmUNtURHaKZLmKBE12hNPSrqNkUp2cs3M/UKmNVVAMFQYSjYIVHDjW5zew==} 487 | engines: {node: '>=12.0.0'} 488 | 489 | tmp@0.0.33: 490 | resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} 491 | engines: {node: '>=0.6.0'} 492 | 493 | to-regex-range@5.0.1: 494 | resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} 495 | engines: {node: '>=8.0'} 496 | 497 | ts-api-utils@1.0.3: 498 | resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} 499 | engines: {node: '>=16.13.0'} 500 | peerDependencies: 501 | typescript: '>=4.2.0' 502 | 503 | typescript@5.8.3: 504 | resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} 505 | engines: {node: '>=14.17'} 506 | hasBin: true 507 | 508 | undici-types@5.25.3: 509 | resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==} 510 | 511 | universalify@0.1.2: 512 | resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} 513 | engines: {node: '>= 4.0.0'} 514 | 515 | uvu@0.5.6: 516 | resolution: {integrity: sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==} 517 | engines: {node: '>=8'} 518 | hasBin: true 519 | 520 | which@2.0.2: 521 | resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} 522 | engines: {node: '>= 8'} 523 | hasBin: true 524 | 525 | yallist@4.0.0: 526 | resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} 527 | 528 | snapshots: 529 | 530 | '@babel/runtime@7.26.9': 531 | dependencies: 532 | regenerator-runtime: 0.14.1 533 | 534 | '@changesets/apply-release-plan@7.0.10': 535 | dependencies: 536 | '@changesets/config': 3.1.1 537 | '@changesets/get-version-range-type': 0.4.0 538 | '@changesets/git': 3.0.2 539 | '@changesets/should-skip-package': 0.1.2 540 | '@changesets/types': 6.1.0 541 | '@manypkg/get-packages': 1.1.3 542 | detect-indent: 6.1.0 543 | fs-extra: 7.0.1 544 | lodash.startcase: 4.4.0 545 | outdent: 0.5.0 546 | prettier: 2.8.8 547 | resolve-from: 5.0.0 548 | semver: 7.5.4 549 | 550 | '@changesets/assemble-release-plan@6.0.6': 551 | dependencies: 552 | '@changesets/errors': 0.2.0 553 | '@changesets/get-dependents-graph': 2.1.3 554 | '@changesets/should-skip-package': 0.1.2 555 | '@changesets/types': 6.1.0 556 | '@manypkg/get-packages': 1.1.3 557 | semver: 7.5.4 558 | 559 | '@changesets/changelog-git@0.2.1': 560 | dependencies: 561 | '@changesets/types': 6.1.0 562 | 563 | '@changesets/cli@2.28.1': 564 | dependencies: 565 | '@changesets/apply-release-plan': 7.0.10 566 | '@changesets/assemble-release-plan': 6.0.6 567 | '@changesets/changelog-git': 0.2.1 568 | '@changesets/config': 3.1.1 569 | '@changesets/errors': 0.2.0 570 | '@changesets/get-dependents-graph': 2.1.3 571 | '@changesets/get-release-plan': 4.0.8 572 | '@changesets/git': 3.0.2 573 | '@changesets/logger': 0.1.1 574 | '@changesets/pre': 2.0.2 575 | '@changesets/read': 0.6.3 576 | '@changesets/should-skip-package': 0.1.2 577 | '@changesets/types': 6.1.0 578 | '@changesets/write': 0.4.0 579 | '@manypkg/get-packages': 1.1.3 580 | ansi-colors: 4.1.3 581 | ci-info: 3.9.0 582 | enquirer: 2.4.1 583 | external-editor: 3.1.0 584 | fs-extra: 7.0.1 585 | mri: 1.2.0 586 | p-limit: 2.3.0 587 | package-manager-detector: 0.2.9 588 | picocolors: 1.1.1 589 | resolve-from: 5.0.0 590 | semver: 7.5.4 591 | spawndamnit: 3.0.1 592 | term-size: 2.2.1 593 | 594 | '@changesets/config@3.1.1': 595 | dependencies: 596 | '@changesets/errors': 0.2.0 597 | '@changesets/get-dependents-graph': 2.1.3 598 | '@changesets/logger': 0.1.1 599 | '@changesets/types': 6.1.0 600 | '@manypkg/get-packages': 1.1.3 601 | fs-extra: 7.0.1 602 | micromatch: 4.0.8 603 | 604 | '@changesets/errors@0.2.0': 605 | dependencies: 606 | extendable-error: 0.1.7 607 | 608 | '@changesets/get-dependents-graph@2.1.3': 609 | dependencies: 610 | '@changesets/types': 6.1.0 611 | '@manypkg/get-packages': 1.1.3 612 | picocolors: 1.1.1 613 | semver: 7.5.4 614 | 615 | '@changesets/get-release-plan@4.0.8': 616 | dependencies: 617 | '@changesets/assemble-release-plan': 6.0.6 618 | '@changesets/config': 3.1.1 619 | '@changesets/pre': 2.0.2 620 | '@changesets/read': 0.6.3 621 | '@changesets/types': 6.1.0 622 | '@manypkg/get-packages': 1.1.3 623 | 624 | '@changesets/get-version-range-type@0.4.0': {} 625 | 626 | '@changesets/git@3.0.2': 627 | dependencies: 628 | '@changesets/errors': 0.2.0 629 | '@manypkg/get-packages': 1.1.3 630 | is-subdir: 1.2.0 631 | micromatch: 4.0.8 632 | spawndamnit: 3.0.1 633 | 634 | '@changesets/logger@0.1.1': 635 | dependencies: 636 | picocolors: 1.1.1 637 | 638 | '@changesets/parse@0.4.1': 639 | dependencies: 640 | '@changesets/types': 6.1.0 641 | js-yaml: 3.14.1 642 | 643 | '@changesets/pre@2.0.2': 644 | dependencies: 645 | '@changesets/errors': 0.2.0 646 | '@changesets/types': 6.1.0 647 | '@manypkg/get-packages': 1.1.3 648 | fs-extra: 7.0.1 649 | 650 | '@changesets/read@0.6.3': 651 | dependencies: 652 | '@changesets/git': 3.0.2 653 | '@changesets/logger': 0.1.1 654 | '@changesets/parse': 0.4.1 655 | '@changesets/types': 6.1.0 656 | fs-extra: 7.0.1 657 | p-filter: 2.1.0 658 | picocolors: 1.1.1 659 | 660 | '@changesets/should-skip-package@0.1.2': 661 | dependencies: 662 | '@changesets/types': 6.1.0 663 | '@manypkg/get-packages': 1.1.3 664 | 665 | '@changesets/types@4.1.0': {} 666 | 667 | '@changesets/types@6.1.0': {} 668 | 669 | '@changesets/write@0.4.0': 670 | dependencies: 671 | '@changesets/types': 6.1.0 672 | fs-extra: 7.0.1 673 | human-id: 4.1.1 674 | prettier: 2.8.8 675 | 676 | '@jridgewell/gen-mapping@0.3.3': 677 | dependencies: 678 | '@jridgewell/set-array': 1.1.2 679 | '@jridgewell/sourcemap-codec': 1.4.15 680 | '@jridgewell/trace-mapping': 0.3.19 681 | 682 | '@jridgewell/resolve-uri@3.1.1': {} 683 | 684 | '@jridgewell/set-array@1.1.2': {} 685 | 686 | '@jridgewell/source-map@0.3.5': 687 | dependencies: 688 | '@jridgewell/gen-mapping': 0.3.3 689 | '@jridgewell/trace-mapping': 0.3.19 690 | 691 | '@jridgewell/sourcemap-codec@1.4.15': {} 692 | 693 | '@jridgewell/trace-mapping@0.3.19': 694 | dependencies: 695 | '@jridgewell/resolve-uri': 3.1.1 696 | '@jridgewell/sourcemap-codec': 1.4.15 697 | 698 | '@manypkg/find-root@1.1.0': 699 | dependencies: 700 | '@babel/runtime': 7.26.9 701 | '@types/node': 12.20.55 702 | find-up: 4.1.0 703 | fs-extra: 8.1.0 704 | 705 | '@manypkg/get-packages@1.1.3': 706 | dependencies: 707 | '@babel/runtime': 7.26.9 708 | '@changesets/types': 4.1.0 709 | '@manypkg/find-root': 1.1.0 710 | fs-extra: 8.1.0 711 | globby: 11.1.0 712 | read-yaml-file: 1.1.0 713 | 714 | '@nodelib/fs.scandir@2.1.5': 715 | dependencies: 716 | '@nodelib/fs.stat': 2.0.5 717 | run-parallel: 1.2.0 718 | 719 | '@nodelib/fs.stat@2.0.5': {} 720 | 721 | '@nodelib/fs.walk@1.2.8': 722 | dependencies: 723 | '@nodelib/fs.scandir': 2.1.5 724 | fastq: 1.19.0 725 | 726 | '@types/node@12.20.55': {} 727 | 728 | '@types/node@20.8.6': 729 | dependencies: 730 | undici-types: 5.25.3 731 | 732 | '@types/semver@7.5.3': {} 733 | 734 | ansi-colors@4.1.3: {} 735 | 736 | ansi-regex@5.0.1: {} 737 | 738 | argparse@1.0.10: 739 | dependencies: 740 | sprintf-js: 1.0.3 741 | 742 | array-union@2.1.0: {} 743 | 744 | better-path-resolve@1.0.0: 745 | dependencies: 746 | is-windows: 1.0.2 747 | 748 | braces@3.0.3: 749 | dependencies: 750 | fill-range: 7.1.1 751 | 752 | chardet@0.7.0: {} 753 | 754 | ci-info@3.9.0: {} 755 | 756 | cross-spawn@7.0.6: 757 | dependencies: 758 | path-key: 3.1.1 759 | shebang-command: 2.0.0 760 | which: 2.0.2 761 | 762 | dequal@2.0.3: {} 763 | 764 | detect-indent@6.1.0: {} 765 | 766 | diff@5.1.0: {} 767 | 768 | dir-glob@3.0.1: 769 | dependencies: 770 | path-type: 4.0.0 771 | 772 | enquirer@2.4.1: 773 | dependencies: 774 | ansi-colors: 4.1.3 775 | strip-ansi: 6.0.1 776 | 777 | esprima@4.0.1: {} 778 | 779 | extendable-error@0.1.7: {} 780 | 781 | external-editor@3.1.0: 782 | dependencies: 783 | chardet: 0.7.0 784 | iconv-lite: 0.4.24 785 | tmp: 0.0.33 786 | 787 | fast-glob@3.3.3: 788 | dependencies: 789 | '@nodelib/fs.stat': 2.0.5 790 | '@nodelib/fs.walk': 1.2.8 791 | glob-parent: 5.1.2 792 | merge2: 1.4.1 793 | micromatch: 4.0.8 794 | 795 | fastq@1.19.0: 796 | dependencies: 797 | reusify: 1.0.4 798 | 799 | fdir@6.4.2(picomatch@4.0.2): 800 | optionalDependencies: 801 | picomatch: 4.0.2 802 | 803 | fill-range@7.1.1: 804 | dependencies: 805 | to-regex-range: 5.0.1 806 | 807 | find-up@4.1.0: 808 | dependencies: 809 | locate-path: 5.0.0 810 | path-exists: 4.0.0 811 | 812 | fs-extra@7.0.1: 813 | dependencies: 814 | graceful-fs: 4.2.11 815 | jsonfile: 4.0.0 816 | universalify: 0.1.2 817 | 818 | fs-extra@8.1.0: 819 | dependencies: 820 | graceful-fs: 4.2.11 821 | jsonfile: 4.0.0 822 | universalify: 0.1.2 823 | 824 | glob-parent@5.1.2: 825 | dependencies: 826 | is-glob: 4.0.3 827 | 828 | globby@11.1.0: 829 | dependencies: 830 | array-union: 2.1.0 831 | dir-glob: 3.0.1 832 | fast-glob: 3.3.3 833 | ignore: 5.3.2 834 | merge2: 1.4.1 835 | slash: 3.0.0 836 | 837 | graceful-fs@4.2.11: {} 838 | 839 | human-id@4.1.1: {} 840 | 841 | iconv-lite@0.4.24: 842 | dependencies: 843 | safer-buffer: 2.1.2 844 | 845 | ignore@5.3.2: {} 846 | 847 | is-extglob@2.1.1: {} 848 | 849 | is-glob@4.0.3: 850 | dependencies: 851 | is-extglob: 2.1.1 852 | 853 | is-number@7.0.0: {} 854 | 855 | is-subdir@1.2.0: 856 | dependencies: 857 | better-path-resolve: 1.0.0 858 | 859 | is-windows@1.0.2: {} 860 | 861 | isexe@2.0.0: {} 862 | 863 | js-yaml@3.14.1: 864 | dependencies: 865 | argparse: 1.0.10 866 | esprima: 4.0.1 867 | 868 | jsonfile@4.0.0: 869 | optionalDependencies: 870 | graceful-fs: 4.2.11 871 | 872 | kleur@4.1.5: {} 873 | 874 | locate-character@3.0.0: {} 875 | 876 | locate-path@5.0.0: 877 | dependencies: 878 | p-locate: 4.1.0 879 | 880 | lodash.startcase@4.4.0: {} 881 | 882 | lru-cache@6.0.0: 883 | dependencies: 884 | yallist: 4.0.0 885 | 886 | magic-string@0.30.5: 887 | dependencies: 888 | '@jridgewell/sourcemap-codec': 1.4.15 889 | 890 | merge2@1.4.1: {} 891 | 892 | micromatch@4.0.8: 893 | dependencies: 894 | braces: 3.0.3 895 | picomatch: 2.3.1 896 | 897 | mri@1.2.0: {} 898 | 899 | os-tmpdir@1.0.2: {} 900 | 901 | outdent@0.5.0: {} 902 | 903 | p-filter@2.1.0: 904 | dependencies: 905 | p-map: 2.1.0 906 | 907 | p-limit@2.3.0: 908 | dependencies: 909 | p-try: 2.2.0 910 | 911 | p-locate@4.1.0: 912 | dependencies: 913 | p-limit: 2.3.0 914 | 915 | p-map@2.1.0: {} 916 | 917 | p-try@2.2.0: {} 918 | 919 | package-manager-detector@0.2.9: {} 920 | 921 | path-exists@4.0.0: {} 922 | 923 | path-key@3.1.1: {} 924 | 925 | path-type@4.0.0: {} 926 | 927 | picocolors@1.1.1: {} 928 | 929 | picomatch@2.3.1: {} 930 | 931 | picomatch@4.0.2: {} 932 | 933 | pify@4.0.1: {} 934 | 935 | prettier@2.8.8: {} 936 | 937 | prettier@3.0.3: {} 938 | 939 | queue-microtask@1.2.3: {} 940 | 941 | read-yaml-file@1.1.0: 942 | dependencies: 943 | graceful-fs: 4.2.11 944 | js-yaml: 3.14.1 945 | pify: 4.0.1 946 | strip-bom: 3.0.0 947 | 948 | regenerator-runtime@0.14.1: {} 949 | 950 | resolve-from@5.0.0: {} 951 | 952 | reusify@1.0.4: {} 953 | 954 | run-parallel@1.2.0: 955 | dependencies: 956 | queue-microtask: 1.2.3 957 | 958 | sade@1.8.1: 959 | dependencies: 960 | mri: 1.2.0 961 | 962 | safer-buffer@2.1.2: {} 963 | 964 | semver@7.5.4: 965 | dependencies: 966 | lru-cache: 6.0.0 967 | 968 | shebang-command@2.0.0: 969 | dependencies: 970 | shebang-regex: 3.0.0 971 | 972 | shebang-regex@3.0.0: {} 973 | 974 | signal-exit@4.1.0: {} 975 | 976 | slash@3.0.0: {} 977 | 978 | spawndamnit@3.0.1: 979 | dependencies: 980 | cross-spawn: 7.0.6 981 | signal-exit: 4.1.0 982 | 983 | sprintf-js@1.0.3: {} 984 | 985 | strip-ansi@6.0.1: 986 | dependencies: 987 | ansi-regex: 5.0.1 988 | 989 | strip-bom@3.0.0: {} 990 | 991 | term-size@2.2.1: {} 992 | 993 | tinyglobby@0.2.10: 994 | dependencies: 995 | fdir: 6.4.2(picomatch@4.0.2) 996 | picomatch: 4.0.2 997 | 998 | tmp@0.0.33: 999 | dependencies: 1000 | os-tmpdir: 1.0.2 1001 | 1002 | to-regex-range@5.0.1: 1003 | dependencies: 1004 | is-number: 7.0.0 1005 | 1006 | ts-api-utils@1.0.3(typescript@5.8.3): 1007 | dependencies: 1008 | typescript: 5.8.3 1009 | 1010 | typescript@5.8.3: {} 1011 | 1012 | undici-types@5.25.3: {} 1013 | 1014 | universalify@0.1.2: {} 1015 | 1016 | uvu@0.5.6: 1017 | dependencies: 1018 | dequal: 2.0.3 1019 | diff: 5.1.0 1020 | kleur: 4.1.5 1021 | sade: 1.8.1 1022 | 1023 | which@2.0.2: 1024 | dependencies: 1025 | isexe: 2.0.0 1026 | 1027 | yallist@4.0.0: {} 1028 | --------------------------------------------------------------------------------