@savvy-web/rslib-builder 0.6.0 → 0.8.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 CHANGED
@@ -19,7 +19,7 @@ focus on your code.
19
19
  - **Fast Type Generation** - Uses tsgo (native TypeScript) for 10-100x faster
20
20
  declaration generation
21
21
  - **Bundled Declarations** - Rolls up TypeScript types via API Extractor for
22
- cleaner public APIs
22
+ cleaner public APIs, with multi-entry support for packages with multiple exports
23
23
  - **Multi-Target Builds** - Separate dev (source maps) and npm (optimized)
24
24
  outputs
25
25
  - **PNPM Integration** - Automatically resolves `catalog:` and `workspace:`
@@ -27,7 +27,8 @@ focus on your code.
27
27
  - **Package.json Transform** - Converts `.ts` exports to `.js`, generates files
28
28
  array, removes dev-only fields
29
29
  - **TSDoc Validation** - Pre-build TSDoc validation with automatic public API discovery
30
- - **API Model Generation** - Optional API model output for documentation tooling
30
+ - **API Model Generation** - Optional API model and resolved tsconfig output for
31
+ documentation tooling
31
32
  - **Extensible** - Add custom RSlib/Rsbuild plugins for advanced use cases
32
33
 
33
34
  ## Prerequisites
@@ -57,10 +58,7 @@ Extend the provided tsconfig for optimal settings:
57
58
  ```jsonc
58
59
  // tsconfig.json
59
60
  {
60
- "extends": "@savvy-web/rslib-builder/tsconfig/ecma/lib.json",
61
- "compilerOptions": {
62
- "outDir": "dist"
63
- }
61
+ "extends": "@savvy-web/rslib-builder/tsconfig/ecma/lib.json"
64
62
  }
65
63
  ```
66
64
 
@@ -91,57 +89,6 @@ Add scripts to your `package.json`:
91
89
  }
92
90
  ```
93
91
 
94
- ## Build Targets
95
-
96
- Two build targets available via `--env-mode`:
97
-
98
- - **dev** - Unminified with source maps for local development
99
- - **npm** - Optimized for npm publishing (Node.js runtime)
100
-
101
- ```bash
102
- rslib build --env-mode dev
103
- rslib build --env-mode npm
104
- ```
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
-
121
- See [Configuration](./docs/guides/configuration.md) for all options.
122
-
123
- ## Plugins
124
-
125
- The builder includes several built-in plugins:
126
-
127
- 1. **TsDocLintPlugin** - Validates TSDoc comments before build (optional)
128
- 2. **AutoEntryPlugin** - Auto-extracts entry points from package.json exports
129
- 3. **DtsPlugin** - Generates TypeScript declarations with tsgo/API Extractor
130
- 4. **PackageJsonTransformPlugin** - Transforms package.json for targets
131
- 5. **FilesArrayPlugin** - Generates files array, excludes source maps
132
-
133
- ## How It Works
134
-
135
- The builder automatically transforms your source package.json for distribution:
136
-
137
- - **Entry Detection** - Extracts entry points from package.json exports
138
- - **Export Transformation** - Converts `.ts` paths to `.js` in exports field
139
- - **Bin Transformation** - Converts bin entries from `.ts` to `.js` scripts
140
- - **PNPM Resolution** - Resolves `catalog:` and `workspace:` to real versions
141
- - **Files Generation** - Creates accurate `files` array for npm publishing
142
- - **Declaration Bundling** - Uses tsgo for fast generation and API Extractor
143
- for bundling
144
-
145
92
  ## Documentation
146
93
 
147
94
  For detailed documentation, see the [docs/](./docs/) directory:
@@ -152,33 +99,10 @@ For detailed documentation, see the [docs/](./docs/) directory:
152
99
  - [Architecture](./docs/architecture/overview.md) - How it works internally
153
100
  - [Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
154
101
 
155
- ## Examples
102
+ ## Example
156
103
 
157
104
  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.
105
+ [`rslib.config.ts`](./rslib.config.ts) for a production example.
182
106
 
183
107
  ## Support
184
108