@d1g1tal/tsbuild 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +388 -0
- package/dist/44KSX2XO.js +269 -0
- package/dist/QAEHWWWE.js +47 -0
- package/dist/QDB5Y2PO.js +2229 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.js +7 -0
- package/dist/tsbuild.js +45 -0
- package/package.json +73 -0
- package/schema.json +200 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 D1g1talEntr0py
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# tsbuild
|
|
2
|
+
|
|
3
|
+
A self-hosting TypeScript build tool that combines the best of three worlds: **TypeScript's type system**, **esbuild's speed**, and **SWC's decorator metadata support**. tsbuild is designed for modern ESM-only projects targeting Node.js 20.16.0+.
|
|
4
|
+
|
|
5
|
+
> **โ ๏ธ Note:** This is an experimental project for personal use. For production use, consider [tsup](https://tsup.egoist.dev/) instead, which is mature, battle-tested, and widely adopted. Or check out the new [tsdown](https://tsdown.dev/) by [void(0)](https://voidzero.dev/).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- ๐ **Blazing Fast** - Leverages esbuild for rapid bundling and transpilation
|
|
10
|
+
- ๐ **Full Type Safety** - Uses TypeScript API for comprehensive type checking
|
|
11
|
+
- ๐ฆ **Declaration Bundling** - Automatically bundles `.d.ts` files into single entry points
|
|
12
|
+
- โก **Incremental Builds** - Intelligent caching with `.tsbuildinfo` for fast rebuilds
|
|
13
|
+
- ๐๏ธ **Watch Mode** - File watching with automatic rebuilds on changes
|
|
14
|
+
- ๐จ **Decorator Metadata** - Optional SWC integration for `emitDecoratorMetadata` support for legacy decorators (Will probably be removed at some point in favor of native ESM decorators only)
|
|
15
|
+
- ๐ **Plugin System** - Extensible architecture with custom esbuild plugins
|
|
16
|
+
- ๐ฏ **ESM-Only** - Pure ESM project with no CommonJS support by design
|
|
17
|
+
- ๐งน **Clean Builds** - Optional output directory cleaning before builds
|
|
18
|
+
- ๐ **Performance Metrics** - Built-in performance logging with detailed timing information
|
|
19
|
+
|
|
20
|
+
## Why tsbuild?
|
|
21
|
+
|
|
22
|
+
tsbuild orchestrates a sophisticated three-phase build process:
|
|
23
|
+
|
|
24
|
+
1. **Type Checking Phase** - TypeScript compiler validates types and emits `.d.ts` files into memory (not disk)
|
|
25
|
+
2. **Transpile Phase** - esbuild bundles JavaScript with custom plugins for module resolution and output formatting
|
|
26
|
+
3. **DTS Bundle Phase** - Custom minimal bundler combines declaration files through dependency graph traversal and AST transformation
|
|
27
|
+
|
|
28
|
+
This separation of concerns ensures TypeScript handles correctness, esbuild handles speed, and the custom bundler handles declaration consolidation efficiently without creating duplicate TypeScript Programs.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# pnpm - no SWC dependency (optional for decorator metadata)
|
|
34
|
+
pnpm add -D @d1g1tal/tsbuild --no-optional
|
|
35
|
+
|
|
36
|
+
# pnpm - with SWC dependency (for decorator metadata)
|
|
37
|
+
pnpm add -D @d1g1tal/tsbuild
|
|
38
|
+
|
|
39
|
+
# npm
|
|
40
|
+
npm install -D @d1g1tal/tsbuild
|
|
41
|
+
|
|
42
|
+
# yarn
|
|
43
|
+
yarn add -D @d1g1tal/tsbuild
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Requirements
|
|
47
|
+
|
|
48
|
+
- **Node.js**: >=20.16.0
|
|
49
|
+
- **pnpm**: >=9.0.0
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Configuration
|
|
54
|
+
|
|
55
|
+
Add a `tsbuild` property to your `tsconfig.json`:
|
|
56
|
+
|
|
57
|
+
```jsonc
|
|
58
|
+
{
|
|
59
|
+
"compilerOptions": {
|
|
60
|
+
"declaration": true,
|
|
61
|
+
"isolatedModules": true,
|
|
62
|
+
"isolatedDeclarations": true,
|
|
63
|
+
"target": "ESNext",
|
|
64
|
+
"module": "ESNext",
|
|
65
|
+
"lib": [ "ESNext", "DOM" ],
|
|
66
|
+
"outDir": "./dist", // default value
|
|
67
|
+
// ... other TypeScript options
|
|
68
|
+
},
|
|
69
|
+
"tsbuild": {
|
|
70
|
+
"clean": true, // Remove all files from output directory before building (default: true)
|
|
71
|
+
"platform": "node", // Will default to "browser" if "DOM" is found in "lib", otherwise "node"
|
|
72
|
+
"entryPoints": {
|
|
73
|
+
"cli": "./src/cli.ts",
|
|
74
|
+
"index": "./src/index.ts"
|
|
75
|
+
},
|
|
76
|
+
"dts": {
|
|
77
|
+
"entryPoints": [ "index" ] // Only bundle declarations for index
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### CLI Commands
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Build once
|
|
87
|
+
tsbuild
|
|
88
|
+
|
|
89
|
+
# Minify build output
|
|
90
|
+
tsbuild --minify # or -m
|
|
91
|
+
|
|
92
|
+
# Force a full rebuild, bypassing incremental compilation.
|
|
93
|
+
tsbuild --force # or -f
|
|
94
|
+
|
|
95
|
+
# Clear the incremental build cache (.tsbuild/dts_cache.v8.br) before building.
|
|
96
|
+
tsbuild --clearCache # or -c
|
|
97
|
+
|
|
98
|
+
# Build with watch mode
|
|
99
|
+
tsbuild --watch # or -w
|
|
100
|
+
|
|
101
|
+
# Type-check only (no bundling)
|
|
102
|
+
tsbuild --noEmit # or -n
|
|
103
|
+
|
|
104
|
+
# Use custom tsconfig
|
|
105
|
+
tsbuild --project ./tsconfig.build.json # or -p
|
|
106
|
+
|
|
107
|
+
# Display help
|
|
108
|
+
tsbuild --help # or -h
|
|
109
|
+
|
|
110
|
+
# Display version
|
|
111
|
+
tsbuild --version # or -v
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> **Note**: `--watch` and `--force` are CLI-only options. If you configure `watch` or `force` in the config, it will be ignored.
|
|
115
|
+
|
|
116
|
+
### Package.json Scripts
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"scripts": {
|
|
121
|
+
"build": "tsbuild",
|
|
122
|
+
"build:watch": "tsbuild --watch",
|
|
123
|
+
"build:force": "tsbuild --force",
|
|
124
|
+
"type-check": "tsbuild --noEmit"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Configuration Options
|
|
130
|
+
|
|
131
|
+
tsbuild supports a comprehensive set of options (full schema available in [`schema.json`](./schema.json)):
|
|
132
|
+
|
|
133
|
+
### Entry Points
|
|
134
|
+
|
|
135
|
+
```jsonc
|
|
136
|
+
{
|
|
137
|
+
"tsbuild": {
|
|
138
|
+
// Object syntax - recommended for named outputs
|
|
139
|
+
"entryPoints": {
|
|
140
|
+
"cli": "./src/cli.ts",
|
|
141
|
+
"index": "./src/index.ts"
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
// Array syntax - auto-names based on file names
|
|
145
|
+
"entryPoints": ["./src/index.ts", "./src/cli.ts"]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
If a directory is provided, all files within will be used as entry points.
|
|
151
|
+
|
|
152
|
+
### Declaration Bundling
|
|
153
|
+
|
|
154
|
+
```jsonc
|
|
155
|
+
{
|
|
156
|
+
"tsbuild": {
|
|
157
|
+
"dts": {}, // Use defaults (bundle declarations for all entry points)
|
|
158
|
+
|
|
159
|
+
// Or configure specific options
|
|
160
|
+
"dts": {
|
|
161
|
+
"entryPoints": ["index", "cli"], // Names from entryPoints object
|
|
162
|
+
"resolve": false // true = bundle external types from node_modules
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The `resolve` option controls whether to bundle external types from `node_modules` into your declaration files. When `false` (default for Node.js), external imports remain as import statements. When `true`, the bundler attempts to inline external types. This defaults to:
|
|
169
|
+
- `false` for `platform: "node"` (recommended for Node.js projects - keeps external types as imports)
|
|
170
|
+
- `true` for `platform: "browser"` and `platform: "neutral"` (bundles everything for standalone distribution)
|
|
171
|
+
|
|
172
|
+
### External Dependencies
|
|
173
|
+
|
|
174
|
+
```jsonc
|
|
175
|
+
{
|
|
176
|
+
"tsbuild": {
|
|
177
|
+
// Don't bundle these modules (keep as imports)
|
|
178
|
+
"external": ["typescript", "esbuild"],
|
|
179
|
+
|
|
180
|
+
// Always bundle these modules (even if in dependencies)
|
|
181
|
+
"noExternal": ["lodash-es"],
|
|
182
|
+
|
|
183
|
+
// Bundle strategy: 'bundle' includes deps, 'external' excludes them
|
|
184
|
+
"packages": "external"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
By default, bare specifiers (e.g., `lodash`) are treated as external when `platform: "node"`. Use `noExternal` to force bundling specific packages.
|
|
190
|
+
|
|
191
|
+
### Other Options
|
|
192
|
+
|
|
193
|
+
```jsonc
|
|
194
|
+
{
|
|
195
|
+
"tsbuild": {
|
|
196
|
+
"platform": "node", // Target platform: 'node' | 'browser' | 'neutral'
|
|
197
|
+
"clean": true, // Remove output directory contents before building (default: true)
|
|
198
|
+
"minify": false, // Minify output
|
|
199
|
+
"sourceMap": true, // Generate source maps (boolean | 'inline' | 'external' | 'both')
|
|
200
|
+
"splitting": true, // Enable code splitting
|
|
201
|
+
"bundle": true, // Enable/disable bundling
|
|
202
|
+
"force": false, // Force full rebuild, bypassing incremental cache
|
|
203
|
+
"banner": { // Inject code at start of files
|
|
204
|
+
"js": "#!/usr/bin/env node"
|
|
205
|
+
},
|
|
206
|
+
"footer": { // Inject code at end of files
|
|
207
|
+
"js": "// Copyright 2025"
|
|
208
|
+
},
|
|
209
|
+
"env": { // Environment variables (accessible via import.meta.env)
|
|
210
|
+
"API_URL": "https://api.example.com"
|
|
211
|
+
},
|
|
212
|
+
"watch": { // Watch mode configuration
|
|
213
|
+
"enabled": false, // Set via --watch CLI flag
|
|
214
|
+
"ignore": ["**/*.test.ts"]
|
|
215
|
+
},
|
|
216
|
+
"plugins": [] // Custom esbuild plugins (programmatic API only)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Note:** The `target` and `outDir` options come from `tsconfig.json` `compilerOptions` and cannot be overridden in the `tsbuild` section. The `force` and `minify` options are typically better controlled via CLI flags (`--force`, `--minify`) rather than in the config.
|
|
222
|
+
|
|
223
|
+
## Advanced Features
|
|
224
|
+
|
|
225
|
+
### Decorator Metadata
|
|
226
|
+
|
|
227
|
+
tsbuild supports `emitDecoratorMetadata` through SWC integration:
|
|
228
|
+
|
|
229
|
+
```jsonc
|
|
230
|
+
{
|
|
231
|
+
"compilerOptions": {
|
|
232
|
+
"experimentalDecorators": true,
|
|
233
|
+
"emitDecoratorMetadata": true
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
You must have `@swc/core` installed (as an optional dependency) for this feature to work:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
pnpm add -D @swc/core
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Custom Plugins
|
|
245
|
+
|
|
246
|
+
tsbuild supports custom esbuild plugins:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import { TypeScriptProject } from 'tsbuild';
|
|
250
|
+
|
|
251
|
+
const myPlugin = {
|
|
252
|
+
name: 'my-plugin',
|
|
253
|
+
setup(build) {
|
|
254
|
+
// Your plugin logic
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// In tsconfig.json, plugins aren't directly supported
|
|
259
|
+
// You'll need to use the TypeScriptProject API directly
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Lifecycle Management
|
|
263
|
+
|
|
264
|
+
tsbuild includes built-in decorators for resource management:
|
|
265
|
+
|
|
266
|
+
- `@closeOnExit` - Automatically cleanup resources on process exit or SIGINT
|
|
267
|
+
- `@logPerformance` - Wraps async methods with performance timing
|
|
268
|
+
|
|
269
|
+
These are used internally but can be leveraged when extending tsbuild.
|
|
270
|
+
|
|
271
|
+
## Architecture
|
|
272
|
+
|
|
273
|
+
### Core Components
|
|
274
|
+
|
|
275
|
+
**TypeScriptProject** (`src/type-script-project.ts`) - Central orchestrator that manages the build lifecycle
|
|
276
|
+
**FileManager** (`src/file-manager.ts`) - In-memory `.d.ts` storage with optional caching support
|
|
277
|
+
**IncrementalBuildCache** (`src/incremental-build-cache.ts`) - Brotli-compressed caching to `.tsbuild/dts_cache.v8.br`
|
|
278
|
+
**ProcessManager** (`src/process-manager.ts`) - Global cleanup coordinator for graceful shutdowns
|
|
279
|
+
|
|
280
|
+
### Plugin System
|
|
281
|
+
|
|
282
|
+
**External Modules Plugin** - Pattern-based external dependency resolution
|
|
283
|
+
**Output Plugin** - Handles file writing and executable permissions (shebangs get 0o755)
|
|
284
|
+
**Decorator Metadata Plugin** - Optional SWC transform for decorator metadata
|
|
285
|
+
|
|
286
|
+
### DTS Bundling System
|
|
287
|
+
|
|
288
|
+
The declaration bundling system (`src/dts/declaration-bundler.ts`) is a custom implementation that:
|
|
289
|
+
|
|
290
|
+
1. **Module Graph Building** - Traverses import/export statements to build dependency graph using TypeScript's module resolution
|
|
291
|
+
2. **Dependency Sorting** - Topologically sorts modules to ensure correct declaration order
|
|
292
|
+
3. **Code Combination** - Strips imports/exports while preserving external references
|
|
293
|
+
4. **Pre/Post Processing** (`declaration-processor.ts`) - Cleans up directives, splits declarations, fixes modifiers, normalizes exports
|
|
294
|
+
|
|
295
|
+
This custom bundler works entirely with in-memory declaration files, avoiding the overhead of duplicate TypeScript Program creation with some other bundlers.
|
|
296
|
+
|
|
297
|
+
## Performance
|
|
298
|
+
|
|
299
|
+
tsbuild is designed for speed:
|
|
300
|
+
|
|
301
|
+
- **Incremental builds** - Only recompiles changed files
|
|
302
|
+
- **In-memory declarations** - No intermediate disk I/O for `.d.ts` files
|
|
303
|
+
- **Parallel processing** - Type checking and transpilation run in parallel when possible
|
|
304
|
+
- **Smart caching** - Leverages `.tsbuildinfo` for TypeScript incremental compilation
|
|
305
|
+
|
|
306
|
+
Typical build times for the tsbuild project itself:
|
|
307
|
+
- Full build: ~400-600ms
|
|
308
|
+
- Incremental rebuild: ~100-200ms
|
|
309
|
+
- Type-check only: ~50-100ms
|
|
310
|
+
|
|
311
|
+
## Acknowledgments
|
|
312
|
+
|
|
313
|
+
tsbuild was inspired by and borrows concepts from several excellent projects:
|
|
314
|
+
|
|
315
|
+
### [tsup](https://tsup.egoist.dev/) by [@egoist](https://github.com/egoist)
|
|
316
|
+
tsbuild's overall architecture, API design, and configuration approach are heavily influenced by tsup. The external module resolution strategy, entry point handling, and plugin system take direct inspiration from tsup's battle-tested design. If you need a production-ready build tool, use tsup.
|
|
317
|
+
|
|
318
|
+
### [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts) by [Arpad Borsos](https://github.com/Swatinem)
|
|
319
|
+
The TypeScript declaration bundling system was originally inspired by rollup-plugin-dts's approach to handling complex TypeScript declarations. The current custom implementation builds a dependency graph and combines modules without Rollup, optimizing for in-memory operations and avoiding duplicate TypeScript Program creation.
|
|
320
|
+
|
|
321
|
+
### Other Dependencies
|
|
322
|
+
- **[esbuild](https://esbuild.github.io/)** - The incredibly fast JavaScript bundler that powers tsbuild's transpilation
|
|
323
|
+
- **[TypeScript](https://www.typescriptlang.org/)** - Type checking, declaration generation, and module resolution
|
|
324
|
+
- **[SWC](https://swc.rs/)** - Optional decorator metadata transformation
|
|
325
|
+
- **[magic-string](https://github.com/Rich-Harris/magic-string)** - Efficient source code transformation with sourcemap support
|
|
326
|
+
- **[watchr](https://github.com/bevry/watchr)** - File watching for watch mode
|
|
327
|
+
|
|
328
|
+
## Limitations
|
|
329
|
+
|
|
330
|
+
- **ESM Only** - No CommonJS support by design
|
|
331
|
+
- **Node.js 20.16.0+** - Requires modern Node.js features
|
|
332
|
+
- **Experimental** - Personal project, not recommended for production use
|
|
333
|
+
- **Limited Configuration in tsconfig.json** - Some options (like `plugins`) are only available via programmatic API
|
|
334
|
+
- **tsBuildInfoFile Path Changes** - When changing the `tsBuildInfoFile` path in `tsconfig.json`, the old `.tsbuildinfo` file at the previous location will not be automatically cleaned up and must be manually removed
|
|
335
|
+
|
|
336
|
+
## Comparison with Other Tools
|
|
337
|
+
|
|
338
|
+
| Feature | tsbuild | tsup | tsc |
|
|
339
|
+
|---------|---------|------|-----|
|
|
340
|
+
| Type Checking | โ
Full | โ
Full | โ
Full |
|
|
341
|
+
| Fast Bundling | โ
esbuild | โ
esbuild | โ N/A |
|
|
342
|
+
| Declaration Bundling | โ
Custom Bundler | โ
rollup-plugin-dts | โ N/A |
|
|
343
|
+
| Decorator Metadata | โ
SWC (optional) | โ
SWC | โ
Native |
|
|
344
|
+
| CommonJS Support | โ None | โ
Yes | โ
Yes |
|
|
345
|
+
| Watch Mode | โ
Yes | โ
Yes | โ
Yes |
|
|
346
|
+
| Incremental Builds | โ
Yes | โ ๏ธ Limited | โ
Yes |
|
|
347
|
+
| Production Ready | โ ๏ธ Experimental | โ
Yes | โ
Yes |
|
|
348
|
+
|
|
349
|
+
## Development
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
# Install dependencies
|
|
353
|
+
pnpm install
|
|
354
|
+
|
|
355
|
+
# Build (self-hosting)
|
|
356
|
+
pnpm build
|
|
357
|
+
|
|
358
|
+
# Watch mode
|
|
359
|
+
pnpm build:watch
|
|
360
|
+
|
|
361
|
+
# Type-check only
|
|
362
|
+
pnpm type-check
|
|
363
|
+
|
|
364
|
+
# Run tests
|
|
365
|
+
pnpm test
|
|
366
|
+
|
|
367
|
+
# Run tests with coverage
|
|
368
|
+
pnpm test:coverage
|
|
369
|
+
|
|
370
|
+
# Lint
|
|
371
|
+
pnpm lint
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Contributing
|
|
375
|
+
|
|
376
|
+
This is a personal experimental project. While contributions are welcome, please note that the project is not actively maintained for production use.
|
|
377
|
+
|
|
378
|
+
## License
|
|
379
|
+
|
|
380
|
+
ISC
|
|
381
|
+
|
|
382
|
+
## Author
|
|
383
|
+
|
|
384
|
+
D1g1talEntr0py
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
**Remember:** For production projects, use [tsup](https://tsup.egoist.dev/) instead. tsbuild is an educational and experimental project exploring how modern build tools can be composed together.
|
package/dist/44KSX2XO.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
48
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
49
|
+
|
|
50
|
+
// src/constants.ts
|
|
51
|
+
import { JsxEmit, ScriptTarget } from "typescript";
|
|
52
|
+
var dataUnits = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
53
|
+
var Platform = { NODE: "node", BROWSER: "browser", NEUTRAL: "neutral" };
|
|
54
|
+
var BuildMessageType = { ERROR: "error", WARNING: "warning" };
|
|
55
|
+
var compilerOptionOverrides = {
|
|
56
|
+
// Skip code generation when error occurs
|
|
57
|
+
noEmitOnError: true,
|
|
58
|
+
// Do not allow JavaScript files to be imported into TypeScript files
|
|
59
|
+
allowJs: false,
|
|
60
|
+
// Skip type-checking JavaScript files
|
|
61
|
+
checkJs: false,
|
|
62
|
+
// Skip declaration map generation. TODO - Would love to figure out how to combine them into a single file / entry point
|
|
63
|
+
declarationMap: false,
|
|
64
|
+
// Skip type-checking all dependencies
|
|
65
|
+
skipLibCheck: true,
|
|
66
|
+
// Ensure TS2742 errors are visible when `true`. TODO - Figure out how to have this work with a value of `true`
|
|
67
|
+
preserveSymlinks: false,
|
|
68
|
+
// Ensure we can parse the latest code
|
|
69
|
+
target: ScriptTarget.ESNext
|
|
70
|
+
};
|
|
71
|
+
var scriptTargetToEsTarget = {
|
|
72
|
+
[ScriptTarget.ES3]: "ES6",
|
|
73
|
+
[ScriptTarget.ES5]: "ES6",
|
|
74
|
+
[ScriptTarget.ES2015]: "ES2015",
|
|
75
|
+
[ScriptTarget.ES2016]: "ES2016",
|
|
76
|
+
[ScriptTarget.ES2017]: "ES2017",
|
|
77
|
+
[ScriptTarget.ES2018]: "ES2018",
|
|
78
|
+
[ScriptTarget.ES2019]: "ES2019",
|
|
79
|
+
[ScriptTarget.ES2020]: "ES2020",
|
|
80
|
+
[ScriptTarget.ES2021]: "ES2021",
|
|
81
|
+
[ScriptTarget.ES2022]: "ES2022",
|
|
82
|
+
[ScriptTarget.ES2023]: "ES2023",
|
|
83
|
+
[ScriptTarget.ES2024]: "ES2024",
|
|
84
|
+
[ScriptTarget.ESNext]: "ESNext",
|
|
85
|
+
[ScriptTarget.JSON]: "ESNext"
|
|
86
|
+
};
|
|
87
|
+
var jsxEmitMap = {
|
|
88
|
+
[JsxEmit.Preserve]: "preserve",
|
|
89
|
+
[JsxEmit.React]: "react",
|
|
90
|
+
[JsxEmit.ReactNative]: "react-native",
|
|
91
|
+
[JsxEmit.ReactJSX]: "react-jsx",
|
|
92
|
+
[JsxEmit.ReactJSXDev]: "react-jsxdev"
|
|
93
|
+
};
|
|
94
|
+
var toEsTarget = (target) => scriptTargetToEsTarget[target];
|
|
95
|
+
var toJsxRenderingMode = (jsxEmit) => jsxEmit !== void 0 ? jsxEmitMap[jsxEmit] : void 0;
|
|
96
|
+
var FileExtension = {
|
|
97
|
+
JS: ".js",
|
|
98
|
+
DTS: ".d.ts",
|
|
99
|
+
CSS: ".css",
|
|
100
|
+
JSON: ".json"
|
|
101
|
+
};
|
|
102
|
+
var Encoding = {
|
|
103
|
+
utf8: "utf8",
|
|
104
|
+
base64: "base64"
|
|
105
|
+
};
|
|
106
|
+
var defaultDirOptions = { recursive: true };
|
|
107
|
+
var defaultCleanOptions = { recursive: true, force: true };
|
|
108
|
+
var defaultOutDirectory = "dist";
|
|
109
|
+
var defaultEntryPoint = "index";
|
|
110
|
+
var defaultSourceDirectory = "./src";
|
|
111
|
+
var defaultEntryFile = "src/index.ts";
|
|
112
|
+
var cacheDirectory = ".tsbuild";
|
|
113
|
+
var buildInfoFile = "tsconfig.tsbuildinfo";
|
|
114
|
+
var dtsCacheFile = "dts_cache.v8.br";
|
|
115
|
+
var dtsCacheVersion = 2;
|
|
116
|
+
var format = "esm";
|
|
117
|
+
var newLine = "\n";
|
|
118
|
+
var typeMatcher = /\btype\b/;
|
|
119
|
+
var sourceScriptExtensionExpression = /(?<!\.d)\.[jt]sx?$/;
|
|
120
|
+
var typeScriptExtensionExpression = /(\.tsx?)$/;
|
|
121
|
+
var processEnvExpansionPattern = /\$\{process\.env\.([^}]+)\}/g;
|
|
122
|
+
var inlineTypePattern = /([{,]\s+)type\s+/g;
|
|
123
|
+
|
|
124
|
+
// src/paths.ts
|
|
125
|
+
import { lstat } from "node:fs/promises";
|
|
126
|
+
import { relative, resolve, join, parse } from "node:path";
|
|
127
|
+
var Paths = class {
|
|
128
|
+
constructor() {
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Computes the absolute path by joining the provided segments.
|
|
132
|
+
* @param paths Array of path segments to join
|
|
133
|
+
* @returns The absolute path
|
|
134
|
+
*/
|
|
135
|
+
static absolute(...paths) {
|
|
136
|
+
return resolve(...paths);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Computes the relative path from one location to another.
|
|
140
|
+
* @param from The starting location
|
|
141
|
+
* @param to The target location
|
|
142
|
+
* @returns The relative path
|
|
143
|
+
*/
|
|
144
|
+
static relative(from, to) {
|
|
145
|
+
return relative(from, to);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns the directory name of a path.
|
|
149
|
+
* @param path - The path to evaluate
|
|
150
|
+
* @returns The directory name of the path
|
|
151
|
+
*/
|
|
152
|
+
static parse(path) {
|
|
153
|
+
return parse(path);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Checks if the given path is a directory.
|
|
157
|
+
* @param path - The path to check
|
|
158
|
+
* @returns True if the path is a directory, false otherwise
|
|
159
|
+
*/
|
|
160
|
+
static async isDirectory(path) {
|
|
161
|
+
return (await lstat(path)).isDirectory();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Checks if the given path is a file.
|
|
165
|
+
* @param path - The path to check
|
|
166
|
+
* @returns True if the path is a file, false otherwise
|
|
167
|
+
*/
|
|
168
|
+
static async isFile(path) {
|
|
169
|
+
return (await lstat(path)).isFile();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Checks if a module specifier represents a local path (not a bare specifier).
|
|
173
|
+
* Local paths start with '/', './', '../', '.', '..', or Windows drive letters (e.g., 'C:\').
|
|
174
|
+
* @param path - The module specifier to check
|
|
175
|
+
* @returns True if the path is a local/relative path, false if it's a bare specifier (node module)
|
|
176
|
+
*/
|
|
177
|
+
static isPath(path) {
|
|
178
|
+
if (path.length === 0) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
const firstCharacter = path.charCodeAt(0);
|
|
182
|
+
if (firstCharacter === 47) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
if (firstCharacter === 46) {
|
|
186
|
+
if (path.length === 1) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
const c1 = path.charCodeAt(1);
|
|
190
|
+
if (c1 === 47) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
if (c1 === 46) {
|
|
194
|
+
return path.length === 2 || path.charCodeAt(2) === 47;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (firstCharacter >= 65 && firstCharacter <= 90 && path.length >= 3 && path.charCodeAt(1) === 58) {
|
|
199
|
+
const c2 = path.charCodeAt(2);
|
|
200
|
+
return c2 === 47 || c2 === 92;
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Joins multiple path segments into a single path.
|
|
206
|
+
* When the first segment is an AbsolutePath, returns AbsolutePath.
|
|
207
|
+
* Otherwise, returns RelativePath.
|
|
208
|
+
* @param first - The first path segment (determines if result is absolute)
|
|
209
|
+
* @param rest - Additional path segments to join
|
|
210
|
+
* @returns The joined path
|
|
211
|
+
*/
|
|
212
|
+
static join(first, ...rest) {
|
|
213
|
+
return join(first, ...rest);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/json.ts
|
|
218
|
+
var Json = class {
|
|
219
|
+
/**
|
|
220
|
+
* Parse a JSON string into an object of type T.
|
|
221
|
+
* @param jsonString The JSON string to parse.
|
|
222
|
+
* @returns The parsed object of type T.
|
|
223
|
+
*/
|
|
224
|
+
static parse(jsonString) {
|
|
225
|
+
return JSON.parse(jsonString);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Serialize an object of type T into a JSON string.
|
|
229
|
+
* @param data The object to serialize.
|
|
230
|
+
* @returns The serialized JSON string.
|
|
231
|
+
*/
|
|
232
|
+
static serialize(data) {
|
|
233
|
+
return JSON.stringify(data);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
__decoratorStart,
|
|
239
|
+
__runInitializers,
|
|
240
|
+
__decorateElement,
|
|
241
|
+
__publicField,
|
|
242
|
+
dataUnits,
|
|
243
|
+
Platform,
|
|
244
|
+
BuildMessageType,
|
|
245
|
+
compilerOptionOverrides,
|
|
246
|
+
toEsTarget,
|
|
247
|
+
toJsxRenderingMode,
|
|
248
|
+
FileExtension,
|
|
249
|
+
Encoding,
|
|
250
|
+
defaultDirOptions,
|
|
251
|
+
defaultCleanOptions,
|
|
252
|
+
defaultOutDirectory,
|
|
253
|
+
defaultEntryPoint,
|
|
254
|
+
defaultSourceDirectory,
|
|
255
|
+
defaultEntryFile,
|
|
256
|
+
cacheDirectory,
|
|
257
|
+
buildInfoFile,
|
|
258
|
+
dtsCacheFile,
|
|
259
|
+
dtsCacheVersion,
|
|
260
|
+
format,
|
|
261
|
+
newLine,
|
|
262
|
+
typeMatcher,
|
|
263
|
+
sourceScriptExtensionExpression,
|
|
264
|
+
typeScriptExtensionExpression,
|
|
265
|
+
processEnvExpansionPattern,
|
|
266
|
+
inlineTypePattern,
|
|
267
|
+
Paths,
|
|
268
|
+
Json
|
|
269
|
+
};
|