feat(tsbuild): Add tsconfig.json support and safer compiler option merging; protect critical options; apply path and enum transforms; bump dependencies.
This commit is contained in:
47
readme.md
47
readme.md
@@ -184,6 +184,49 @@ Example:
|
||||
npx tsbuild --skiplibcheck --disallowimplicitany
|
||||
```
|
||||
|
||||
## Configuration with tsconfig.json
|
||||
|
||||
`@git.zone/tsbuild` fully supports `tsconfig.json` for compiler configuration. All compiler options from your `tsconfig.json` will be respected and merged with tsbuild's defaults.
|
||||
|
||||
### Option Priority (Merge Order)
|
||||
|
||||
When multiple configuration sources are present, they are merged in the following order (later sources override earlier ones):
|
||||
|
||||
1. **Default compiler options** - Base defaults for all options
|
||||
2. **tsconfig.json** - All compiler options from your project's `tsconfig.json` (if present)
|
||||
3. **Protected defaults** - Critical options for build integrity (see below)
|
||||
4. **Programmatic options** - Options passed to API functions
|
||||
5. **CLI flags** - Command-line arguments (highest priority)
|
||||
|
||||
### Protected Compiler Options
|
||||
|
||||
To ensure build integrity and correct functionality, the following options are protected and cannot be overridden by `tsconfig.json` alone (but can be overridden programmatically or via CLI):
|
||||
|
||||
- `outDir: 'dist_ts/'` - Required for path transformation logic
|
||||
- `noEmitOnError: true` - Prevents broken builds from being emitted
|
||||
- `declaration: true` - Ensures .d.ts files for library consumers
|
||||
- `emitDecoratorMetadata: true` - Required for dependency injection frameworks
|
||||
- `inlineSourceMap: true` - Provides consistent debugging experience
|
||||
|
||||
### Working Without tsconfig.json
|
||||
|
||||
`@git.zone/tsbuild` works perfectly fine without a `tsconfig.json` file. If no `tsconfig.json` is found, it will gracefully fall back to sensible defaults without errors.
|
||||
|
||||
Example `tsconfig.json`:
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Default Compiler Options
|
||||
|
||||
By default, `@git.zone/tsbuild` uses the following compiler options:
|
||||
@@ -200,7 +243,7 @@ By default, `@git.zone/tsbuild` uses the following compiler options:
|
||||
target: ScriptTarget.ESNext,
|
||||
moduleResolution: ModuleResolutionKind.NodeNext,
|
||||
lib: ['lib.dom.d.ts', 'lib.es2022.d.ts'],
|
||||
noImplicitAny: false, // Now allowing implicit any by default
|
||||
noImplicitAny: false,
|
||||
esModuleInterop: true,
|
||||
useDefineForClassFields: false,
|
||||
verbatimModuleSyntax: true,
|
||||
@@ -208,7 +251,7 @@ By default, `@git.zone/tsbuild` uses the following compiler options:
|
||||
}
|
||||
```
|
||||
|
||||
These options can be overridden by providing a custom `CompilerOptions` object.
|
||||
These defaults are merged with your `tsconfig.json` options (if present), programmatic options, and CLI flags according to the priority order described above.
|
||||
|
||||
## Path Resolution
|
||||
|
||||
|
||||
Reference in New Issue
Block a user