@savvy-web/rslib-builder 0.1.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/.npmignore +2 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/api.model.json +3022 -0
- package/index.d.ts +855 -0
- package/index.js +1521 -0
- package/package.json +86 -0
- package/rslib-runtime.js +18 -0
- package/tsconfig/node/ecma/lib.json +49 -0
- package/tsconfig/root.json +13 -0
package/.npmignore
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Savvy Web Strategy, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @savvy-web/rslib-builder
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@savvy-web/rslib-builder)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
Build modern ESM Node.js libraries with zero configuration. Handles TypeScript
|
|
8
|
+
declarations, package.json transformations, and PNPM workspace resolution
|
|
9
|
+
automatically.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Zero Config** - Auto-detects entry points from package.json exports
|
|
14
|
+
- **Fast Type Generation** - Uses tsgo (native TypeScript) for 10-100x faster
|
|
15
|
+
declaration generation
|
|
16
|
+
- **Bundled Declarations** - Rolls up TypeScript types via API Extractor for
|
|
17
|
+
cleaner public APIs
|
|
18
|
+
- **Multi-Target Builds** - Separate dev (source maps) and npm (optimized)
|
|
19
|
+
outputs
|
|
20
|
+
- **PNPM Integration** - Automatically resolves `catalog:` and `workspace:`
|
|
21
|
+
references
|
|
22
|
+
- **Package.json Transform** - Converts `.ts` exports and bin entries to `.js`,
|
|
23
|
+
generates files array, removes dev-only fields
|
|
24
|
+
- **Extensible** - Add custom RSlib/Rsbuild plugins for advanced use cases
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Node.js 24.x or later
|
|
29
|
+
- pnpm 10.x or later
|
|
30
|
+
- TypeScript 5.9.x or later
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add -D @savvy-web/rslib-builder
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Peer Dependencies
|
|
39
|
+
|
|
40
|
+
Install the required peer dependencies:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pnpm add -D @rslib/core @microsoft/api-extractor @typescript/native-preview
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
Extend the provided tsconfig for optimal settings:
|
|
49
|
+
|
|
50
|
+
```jsonc
|
|
51
|
+
// tsconfig.json
|
|
52
|
+
{
|
|
53
|
+
"extends": "@savvy-web/rslib-builder/tsconfig/node/ecma/lib.json",
|
|
54
|
+
"compilerOptions": {
|
|
55
|
+
"outDir": "dist"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Create an `rslib.config.ts` in your project root:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { NodeLibraryBuilder } from '@savvy-web/rslib-builder';
|
|
64
|
+
|
|
65
|
+
export default NodeLibraryBuilder.create({
|
|
66
|
+
externals: ['@rslib/core'],
|
|
67
|
+
transform({ pkg, target }) {
|
|
68
|
+
if (target === 'npm') {
|
|
69
|
+
delete pkg.devDependencies;
|
|
70
|
+
}
|
|
71
|
+
return pkg;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Add scripts to your `package.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "rslib build --env-mode dev",
|
|
82
|
+
"build:npm": "rslib build --env-mode npm"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Build Targets
|
|
88
|
+
|
|
89
|
+
Two build targets available via `--env-mode`:
|
|
90
|
+
|
|
91
|
+
- **dev** - Unminified with source maps for local development
|
|
92
|
+
- **npm** - Optimized for npm publishing (Node.js runtime)
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
rslib build --env-mode dev
|
|
96
|
+
rslib build --env-mode npm
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See [Configuration](./docs/guides/configuration.md) for all options.
|
|
100
|
+
|
|
101
|
+
## Plugins
|
|
102
|
+
|
|
103
|
+
The builder includes several built-in plugins:
|
|
104
|
+
|
|
105
|
+
1. **AutoEntryPlugin** - Auto-extracts entry points from package.json exports
|
|
106
|
+
2. **PackageJsonTransformPlugin** - Transforms package.json for targets
|
|
107
|
+
3. **DtsPlugin** - Generates TypeScript declarations with tsgo/API Extractor
|
|
108
|
+
4. **FilesArrayPlugin** - Generates files array, excludes source maps
|
|
109
|
+
|
|
110
|
+
## How It Works
|
|
111
|
+
|
|
112
|
+
The builder automatically transforms your source package.json for distribution:
|
|
113
|
+
|
|
114
|
+
- **Entry Detection** - Extracts entry points from package.json exports
|
|
115
|
+
- **Export Transformation** - Converts `.ts` paths to `.js` in exports field
|
|
116
|
+
- **Bin Transformation** - Converts bin entries from `.ts` to `.js` scripts
|
|
117
|
+
- **PNPM Resolution** - Resolves `catalog:` and `workspace:` to real versions
|
|
118
|
+
- **Files Generation** - Creates accurate `files` array for npm publishing
|
|
119
|
+
- **Declaration Bundling** - Uses tsgo for fast generation and API Extractor
|
|
120
|
+
for bundling
|
|
121
|
+
|
|
122
|
+
## Documentation
|
|
123
|
+
|
|
124
|
+
For detailed documentation, see the [docs/](./docs/) directory:
|
|
125
|
+
|
|
126
|
+
- [Getting Started](./docs/guides/getting-started.md) - Installation and setup
|
|
127
|
+
- [Configuration](./docs/guides/configuration.md) - All options explained
|
|
128
|
+
- [Plugin System](./docs/guides/plugins.md) - Built-in and custom plugins
|
|
129
|
+
- [Architecture](./docs/architecture/overview.md) - How it works internally
|
|
130
|
+
- [Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
|
|
131
|
+
|
|
132
|
+
## Examples
|
|
133
|
+
|
|
134
|
+
See the repository's own `rslib.config.ts` for a real-world example of the
|
|
135
|
+
builder building itself.
|
|
136
|
+
|
|
137
|
+
## Support
|
|
138
|
+
|
|
139
|
+
This software is provided as-is under the MIT License with no warranty or
|
|
140
|
+
support guarantees. While we welcome bug reports and feature requests via
|
|
141
|
+
GitHub Issues, we cannot guarantee response times or resolution.
|
|
142
|
+
|
|
143
|
+
For security vulnerabilities, please see [SECURITY.md](./SECURITY.md).
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
[MIT](./LICENSE)
|
|
148
|
+
|
|
149
|
+
## Contributing
|
|
150
|
+
|
|
151
|
+
Contributions welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup
|
|
152
|
+
and guidelines.
|
|
153
|
+
|
|
154
|
+
## Links
|
|
155
|
+
|
|
156
|
+
- [RSlib Documentation](https://rslib.dev/)
|
|
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)
|