@savvy-web/rslib-builder 0.2.2 → 0.4.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/README.md +70 -18
- package/index.d.ts +1013 -392
- package/index.js +491 -209
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://nodejs.org)
|
|
6
6
|
|
|
7
|
-
Build modern ESM Node.js libraries with
|
|
8
|
-
declarations, package.json transformations, and PNPM workspace
|
|
9
|
-
automatically.
|
|
7
|
+
Build modern ESM Node.js libraries with minimal configuration. Handles
|
|
8
|
+
TypeScript declarations, package.json transformations, and PNPM workspace
|
|
9
|
+
resolution automatically.
|
|
10
|
+
|
|
11
|
+
Building TypeScript packages for npm involves repetitive setup: configuring
|
|
12
|
+
bundlers, generating declarations, transforming package.json exports, and
|
|
13
|
+
resolving workspace references. rslib-builder handles these tasks so you can
|
|
14
|
+
focus on your code.
|
|
10
15
|
|
|
11
16
|
## Features
|
|
12
17
|
|
|
@@ -19,8 +24,10 @@ automatically.
|
|
|
19
24
|
outputs
|
|
20
25
|
- **PNPM Integration** - Automatically resolves `catalog:` and `workspace:`
|
|
21
26
|
references
|
|
22
|
-
- **Package.json Transform** - Converts `.ts` exports
|
|
23
|
-
|
|
27
|
+
- **Package.json Transform** - Converts `.ts` exports to `.js`, generates files
|
|
28
|
+
array, removes dev-only fields
|
|
29
|
+
- **TSDoc Validation** - Pre-build TSDoc validation with automatic public API discovery
|
|
30
|
+
- **API Model Generation** - Optional API model output for documentation tooling
|
|
24
31
|
- **Extensible** - Add custom RSlib/Rsbuild plugins for advanced use cases
|
|
25
32
|
|
|
26
33
|
## Prerequisites
|
|
@@ -43,6 +50,12 @@ Install the required peer dependencies:
|
|
|
43
50
|
pnpm add -D @rslib/core @microsoft/api-extractor @typescript/native-preview
|
|
44
51
|
```
|
|
45
52
|
|
|
53
|
+
For TSDoc validation (optional):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm add -D eslint @typescript-eslint/parser eslint-plugin-tsdoc
|
|
57
|
+
```
|
|
58
|
+
|
|
46
59
|
## Quick Start
|
|
47
60
|
|
|
48
61
|
Extend the provided tsconfig for optimal settings:
|
|
@@ -96,16 +109,32 @@ rslib build --env-mode dev
|
|
|
96
109
|
rslib build --env-mode npm
|
|
97
110
|
```
|
|
98
111
|
|
|
112
|
+
## API Overview
|
|
113
|
+
|
|
114
|
+
The package exports a main builder and several plugins:
|
|
115
|
+
|
|
116
|
+
| Export | Description |
|
|
117
|
+
| ---------------------------- | --------------------------------------------- |
|
|
118
|
+
| `NodeLibraryBuilder` | Main API for building Node.js libraries |
|
|
119
|
+
| `AutoEntryPlugin` | Auto-extracts entry points from package.json |
|
|
120
|
+
| `DtsPlugin` | Generates TypeScript declarations with tsgo |
|
|
121
|
+
| `PackageJsonTransformPlugin` | Transforms package.json for distribution |
|
|
122
|
+
| `FilesArrayPlugin` | Generates files array for npm publishing |
|
|
123
|
+
| `TsDocLintPlugin` | Validates TSDoc comments before build |
|
|
124
|
+
| `TsDocConfigBuilder` | Utility for TSDoc configuration |
|
|
125
|
+
| `ImportGraph` | Traces TypeScript imports for file discovery |
|
|
126
|
+
|
|
99
127
|
See [Configuration](./docs/guides/configuration.md) for all options.
|
|
100
128
|
|
|
101
129
|
## Plugins
|
|
102
130
|
|
|
103
131
|
The builder includes several built-in plugins:
|
|
104
132
|
|
|
105
|
-
1. **
|
|
106
|
-
2. **
|
|
133
|
+
1. **TsDocLintPlugin** - Validates TSDoc comments before build (optional)
|
|
134
|
+
2. **AutoEntryPlugin** - Auto-extracts entry points from package.json exports
|
|
107
135
|
3. **DtsPlugin** - Generates TypeScript declarations with tsgo/API Extractor
|
|
108
|
-
4. **
|
|
136
|
+
4. **PackageJsonTransformPlugin** - Transforms package.json for targets
|
|
137
|
+
5. **FilesArrayPlugin** - Generates files array, excludes source maps
|
|
109
138
|
|
|
110
139
|
## How It Works
|
|
111
140
|
|
|
@@ -131,8 +160,31 @@ For detailed documentation, see the [docs/](./docs/) directory:
|
|
|
131
160
|
|
|
132
161
|
## Examples
|
|
133
162
|
|
|
134
|
-
|
|
135
|
-
|
|
163
|
+
This package builds itself using its own `NodeLibraryBuilder`. See
|
|
164
|
+
[`rslib.config.ts`](./rslib.config.ts) for a production example demonstrating:
|
|
165
|
+
|
|
166
|
+
- API model generation for documentation tooling
|
|
167
|
+
- External package configuration
|
|
168
|
+
- Custom package.json transformations
|
|
169
|
+
- Copy patterns for static files
|
|
170
|
+
|
|
171
|
+
### Programmatic Usage
|
|
172
|
+
|
|
173
|
+
Use `ImportGraph` to discover all files reachable from your package exports:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { ImportGraph } from '@savvy-web/rslib-builder';
|
|
177
|
+
|
|
178
|
+
const result = ImportGraph.fromPackageExports('./package.json', {
|
|
179
|
+
rootDir: process.cwd(),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
console.log('Public API files:', result.files);
|
|
183
|
+
console.log('Entry points:', result.entries);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
See [Configuration](./docs/guides/configuration.md#importgraph-utility) for more
|
|
187
|
+
examples.
|
|
136
188
|
|
|
137
189
|
## Support
|
|
138
190
|
|
|
@@ -142,19 +194,19 @@ GitHub Issues, we cannot guarantee response times or resolution.
|
|
|
142
194
|
|
|
143
195
|
For security vulnerabilities, please see [SECURITY.md](./SECURITY.md).
|
|
144
196
|
|
|
145
|
-
##
|
|
197
|
+
## Links
|
|
146
198
|
|
|
147
|
-
[
|
|
199
|
+
- [RSlib Documentation](https://rslib.dev/)
|
|
200
|
+
- [Rsbuild Plugin API](https://rsbuild.dev/plugins/dev/core)
|
|
201
|
+
- [API Extractor](https://api-extractor.com/)
|
|
202
|
+
- [PNPM Workspace](https://pnpm.io/workspaces)
|
|
203
|
+
- [PNPM Catalogs](https://pnpm.io/catalogs)
|
|
148
204
|
|
|
149
205
|
## Contributing
|
|
150
206
|
|
|
151
207
|
Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup
|
|
152
208
|
and guidelines.
|
|
153
209
|
|
|
154
|
-
##
|
|
210
|
+
## License
|
|
155
211
|
|
|
156
|
-
|
|
157
|
-
- [Rsbuild Plugin API](https://rsbuild.dev/plugins/dev/core)
|
|
158
|
-
- [API Extractor](https://api-extractor.com/)
|
|
159
|
-
- [PNPM Workspace](https://pnpm.io/workspaces)
|
|
160
|
-
- [PNPM Catalogs](https://pnpm.io/catalogs)
|
|
212
|
+
[MIT](./LICENSE)
|