Skip to content

Commit ecd17ff

Browse files
committed
chore: improve documentation and add bun-git-hooks
1 parent e1a0d67 commit ecd17ff

16 files changed

+1740
-215
lines changed

build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ await Bun.build({
1212
format: 'esm',
1313
target: 'bun',
1414
minify: true,
15-
plugins: [dts()],
15+
plugins: [
16+
dts(),
17+
],
1618
})
1719

1820
// prepare dist for publishing

bun.lock

Lines changed: 205 additions & 209 deletions
Large diffs are not rendered by default.

docs/.vitepress/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// @ts-nocheck
33
// Generated by unplugin-vue-components
44
// Read more: https://github.com/vuejs/core/pull/3399
5+
// biome-ignore lint: disable
56
export {}
67

78
/* prettier-ignore */

docs/.vitepress/config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ const sidebar = [
6060
{ text: 'Config', link: '/config' },
6161
],
6262
},
63+
{
64+
text: 'Features',
65+
items: [
66+
{ text: 'Overview', link: '/features/' },
67+
{ text: 'Type Support', link: '/features/type-support' },
68+
{ text: 'Import Optimization', link: '/features/import-optimization' },
69+
{ text: 'Type Inference', link: '/features/type-inference' },
70+
],
71+
},
72+
{
73+
text: 'Advanced',
74+
items: [
75+
{ text: 'Overview', link: '/advanced/' },
76+
{ text: 'Type Processing', link: '/advanced/type-processing' },
77+
{ text: 'Performance', link: '/advanced/performance' },
78+
{ text: 'Integration', link: '/advanced/integration' },
79+
{ text: 'Troubleshooting', link: '/advanced/troubleshooting' },
80+
],
81+
},
82+
{ text: 'API Reference', link: '/api-reference' },
6383
{ text: 'Showcase', link: '/Showcase' },
6484
]
6585
const description = 'Extremely fast & configurable DTS emitter.'

docs/advanced/index.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Advanced Topics
2+
3+
This section covers advanced topics and techniques for using dtsx effectively.
4+
5+
## Advanced Type Processing
6+
7+
- **Complex Type Inference**: Handling nested and recursive types
8+
- **Type Relationship Tracking**: Maintaining type relationships across files
9+
- **Custom Type Transformations**: Advanced type manipulation techniques
10+
- **Type Augmentation**: Extending existing type definitions
11+
12+
## Performance Optimization
13+
14+
- **Import Optimization Strategies**: Advanced techniques for optimizing imports
15+
- **Memory Management**: Handling large codebases efficiently
16+
- **Parallel Processing**: Optimizing multi-file processing
17+
- **Caching Strategies**: Improving build times with caching
18+
19+
## Integration Patterns
20+
21+
- **Build System Integration**: Integrating with various build tools
22+
- **CI/CD Integration**: Setting up automated declaration generation
23+
- **Custom Transformers**: Creating custom type transformers
24+
- **Plugin System**: Extending dtsx functionality
25+
26+
## Troubleshooting
27+
28+
- **Common Issues**: Solutions to frequent problems
29+
- **Debugging Techniques**: Advanced debugging strategies
30+
- **Performance Profiling**: Identifying and fixing performance bottlenecks
31+
- **Type Resolution**: Handling complex type resolution scenarios

