fix(compiler): return emitted files from compilation results and align tests with emitted output handling
This commit is contained in:
@@ -9,11 +9,7 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# Using pnpm (recommended)
|
||||
pnpm install @git.zone/tsbuild --save-dev
|
||||
|
||||
# Using npm
|
||||
npm install @git.zone/tsbuild --save-dev
|
||||
pnpm add --save-dev @git.zone/tsbuild
|
||||
```
|
||||
|
||||
## Why tsbuild?
|
||||
@@ -38,13 +34,13 @@ npm install @git.zone/tsbuild --save-dev
|
||||
|
||||
**Compile your TypeScript project:**
|
||||
```bash
|
||||
npx tsbuild
|
||||
pnpm exec tsbuild
|
||||
```
|
||||
Compiles `./ts/**/*.ts` to `./dist_ts/`
|
||||
|
||||
**Custom directories:**
|
||||
```bash
|
||||
npx tsbuild custom src utils
|
||||
pnpm exec tsbuild custom src utils
|
||||
```
|
||||
Compiles:
|
||||
- `./src/**/*.ts` -> `./dist_src/`
|
||||
@@ -52,7 +48,7 @@ Compiles:
|
||||
|
||||
**Auto-discover and compile in dependency order:**
|
||||
```bash
|
||||
npx tsbuild tsfolders
|
||||
pnpm exec tsbuild tsfolders
|
||||
```
|
||||
Finds all `ts_*` folders and compiles them respecting dependencies.
|
||||
|
||||
@@ -103,7 +99,7 @@ await compiler.compileGlob({
|
||||
### 1. Default Build
|
||||
|
||||
```bash
|
||||
npx tsbuild [options]
|
||||
pnpm exec tsbuild [options]
|
||||
```
|
||||
|
||||
Compiles all TypeScript files from `./ts/` to `./dist_ts/`
|
||||
@@ -121,39 +117,39 @@ Compiles all TypeScript files from `./ts/` to `./dist_ts/`
|
||||
**Examples:**
|
||||
```bash
|
||||
# Standard build
|
||||
npx tsbuild
|
||||
pnpm exec tsbuild
|
||||
|
||||
# Build with JSON output for CI
|
||||
npx tsbuild --json --quiet
|
||||
pnpm exec tsbuild --json --quiet
|
||||
|
||||
# CommonJS build
|
||||
npx tsbuild --commonjs
|
||||
pnpm exec tsbuild --commonjs
|
||||
|
||||
# Strict mode
|
||||
npx tsbuild --disallowimplicitany
|
||||
pnpm exec tsbuild --disallowimplicitany
|
||||
```
|
||||
|
||||
### 2. Custom Directories
|
||||
|
||||
```bash
|
||||
npx tsbuild custom <dir1> <dir2> ... [options]
|
||||
pnpm exec tsbuild custom <dir1> <dir2> ... [options]
|
||||
```
|
||||
|
||||
Compile specific directories to their corresponding `dist_` folders.
|
||||
|
||||
```bash
|
||||
# Compile src and utils
|
||||
npx tsbuild custom src utils
|
||||
pnpm exec tsbuild custom src utils
|
||||
# Creates: ./dist_src/ and ./dist_utils/
|
||||
|
||||
# Multiple directories with options
|
||||
npx tsbuild custom api models services --commonjs
|
||||
pnpm exec tsbuild custom api models services --commonjs
|
||||
```
|
||||
|
||||
### 3. TSFolders (Dependency-Aware)
|
||||
|
||||
```bash
|
||||
npx tsbuild tsfolders [options]
|
||||
pnpm exec tsbuild tsfolders [options]
|
||||
```
|
||||
|
||||
Automatically discovers and compiles all `ts_*` folders in dependency order:
|
||||
@@ -176,17 +172,17 @@ TypeScript Folder Compilation Plan (5 folders)
|
||||
### 4. Emit Check
|
||||
|
||||
```bash
|
||||
npx tsbuild emitcheck <file_or_pattern> [more...] [options]
|
||||
pnpm exec tsbuild emitcheck <file_or_pattern> [more...] [options]
|
||||
```
|
||||
|
||||
Validates TypeScript files can be compiled without actually emitting them.
|
||||
|
||||
```bash
|
||||
# Check specific files
|
||||
npx tsbuild emitcheck src/main.ts src/utils.ts
|
||||
pnpm exec tsbuild emitcheck src/main.ts src/utils.ts
|
||||
|
||||
# Check with glob patterns
|
||||
npx tsbuild emitcheck "src/**/*.ts" "test/**/*.ts"
|
||||
pnpm exec tsbuild emitcheck "src/**/*.ts" "test/**/*.ts"
|
||||
```
|
||||
|
||||
**Exit codes:**
|
||||
@@ -196,15 +192,15 @@ npx tsbuild emitcheck "src/**/*.ts" "test/**/*.ts"
|
||||
### 5. Type Check
|
||||
|
||||
```bash
|
||||
npx tsbuild check [pattern] [more...] [options]
|
||||
pnpm exec tsbuild check [pattern] [more...] [options]
|
||||
```
|
||||
|
||||
Performs type checking without emitting files.
|
||||
|
||||
**With arguments:** Check specified files/patterns
|
||||
```bash
|
||||
npx tsbuild check "ts/**/*.ts"
|
||||
npx tsbuild check "src/**/*.ts" "test/**/*.ts"
|
||||
pnpm exec tsbuild check "ts/**/*.ts"
|
||||
pnpm exec tsbuild check "src/**/*.ts" "test/**/*.ts"
|
||||
```
|
||||
|
||||
**Without arguments:** Two-phase default check
|
||||
@@ -212,7 +208,7 @@ npx tsbuild check "src/**/*.ts" "test/**/*.ts"
|
||||
2. Phase 2: Type check `test/**/*` (relaxed, skipLibCheck: true)
|
||||
|
||||
```bash
|
||||
npx tsbuild check
|
||||
pnpm exec tsbuild check
|
||||
# Running default type checking sequence...
|
||||
# Checking ts/**/* files...
|
||||
# Checking test/**/* files with --skiplibcheck...
|
||||
@@ -549,14 +545,16 @@ Each `ts_*` folder can contain its own `tspublish.json` to configure compilation
|
||||
|
||||
#### tspublish.json Configuration
|
||||
|
||||
Create a `tspublish.json` in each `ts_*` folder:
|
||||
Create a `tspublish.json` in each publishable `ts_*` folder. `@git.zone/tspublish` expects publishing fields, while tsbuild additionally reads `order` and `unpack` for build ordering and output flattening:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "@myorg/core",
|
||||
"order": 3,
|
||||
"unpack": true,
|
||||
"dependencies": ["ts_interfaces", "ts_shared"]
|
||||
"dependencies": ["@myorg/interfaces", "@myorg/shared"],
|
||||
"registries": ["useBase"],
|
||||
"bin": []
|
||||
}
|
||||
```
|
||||
|
||||
@@ -565,14 +563,16 @@ Create a `tspublish.json` in each `ts_*` folder:
|
||||
| `name` | string | -- | Package name for publishing |
|
||||
| `order` | number | `Infinity` | Build sequence (lower builds first) |
|
||||
| `unpack` | boolean | `true` | Flatten nested output directories |
|
||||
| `dependencies` | string[] | -- | Monorepo dependencies to bundle |
|
||||
| `dependencies` | string[] | `[]` | Published package dependencies resolved from the monorepo `package.json` |
|
||||
| `registries` | string[] | -- | Publish registries, for example `useBase` to read `.smartconfig.json` |
|
||||
| `bin` | string[] | `[]` | CLI binary names generated by `@git.zone/tspublish` |
|
||||
|
||||
#### Build Order
|
||||
|
||||
The `tsfolders` command respects the `order` property:
|
||||
|
||||
```bash
|
||||
npx tsbuild tsfolders
|
||||
pnpm exec tsbuild tsfolders
|
||||
```
|
||||
|
||||
**Default ordering (without tspublish.json):**
|
||||
@@ -680,14 +680,14 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- run: npm install
|
||||
- run: npx tsbuild
|
||||
- run: pnpm install
|
||||
- run: pnpm exec tsbuild
|
||||
```
|
||||
|
||||
### JSON Output
|
||||
|
||||
```bash
|
||||
npx tsbuild --json --quiet
|
||||
pnpm exec tsbuild --json --quiet
|
||||
```
|
||||
|
||||
```json
|
||||
@@ -739,14 +739,14 @@ Ensure your tsconfig.json has:
|
||||
|
||||
Use `--skiplibcheck` to skip declaration file checking:
|
||||
```bash
|
||||
npx tsbuild --skiplibcheck
|
||||
pnpm exec tsbuild --skiplibcheck
|
||||
```
|
||||
|
||||
Only use this if you trust your dependencies' type definitions.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
@@ -758,7 +758,7 @@ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark G
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Task Venture Capital GmbH
|
||||
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||
|
||||
Reference in New Issue
Block a user