Skip to content

Commit 39b97a4

Browse files
committed
refactor!: expose internal utilities
1 parent 9522781 commit 39b97a4

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

dts.snapshot.json

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
{
2-
"context-!~{002}~.d.mts": {
2+
"context-!~{003}~.d.mts": {
33
"createContext": "declare function createContext(): TscContext",
44
"globalContext": "TscContext",
55
"invalidateContextFile": "declare function invalidateContextFile(_: TscContext, _: string): void",
66
"ParsedProject": "interface ParsedProject {\n tsconfigPath: string\n parsedConfig: ts.ParsedCommandLine\n}",
77
"SourceFileToProjectMap": "type SourceFileToProjectMap = Map<string, ParsedProject>",
88
"TscContext": "interface TscContext {\n programs: ts.Program[]\n files: Map<string, string>\n projects: Map<string, SourceFileToProjectMap>\n}"
99
},
10-
"filename.d.mts": {
10+
"index-!~{004}~.d.mts": {
11+
"tscEmit": "declare function tscEmit(_: TscOptions): TscResult",
12+
"TscModule": "interface TscModule {\n program: ts.Program\n file: ts.SourceFile\n}",
13+
"TscOptions": "interface TscOptions {\n tsconfig?: string\n tsconfigRaw: TsConfigJson\n cwd: string\n build: boolean\n incremental: boolean\n entries?: string[]\n id: string\n sourcemap: boolean\n vue?: boolean\n tsMacro?: boolean\n context?: TscContext\n}",
14+
"TscResult": "interface TscResult {\n code?: string\n map?: SourceMapInput\n error?: string\n}"
15+
},
16+
"index.d.mts": {
17+
"createFakeJsPlugin": "declare function createFakeJsPlugin(_: Pick<OptionsResolved, 'sourcemap' | 'cjsDefault' | 'sideEffects'>): Plugin",
18+
"createGeneratePlugin": "declare function createGeneratePlugin(_: Pick<OptionsResolved, 'cwd' | 'tsconfig' | 'tsconfigRaw' | 'build' | 'incremental' | 'oxc' | 'emitDtsOnly' | 'vue' | 'tsMacro' | 'parallel' | 'eager' | 'tsgo' | 'newContext' | 'emitJs' | 'sourcemap'>): Plugin",
19+
"dts": "declare function dts(_: Options): Plugin[]",
20+
"GeneralOptions": "interface GeneralOptions {\n cwd?: string\n dtsInput?: boolean\n emitDtsOnly?: boolean\n tsconfig?: string | boolean\n tsconfigRaw?: Omit<TsConfigJson, 'compilerOptions'>\n compilerOptions?: TsConfigJson.CompilerOptions\n sourcemap?: boolean\n resolver?: 'oxc' | 'tsc'\n cjsDefault?: boolean\n sideEffects?: boolean\n}",
21+
"Options": "interface Options extends GeneralOptions, TscOptions {\n oxc?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>\n tsgo?: boolean | TsgoOptions\n}",
22+
"OptionsResolved": "type OptionsResolved = Overwrite<Required<Omit<Options, 'compilerOptions'>>, { tsconfig?: string; oxc: IsolatedDeclarationsOptions | false; tsconfigRaw: TsConfigJson; tsgo: Omit<TsgoOptions, 'enabled'> | false }>",
23+
"Overwrite": "type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U",
24+
"resolveOptions": "declare function resolveOptions(_: Options): OptionsResolved",
25+
"TscOptions": "interface TscOptions {\n build?: boolean\n incremental?: boolean\n vue?: boolean\n tsMacro?: boolean\n parallel?: boolean\n eager?: boolean\n newContext?: boolean\n emitJs?: boolean\n}",
26+
"TsgoOptions": "interface TsgoOptions {\n enabled?: boolean\n path?: string\n}",
27+
"#exports": [
28+
"Options",
29+
"createFakeJsPlugin",
30+
"createGeneratePlugin",
31+
"dts",
32+
"resolveOptions"
33+
]
34+
},
35+
"internal.d.mts": {
1136
"filename_dts_to": "declare function filename_dts_to(_: string, _: 'js' | 'ts'): string",
1237
"filename_js_to_dts": "declare function filename_js_to_dts(_: string): string",
1338
"filename_to_dts": "declare function filename_to_dts(_: string): string",
@@ -35,35 +60,11 @@
3560
"filename_dts_to",
3661
"filename_js_to_dts",
3762
"filename_to_dts",
63+
"parseTsconfig",
3864
"replaceTemplateName",
3965
"resolveTemplateFn"
4066
]
4167
},
42-
"index-!~{003}~.d.mts": {
43-
"tscEmit": "declare function tscEmit(_: TscOptions): TscResult",
44-
"TscModule": "interface TscModule {\n program: ts.Program\n file: ts.SourceFile\n}",
45-
"TscOptions": "interface TscOptions {\n tsconfig?: string\n tsconfigRaw: TsConfigJson\n cwd: string\n build: boolean\n incremental: boolean\n entries?: string[]\n id: string\n sourcemap: boolean\n vue?: boolean\n tsMacro?: boolean\n context?: TscContext\n}",
46-
"TscResult": "interface TscResult {\n code?: string\n map?: SourceMapInput\n error?: string\n}"
47-
},
48-
"index.d.mts": {
49-
"createFakeJsPlugin": "declare function createFakeJsPlugin(_: Pick<OptionsResolved, 'sourcemap' | 'cjsDefault' | 'sideEffects'>): Plugin",
50-
"createGeneratePlugin": "declare function createGeneratePlugin(_: Pick<OptionsResolved, 'cwd' | 'tsconfig' | 'tsconfigRaw' | 'build' | 'incremental' | 'oxc' | 'emitDtsOnly' | 'vue' | 'tsMacro' | 'parallel' | 'eager' | 'tsgo' | 'newContext' | 'emitJs' | 'sourcemap'>): Plugin",
51-
"dts": "declare function dts(_: Options): Plugin[]",
52-
"GeneralOptions": "interface GeneralOptions {\n cwd?: string\n dtsInput?: boolean\n emitDtsOnly?: boolean\n tsconfig?: string | boolean\n tsconfigRaw?: Omit<TsConfigJson, 'compilerOptions'>\n compilerOptions?: TsConfigJson.CompilerOptions\n sourcemap?: boolean\n resolver?: 'oxc' | 'tsc'\n cjsDefault?: boolean\n sideEffects?: boolean\n}",
53-
"Options": "interface Options extends GeneralOptions, TscOptions {\n oxc?: boolean | Omit<IsolatedDeclarationsOptions, 'sourcemap'>\n tsgo?: boolean | TsgoOptions\n}",
54-
"OptionsResolved": "type OptionsResolved = Overwrite<Required<Omit<Options, 'compilerOptions'>>, { tsconfig?: string; oxc: IsolatedDeclarationsOptions | false; tsconfigRaw: TsConfigJson; tsgo: Omit<TsgoOptions, 'enabled'> | false }>",
55-
"Overwrite": "type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U",
56-
"resolveOptions": "declare function resolveOptions(_: Options): OptionsResolved",
57-
"TscOptions": "interface TscOptions {\n build?: boolean\n incremental?: boolean\n vue?: boolean\n tsMacro?: boolean\n parallel?: boolean\n eager?: boolean\n newContext?: boolean\n emitJs?: boolean\n}",
58-
"TsgoOptions": "interface TsgoOptions {\n enabled?: boolean\n path?: string\n}",
59-
"#exports": [
60-
"Options",
61-
"createFakeJsPlugin",
62-
"createGeneratePlugin",
63-
"dts",
64-
"resolveOptions"
65-
]
66-
},
6768
"tsc-context.d.mts": {
6869
"#exports": [
6970
"ParsedProject",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"exports": {
2727
".": "./dist/index.mjs",
28-
"./filename": "./dist/filename.mjs",
28+
"./internal": "./dist/internal.mjs",
2929
"./tsc": "./dist/tsc.mjs",
3030
"./tsc-context": "./dist/tsc-context.mjs",
3131
"./tsc-worker": "./dist/tsc-worker.mjs",

src/internal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './filename.ts'
2+
export { parseTsconfig } from 'get-tsconfig'

tsdown.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { dts } from './src/index.ts'
77
export default defineConfig({
88
entry: {
99
index: './src/index.ts',
10-
filename: './src/filename.ts',
10+
internal: './src/internal.ts',
1111
tsc: './src/tsc/index.ts',
1212
'tsc-context': './src/tsc/context.ts',
1313
'tsc-worker': './src/tsc/worker.ts',
@@ -18,7 +18,7 @@ export default defineConfig({
1818
'import.meta.WORKER_URL': JSON.stringify('./tsc-worker.mjs'),
1919
},
2020
deps: {
21-
onlyAllowBundle: [],
21+
onlyBundle: [],
2222
},
2323
treeshake: {
2424
moduleSideEffects: false,
@@ -34,7 +34,6 @@ export default defineConfig({
3434
// perf: TypeScript is large and takes time to detect ESM/CJS.
3535
if (id === 'typescript') return true
3636
},
37-
builtinNodeModules: true,
3837
}),
3938
],
4039
})

0 commit comments

Comments
 (0)