@savvy-web/rslib-builder 0.3.0 → 0.5.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 +64 -18
- package/index.d.ts +1118 -3
- package/index.js +441 -11
- package/package.json +14 -7
- package/tsconfig/ecma/lib.json +1 -1
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
|
|
@@ -96,16 +103,32 @@ rslib build --env-mode dev
|
|
|
96
103
|
rslib build --env-mode npm
|
|
97
104
|
```
|
|
98
105
|
|
|
106
|
+
## API Overview
|
|
107
|
+
|
|
108
|
+
The package exports a main builder and several plugins:
|
|
109
|
+
|
|
110
|
+
| Export | Description |
|
|
111
|
+
| ---------------------------- | --------------------------------------------- |
|
|
112
|
+
| `NodeLibraryBuilder` | Main API for building Node.js libraries |
|
|
113
|
+
| `AutoEntryPlugin` | Auto-extracts entry points from package.json |
|
|
114
|
+
| `DtsPlugin` | Generates TypeScript declarations with tsgo |
|
|
115
|
+
| `PackageJsonTransformPlugin` | Transforms package.json for distribution |
|
|
116
|
+
| `FilesArrayPlugin` | Generates files array for npm publishing |
|
|
117
|
+
| `TsDocLintPlugin` | Validates TSDoc comments before build |
|
|
118
|
+
| `TsDocConfigBuilder` | Utility for TSDoc configuration |
|
|
119
|
+
| `ImportGraph` | Traces TypeScript imports for file discovery |
|
|
120
|
+
|
|
99
121
|
See [Configuration](./docs/guides/configuration.md) for all options.
|
|
100
122
|
|
|
101
123
|
## Plugins
|
|
102
124
|
|
|
103
125
|
The builder includes several built-in plugins:
|
|
104
126
|
|
|
105
|
-
1. **
|
|
106
|
-
2. **
|
|
127
|
+
1. **TsDocLintPlugin** - Validates TSDoc comments before build (optional)
|
|
128
|
+
2. **AutoEntryPlugin** - Auto-extracts entry points from package.json exports
|
|
107
129
|
3. **DtsPlugin** - Generates TypeScript declarations with tsgo/API Extractor
|
|
108
|
-
4. **
|
|
130
|
+
4. **PackageJsonTransformPlugin** - Transforms package.json for targets
|
|
131
|
+
5. **FilesArrayPlugin** - Generates files array, excludes source maps
|
|
109
132
|
|
|
110
133
|
## How It Works
|
|
111
134
|
|
|
@@ -131,8 +154,31 @@ For detailed documentation, see the [docs/](./docs/) directory:
|
|
|
131
154
|
|
|
132
155
|
## Examples
|
|
133
156
|
|
|
134
|
-
|
|
135
|
-
|
|
157
|
+
This package builds itself using its own `NodeLibraryBuilder`. See
|
|
158
|
+
[`rslib.config.ts`](./rslib.config.ts) for a production example demonstrating:
|
|
159
|
+
|
|
160
|
+
- API model generation for documentation tooling
|
|
161
|
+
- External package configuration
|
|
162
|
+
- Custom package.json transformations
|
|
163
|
+
- Copy patterns for static files
|
|
164
|
+
|
|
165
|
+
### Programmatic Usage
|
|
166
|
+
|
|
167
|
+
Use `ImportGraph` to discover all files reachable from your package exports:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { ImportGraph } from '@savvy-web/rslib-builder';
|
|
171
|
+
|
|
172
|
+
const result = ImportGraph.fromPackageExports('./package.json', {
|
|
173
|
+
rootDir: process.cwd(),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log('Public API files:', result.files);
|
|
177
|
+
console.log('Entry points:', result.entries);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
See [Configuration](./docs/guides/configuration.md#importgraph-utility) for more
|
|
181
|
+
examples.
|
|
136
182
|
|
|
137
183
|
## Support
|
|
138
184
|
|
|
@@ -142,19 +188,19 @@ GitHub Issues, we cannot guarantee response times or resolution.
|
|
|
142
188
|
|
|
143
189
|
For security vulnerabilities, please see [SECURITY.md](./SECURITY.md).
|
|
144
190
|
|
|
145
|
-
##
|
|
191
|
+
## Links
|
|
146
192
|
|
|
147
|
-
[
|
|
193
|
+
- [RSlib Documentation](https://rslib.dev/)
|
|
194
|
+
- [Rsbuild Plugin API](https://rsbuild.dev/plugins/dev/core)
|
|
195
|
+
- [API Extractor](https://api-extractor.com/)
|
|
196
|
+
- [PNPM Workspace](https://pnpm.io/workspaces)
|
|
197
|
+
- [PNPM Catalogs](https://pnpm.io/catalogs)
|
|
148
198
|
|
|
149
199
|
## Contributing
|
|
150
200
|
|
|
151
201
|
Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup
|
|
152
202
|
and guidelines.
|
|
153
203
|
|
|
154
|
-
##
|
|
204
|
+
## License
|
|
155
205
|
|
|
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)
|
|
206
|
+
[MIT](./LICENSE)
|