docs/advanced/integration.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Integration
2+
3+
This guide covers how to integrate dtsx with various build tools and development environments.
4+
5+
## Build System Integration
6+
7+
### Vite Integration
8+
9+
```typescript
10+
// vite.config.ts
11+
import { defineConfig } from 'vite';
12+
import dtsx from 'dtsx/vite';
13+
14+
export default defineConfig({
15+
plugins: [
16+
dtsx({
17+
// dtsx configuration
18+
root: './src',
19+
outdir: './dist',
20+
clean: true,
21+
}),
22+
],
23+
});
24+
```
25+
26+
### Webpack Integration
27+
28+
```typescript
29+
// webpack.config.js
30+
const DtsxPlugin = require('dtsx/webpack');
31+
32+
module.exports = {
33+
plugins: [
34+
new DtsxPlugin({
35+
// dtsx configuration
36+
root: './src',
37+
outdir: './dist',
38+
clean: true,
39+
}),
40+
],
41+
};
42+
```
43+
44+
### Rollup Integration
45+
46+
```typescript
47+
// rollup.config.js
48+
import dtsx from 'dtsx/rollup';
49+
50+
export default {
51+
plugins: [
52+
dtsx({
53+
// dtsx configuration
54+
root: './src',
55+
outdir: './dist',
56+
clean: true,
57+
}),
58+
],
59+
};
60+
```
61+
62+
## CI/CD Integration
63+
64+
### GitHub Actions
65+
66+
```yaml
67+
# .github/workflows/build.yml
68+
name: Build
69+
on: [push, pull_request]
70+
71+
jobs:
72+
build:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v2
76+
- uses: actions/setup-node@v2
77+
with:
78+
node-version: '18'
79+
- run: npm install
80+
- run: npm run build
81+
- run: npm run generate-dts
82+
```
83+
84+
### GitLab CI
85+
86+
```yaml
87+
# .gitlab-ci.yml
88+
build:
89+
image: node:18
90+
script:
91+
- npm install
92+
- npm run build
93+
- npm run generate-dts
94+
```
95+
96+
## Custom Transformers
97+
98+
### Type Transformer
99+
100+
```typescript
101+
interface TypeTransformer {
102+
// Transform type definition
103+
transformType(type: TypeDefinition): TypeDefinition;
104+
// Transform type reference
105+
transformReference(ref: TypeReference): TypeReference;
106+
// Transform type usage
107+
transformUsage(usage: TypeUsage): TypeUsage;
108+
}
109+
110+
// Example transformer
111+
const transformer: TypeTransformer = {
112+
transformType(type) {
113+
// Transform type definition
114+
return type;
115+
},
116+
transformReference(ref) {
117+
// Transform type reference
118+
return ref;
119+
},
120+
transformUsage(usage) {
121+
// Transform type usage
122+
return usage;
123+
},
124+
};
125+
```
126+
127+
### Import Transformer
128+
129+
```typescript
130+
interface ImportTransformer {
131+
// Transform import statement
132+
transformImport(import: ImportStatement): ImportStatement;
133+
// Transform import usage
134+
transformUsage(usage: ImportUsage): ImportUsage;
135+
// Transform import relationships
136+
transformRelationships(relationships: ImportRelationships): ImportRelationships;
137+
}
138+
139+
// Example transformer
140+
const transformer: ImportTransformer = {
141+
transformImport(import) {
142+
// Transform import statement
143+
return import;
144+
},
145+
transformUsage(usage) {
146+
// Transform import usage
147+
return usage;
148+
},
149+
transformRelationships(relationships) {
150+
// Transform import relationships
151+
return relationships;
152+
},
153+
};
154+
```
155+
156+
## Plugin System
157+
158+
### Plugin Interface
159+
160+
```typescript
161+
interface DtsxPlugin {
162+
// Plugin name
163+
name: string;
164+
// Plugin version
165+
version: string;
166+
// Plugin hooks
167+
hooks: {
168+
// Before processing
169+
beforeProcess?: (context: ProcessingContext) => void;
170+
// After processing
171+
afterProcess?: (context: ProcessingContext) => void;
172+
// Before type generation
173+
beforeTypeGeneration?: (context: TypeGenerationContext) => void;
174+
// After type generation
175+
afterTypeGeneration?: (context: TypeGenerationContext) => void;
176+
};
177+
}
178+
```
179+
180+
### Plugin Configuration
181+
182+
```typescript
183+
interface PluginConfig {
184+
// Plugin name
185+
name: string;
186+
// Plugin options
187+
options: Record<string, unknown>;
188+
// Plugin dependencies
189+
dependencies?: string[];
190+
// Plugin order
191+
order?: number;
192+
}
193+
```
194+
195+
## Best Practices
196+
197+
1. **Build System Integration**
198+
- Use appropriate plugin
199+
- Configure correctly
200+
- Handle errors
201+
- Monitor performance
202+
203+
2. **CI/CD Integration**
204+
- Set up automated builds
205+
- Configure caching
206+
- Handle artifacts
207+
- Monitor builds
208+
209+
3. **Custom Transformers**
210+
- Keep transformers focused
211+
- Handle errors
212+
- Document transformations
213+
- Test thoroughly
214+
215+
4. **Plugin Development**
216+
- Follow plugin interface
217+
- Handle dependencies
218+
- Document usage
219+
- Test thoroughly

0 commit comments

Comments
 (0)