@savvy-web/rslib-builder 0.7.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 +4 -81
- package/index.d.ts +959 -337
- package/index.js +135 -130
- package/package.json +6 -3
- package/tsdoc-metadata.json +1 -1
- package/rslib-runtime.js +0 -18
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:`
|
|
@@ -58,10 +58,7 @@ Extend the provided tsconfig for optimal settings:
|
|
|
58
58
|
```jsonc
|
|
59
59
|
// tsconfig.json
|
|
60
60
|
{
|
|
61
|
-
"extends": "@savvy-web/rslib-builder/tsconfig/ecma/lib.json"
|
|
62
|
-
"compilerOptions": {
|
|
63
|
-
"outDir": "dist"
|
|
64
|
-
}
|
|
61
|
+
"extends": "@savvy-web/rslib-builder/tsconfig/ecma/lib.json"
|
|
65
62
|
}
|
|
66
63
|
```
|
|
67
64
|
|
|
@@ -92,57 +89,6 @@ Add scripts to your `package.json`:
|
|
|
92
89
|
}
|
|
93
90
|
```
|
|
94
91
|
|
|
95
|
-
## Build Targets
|
|
96
|
-
|
|
97
|
-
Two build targets available via `--env-mode`:
|
|
98
|
-
|
|
99
|
-
- **dev** - Unminified with source maps for local development
|
|
100
|
-
- **npm** - Optimized for npm publishing (Node.js runtime)
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
rslib build --env-mode dev
|
|
104
|
-
rslib build --env-mode npm
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## API Overview
|
|
108
|
-
|
|
109
|
-
The package exports a main builder and several plugins:
|
|
110
|
-
|
|
111
|
-
| Export | Description |
|
|
112
|
-
| ---------------------------- | --------------------------------------------- |
|
|
113
|
-
| `NodeLibraryBuilder` | Main API for building Node.js libraries |
|
|
114
|
-
| `AutoEntryPlugin` | Auto-extracts entry points from package.json |
|
|
115
|
-
| `DtsPlugin` | Generates TypeScript declarations with tsgo |
|
|
116
|
-
| `PackageJsonTransformPlugin` | Transforms package.json for distribution |
|
|
117
|
-
| `FilesArrayPlugin` | Generates files array for npm publishing |
|
|
118
|
-
| `TsDocLintPlugin` | Validates TSDoc comments before build |
|
|
119
|
-
| `TsDocConfigBuilder` | Utility for TSDoc configuration |
|
|
120
|
-
| `ImportGraph` | Traces TypeScript imports for file discovery |
|
|
121
|
-
|
|
122
|
-
See [Configuration](./docs/guides/configuration.md) for all options.
|
|
123
|
-
|
|
124
|
-
## Plugins
|
|
125
|
-
|
|
126
|
-
The builder includes several built-in plugins:
|
|
127
|
-
|
|
128
|
-
1. **TsDocLintPlugin** - Validates TSDoc comments before build (optional)
|
|
129
|
-
2. **AutoEntryPlugin** - Auto-extracts entry points from package.json exports
|
|
130
|
-
3. **DtsPlugin** - Generates TypeScript declarations with tsgo/API Extractor
|
|
131
|
-
4. **PackageJsonTransformPlugin** - Transforms package.json for targets
|
|
132
|
-
5. **FilesArrayPlugin** - Generates files array, excludes source maps
|
|
133
|
-
|
|
134
|
-
## How It Works
|
|
135
|
-
|
|
136
|
-
The builder automatically transforms your source package.json for distribution:
|
|
137
|
-
|
|
138
|
-
- **Entry Detection** - Extracts entry points from package.json exports
|
|
139
|
-
- **Export Transformation** - Converts `.ts` paths to `.js` in exports field
|
|
140
|
-
- **Bin Transformation** - Converts bin entries from `.ts` to `.js` scripts
|
|
141
|
-
- **PNPM Resolution** - Resolves `catalog:` and `workspace:` to real versions
|
|
142
|
-
- **Files Generation** - Creates accurate `files` array for npm publishing
|
|
143
|
-
- **Declaration Bundling** - Uses tsgo for fast generation and API Extractor
|
|
144
|
-
for bundling
|
|
145
|
-
|
|
146
92
|
## Documentation
|
|
147
93
|
|
|
148
94
|
For detailed documentation, see the [docs/](./docs/) directory:
|
|
@@ -153,33 +99,10 @@ For detailed documentation, see the [docs/](./docs/) directory:
|
|
|
153
99
|
- [Architecture](./docs/architecture/overview.md) - How it works internally
|
|
154
100
|
- [Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
|
|
155
101
|
|
|
156
|
-
##
|
|
102
|
+
## Example
|
|
157
103
|
|
|
158
104
|
This package builds itself using its own `NodeLibraryBuilder`. See
|
|
159
|
-
[`rslib.config.ts`](./rslib.config.ts) for a production example
|
|
160
|
-
|
|
161
|
-
- API model generation for documentation tooling
|
|
162
|
-
- External package configuration
|
|
163
|
-
- Custom package.json transformations
|
|
164
|
-
- Copy patterns for static files
|
|
165
|
-
|
|
166
|
-
### Programmatic Usage
|
|
167
|
-
|
|
168
|
-
Use `ImportGraph` to discover all files reachable from your package exports:
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { ImportGraph } from '@savvy-web/rslib-builder';
|
|
172
|
-
|
|
173
|
-
const result = ImportGraph.fromPackageExports('./package.json', {
|
|
174
|
-
rootDir: process.cwd(),
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
console.log('Public API files:', result.files);
|
|
178
|
-
console.log('Entry points:', result.entries);
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
See [Configuration](./docs/guides/configuration.md#importgraph-utility) for more
|
|
182
|
-
examples.
|
|
105
|
+
[`rslib.config.ts`](./rslib.config.ts) for a production example.
|
|
183
106
|
|
|
184
107
|
## Support
|
|
185
108
|
|