@savvy-web/rslib-builder 0.14.5 → 0.15.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/index.d.ts +181 -46
- package/index.js +154 -56
- package/package.json +102 -102
package/index.d.ts
CHANGED
|
@@ -236,15 +236,15 @@ export declare interface AutoEntryPluginOptions {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
* Build
|
|
239
|
+
* Build mode environment for library output.
|
|
240
240
|
*
|
|
241
241
|
* @remarks
|
|
242
|
-
* Each
|
|
242
|
+
* Each mode produces different output optimizations:
|
|
243
243
|
* - `"dev"`: Development build with source maps for debugging
|
|
244
244
|
* - `"npm"`: Production build optimized for npm publishing
|
|
245
245
|
*
|
|
246
246
|
* @example
|
|
247
|
-
* Specifying
|
|
247
|
+
* Specifying modes via CLI:
|
|
248
248
|
* ```bash
|
|
249
249
|
* rslib build --env-mode dev
|
|
250
250
|
* rslib build --env-mode npm
|
|
@@ -252,7 +252,7 @@ export declare interface AutoEntryPluginOptions {
|
|
|
252
252
|
*
|
|
253
253
|
* @public
|
|
254
254
|
*/
|
|
255
|
-
export declare type
|
|
255
|
+
export declare type BuildMode = "dev" | "npm";
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
258
|
* Configuration for copying files during the build process.
|
|
@@ -402,10 +402,10 @@ export declare interface DtsPluginOptions {
|
|
|
402
402
|
*/
|
|
403
403
|
footer?: string;
|
|
404
404
|
/**
|
|
405
|
-
* Build
|
|
405
|
+
* Build mode (dev, npm).
|
|
406
406
|
* Used to generate the correct temp tsconfig when tsconfigPath is not provided.
|
|
407
407
|
*/
|
|
408
|
-
|
|
408
|
+
buildMode?: "dev" | "npm";
|
|
409
409
|
/**
|
|
410
410
|
* Output format for the library.
|
|
411
411
|
* Affects the resolved tsconfig.json module settings:
|
|
@@ -578,7 +578,7 @@ export declare interface ExtractedEntries {
|
|
|
578
578
|
*
|
|
579
579
|
* export default {
|
|
580
580
|
* plugins: [
|
|
581
|
-
* FilesArrayPlugin({
|
|
581
|
+
* FilesArrayPlugin({ mode: 'npm' }),
|
|
582
582
|
* ],
|
|
583
583
|
* };
|
|
584
584
|
* ```
|
|
@@ -591,7 +591,7 @@ export declare interface ExtractedEntries {
|
|
|
591
591
|
* export default {
|
|
592
592
|
* plugins: [
|
|
593
593
|
* FilesArrayPlugin({
|
|
594
|
-
*
|
|
594
|
+
* mode: 'npm',
|
|
595
595
|
* transformFiles({ filesArray }) {
|
|
596
596
|
* filesArray.add('CHANGELOG.md');
|
|
597
597
|
* },
|
|
@@ -602,16 +602,16 @@ export declare interface ExtractedEntries {
|
|
|
602
602
|
*
|
|
603
603
|
* @public
|
|
604
604
|
*/
|
|
605
|
-
export declare const FilesArrayPlugin: <
|
|
605
|
+
export declare const FilesArrayPlugin: <TMode extends string = string>(options?: FilesArrayPluginOptions<TMode> | undefined) => RsbuildPlugin;
|
|
606
606
|
|
|
607
607
|
/**
|
|
608
608
|
* Options for the FilesArrayPlugin.
|
|
609
609
|
*
|
|
610
|
-
* @typeParam
|
|
610
|
+
* @typeParam TMode - The build mode type, defaults to string
|
|
611
611
|
*
|
|
612
612
|
* @public
|
|
613
613
|
*/
|
|
614
|
-
export declare interface FilesArrayPluginOptions<
|
|
614
|
+
export declare interface FilesArrayPluginOptions<TMode extends string = string> {
|
|
615
615
|
/**
|
|
616
616
|
* Optional callback to transform files after they're built but before the files array is finalized.
|
|
617
617
|
*
|
|
@@ -622,14 +622,14 @@ export declare interface FilesArrayPluginOptions<TTarget extends string = string
|
|
|
622
622
|
* @param context - Transform context containing:
|
|
623
623
|
* - `compilation`: Rspack compilation object with assets
|
|
624
624
|
* - `filesArray`: Set of files to be included in package.json `files` field
|
|
625
|
-
* - `
|
|
625
|
+
* - `mode`: Current build mode
|
|
626
626
|
*
|
|
627
627
|
* @example
|
|
628
628
|
* ```typescript
|
|
629
629
|
* import type { FilesArrayPluginOptions } from '@savvy-web/rslib-builder';
|
|
630
630
|
*
|
|
631
631
|
* const options: FilesArrayPluginOptions = {
|
|
632
|
-
*
|
|
632
|
+
* mode: 'npm',
|
|
633
633
|
* transformFiles({ compilation, filesArray }) {
|
|
634
634
|
* // Add a custom file to the output
|
|
635
635
|
* filesArray.add('custom-file.txt');
|
|
@@ -644,16 +644,25 @@ export declare interface FilesArrayPluginOptions<TTarget extends string = string
|
|
|
644
644
|
};
|
|
645
645
|
/** Set of files to include in package.json files array */
|
|
646
646
|
filesArray: Set<string>;
|
|
647
|
-
/** Current build
|
|
648
|
-
|
|
647
|
+
/** Current build mode */
|
|
648
|
+
mode: TMode;
|
|
649
|
+
/** The publish target for this build output, if configured */
|
|
650
|
+
target: PublishTarget | undefined;
|
|
649
651
|
}) => void | Promise<void>;
|
|
650
652
|
/**
|
|
651
|
-
* Build
|
|
653
|
+
* Build mode identifier (e.g., "dev", "npm").
|
|
654
|
+
*
|
|
655
|
+
* @remarks
|
|
656
|
+
* Passed to the `transformFiles` callback to allow mode-specific transformations.
|
|
657
|
+
*/
|
|
658
|
+
mode: TMode;
|
|
659
|
+
/**
|
|
660
|
+
* The publish target for this build output, if configured.
|
|
652
661
|
*
|
|
653
662
|
* @remarks
|
|
654
663
|
* Passed to the `transformFiles` callback to allow target-specific transformations.
|
|
655
664
|
*/
|
|
656
|
-
target
|
|
665
|
+
target?: PublishTarget;
|
|
657
666
|
/**
|
|
658
667
|
* Format directories to include in the files array.
|
|
659
668
|
* Used in dual format builds so npm's `files` field includes
|
|
@@ -1139,8 +1148,8 @@ export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = Lite
|
|
|
1139
1148
|
* export default NodeLibraryBuilder.create({
|
|
1140
1149
|
* externals: ['@rslib/core', '@rsbuild/core'],
|
|
1141
1150
|
* dtsBundledPackages: ['picocolors'],
|
|
1142
|
-
* transform({
|
|
1143
|
-
* if (
|
|
1151
|
+
* transform({ mode, pkg }) {
|
|
1152
|
+
* if (mode === 'npm') {
|
|
1144
1153
|
* delete pkg.devDependencies;
|
|
1145
1154
|
* }
|
|
1146
1155
|
* return pkg;
|
|
@@ -1161,8 +1170,8 @@ export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = Lite
|
|
|
1161
1170
|
* @public
|
|
1162
1171
|
*/
|
|
1163
1172
|
export declare class NodeLibraryBuilder {
|
|
1164
|
-
/** Valid build
|
|
1165
|
-
private static readonly
|
|
1173
|
+
/** Valid build modes for validation. */
|
|
1174
|
+
private static readonly VALID_MODES;
|
|
1166
1175
|
/**
|
|
1167
1176
|
* Default configuration options for NodeLibraryBuilder.
|
|
1168
1177
|
*
|
|
@@ -1194,7 +1203,7 @@ export declare class NodeLibraryBuilder {
|
|
|
1194
1203
|
*/
|
|
1195
1204
|
static mergeOptions(options?: Partial<NodeLibraryBuilderOptions>): NodeLibraryBuilderOptions;
|
|
1196
1205
|
/**
|
|
1197
|
-
* Creates an async RSLib configuration function that determines build
|
|
1206
|
+
* Creates an async RSLib configuration function that determines build mode from envMode.
|
|
1198
1207
|
*
|
|
1199
1208
|
* @remarks
|
|
1200
1209
|
* This is the primary entry point for using NodeLibraryBuilder. The returned function
|
|
@@ -1205,22 +1214,17 @@ export declare class NodeLibraryBuilder {
|
|
|
1205
1214
|
*/
|
|
1206
1215
|
static create(options?: Partial<NodeLibraryBuilderOptions>): RslibConfigAsyncFn;
|
|
1207
1216
|
/**
|
|
1208
|
-
* Creates a single-
|
|
1217
|
+
* Creates a single-mode build configuration.
|
|
1209
1218
|
*
|
|
1210
1219
|
* @remarks
|
|
1211
|
-
* This method is called internally by {@link NodeLibraryBuilder.create} for each build
|
|
1212
|
-
* It configures all plugins and RSLib options based on the
|
|
1220
|
+
* This method is called internally by {@link NodeLibraryBuilder.create} for each build mode.
|
|
1221
|
+
* It configures all plugins and RSLib options based on the mode and user options.
|
|
1213
1222
|
*
|
|
1214
|
-
* @param
|
|
1223
|
+
* @param mode - The build mode ("dev" or "npm")
|
|
1215
1224
|
* @param opts - Configuration options (will be merged with defaults)
|
|
1216
1225
|
* @returns Promise resolving to the RSLib configuration
|
|
1217
1226
|
*/
|
|
1218
|
-
static
|
|
1219
|
-
/**
|
|
1220
|
-
* Checks if the current package has exports defined in package.json.
|
|
1221
|
-
* @internal
|
|
1222
|
-
*/
|
|
1223
|
-
private static packageHasExports;
|
|
1227
|
+
static createSingleMode(mode: BuildMode, opts: NodeLibraryBuilderOptions): Promise<RslibConfig>;
|
|
1224
1228
|
}
|
|
1225
1229
|
|
|
1226
1230
|
/**
|
|
@@ -1400,8 +1404,8 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1400
1404
|
* @defaultValue `undefined` (auto-detected)
|
|
1401
1405
|
*/
|
|
1402
1406
|
tsconfigPath: string | undefined;
|
|
1403
|
-
/** Build
|
|
1404
|
-
targets?:
|
|
1407
|
+
/** Build modes to include (default: ["dev", "npm"]) */
|
|
1408
|
+
targets?: BuildMode[];
|
|
1405
1409
|
/**
|
|
1406
1410
|
* External dependencies that should not be bundled.
|
|
1407
1411
|
* These modules will be imported at runtime instead of being included in the bundle.
|
|
@@ -1447,7 +1451,7 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1447
1451
|
* @param context - Transform context with properties:
|
|
1448
1452
|
* - `compilation`: Rspack compilation object with assets
|
|
1449
1453
|
* - `filesArray`: Set of files that will be included in package.json files field
|
|
1450
|
-
* - `
|
|
1454
|
+
* - `mode`: Current build mode (dev/npm)
|
|
1451
1455
|
*
|
|
1452
1456
|
* @example
|
|
1453
1457
|
* ```typescript
|
|
@@ -1471,7 +1475,10 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1471
1475
|
assets: Record<string, unknown>;
|
|
1472
1476
|
};
|
|
1473
1477
|
filesArray: Set<string>;
|
|
1474
|
-
|
|
1478
|
+
/** Current build mode */
|
|
1479
|
+
mode: BuildMode;
|
|
1480
|
+
/** The publish target for this build output, if configured */
|
|
1481
|
+
target: PublishTarget | undefined;
|
|
1475
1482
|
}) => void | Promise<void>;
|
|
1476
1483
|
/**
|
|
1477
1484
|
* Optional transform function to modify package.json before it's saved.
|
|
@@ -1485,8 +1492,8 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1485
1492
|
* import { NodeLibraryBuilder } from '@savvy-web/rslib-builder';
|
|
1486
1493
|
*
|
|
1487
1494
|
* export default NodeLibraryBuilder.create({
|
|
1488
|
-
* transform({
|
|
1489
|
-
* if (
|
|
1495
|
+
* transform({ mode, pkg }) {
|
|
1496
|
+
* if (mode === 'npm') {
|
|
1490
1497
|
* delete pkg.devDependencies;
|
|
1491
1498
|
* delete pkg.scripts;
|
|
1492
1499
|
* }
|
|
@@ -1499,7 +1506,7 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1499
1506
|
/**
|
|
1500
1507
|
* Options for API model generation.
|
|
1501
1508
|
* Generates an `<unscopedPackageName>.api.json` file in the dist directory.
|
|
1502
|
-
* Only applies when
|
|
1509
|
+
* Only applies when mode is "npm".
|
|
1503
1510
|
*
|
|
1504
1511
|
* @remarks
|
|
1505
1512
|
* API model generation is **enabled by default**. The generated file contains
|
|
@@ -1792,6 +1799,12 @@ export declare namespace PackageJson {
|
|
|
1792
1799
|
* @defaultValue `'latest'`
|
|
1793
1800
|
*/
|
|
1794
1801
|
tag?: string;
|
|
1802
|
+
/**
|
|
1803
|
+
* Publish targets for multi-registry publishing.
|
|
1804
|
+
* Supports shorthand strings (`"npm"`, `"github"`, `"jsr"`, or a URL)
|
|
1805
|
+
* and full target objects.
|
|
1806
|
+
*/
|
|
1807
|
+
targets?: Array<Record<string, JsonValue> | string>;
|
|
1795
1808
|
}
|
|
1796
1809
|
/**
|
|
1797
1810
|
* Type for npm's `package.json` file containing standard npm properties.
|
|
@@ -2002,6 +2015,7 @@ export declare type PackageJson = JsonObject & PackageJson.NodeJsStandard & Pack
|
|
|
2002
2015
|
* - Consumes `entrypoints` map from AutoEntryPlugin
|
|
2003
2016
|
* - Consumes `exportToOutputMap` for exportsAsIndexes mode
|
|
2004
2017
|
* - Consumes `use-rollup-types` flag from DtsPlugin
|
|
2018
|
+
* - Exposes `base-package-json` after standard transforms (before user transform)
|
|
2005
2019
|
*
|
|
2006
2020
|
* @param options - Plugin configuration options
|
|
2007
2021
|
*
|
|
@@ -2108,13 +2122,13 @@ export declare interface PackageJsonTransformPluginOptions {
|
|
|
2108
2122
|
*/
|
|
2109
2123
|
bundle?: boolean;
|
|
2110
2124
|
/**
|
|
2111
|
-
* Build
|
|
2125
|
+
* Build mode identifier for custom transformations.
|
|
2112
2126
|
*
|
|
2113
2127
|
* @remarks
|
|
2114
|
-
* Passed to the transform function to allow
|
|
2128
|
+
* Passed to the transform function to allow mode-specific modifications.
|
|
2115
2129
|
* Common values: "dev", "npm"
|
|
2116
2130
|
*/
|
|
2117
|
-
|
|
2131
|
+
mode?: string;
|
|
2118
2132
|
/**
|
|
2119
2133
|
* Custom transform function to modify package.json after standard transformations.
|
|
2120
2134
|
*
|
|
@@ -2162,6 +2176,104 @@ export declare interface PackageJsonTransformPluginOptions {
|
|
|
2162
2176
|
*/
|
|
2163
2177
|
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2164
2178
|
|
|
2179
|
+
/**
|
|
2180
|
+
* Publishing protocol for a publish target.
|
|
2181
|
+
*
|
|
2182
|
+
* @remarks
|
|
2183
|
+
* - `"npm"` - npm-compatible registries (npmjs, GitHub Packages, Verdaccio, etc.)
|
|
2184
|
+
* - `"jsr"` - JavaScript Registry (jsr.io)
|
|
2185
|
+
*
|
|
2186
|
+
* @public
|
|
2187
|
+
*/
|
|
2188
|
+
export declare type PublishProtocol = "npm" | "jsr";
|
|
2189
|
+
|
|
2190
|
+
/**
|
|
2191
|
+
* A resolved publish target from `publishConfig.targets`.
|
|
2192
|
+
*
|
|
2193
|
+
* @remarks
|
|
2194
|
+
* Aligns with `ResolvedTarget` from workflow-release-action,
|
|
2195
|
+
* minus authentication-specific fields.
|
|
2196
|
+
*
|
|
2197
|
+
* @public
|
|
2198
|
+
*/
|
|
2199
|
+
export declare interface PublishTarget {
|
|
2200
|
+
/** The publishing protocol. */
|
|
2201
|
+
protocol: PublishProtocol;
|
|
2202
|
+
/** The registry URL, or `null` for JSR targets. */
|
|
2203
|
+
registry: string | null;
|
|
2204
|
+
/** The absolute path to the output directory for this target. */
|
|
2205
|
+
directory: string;
|
|
2206
|
+
/** Package access level for scoped packages. */
|
|
2207
|
+
access: "public" | "restricted";
|
|
2208
|
+
/** Whether provenance attestations are configured. */
|
|
2209
|
+
provenance: boolean;
|
|
2210
|
+
/** The publish tag (e.g., "latest", "next", "beta"). */
|
|
2211
|
+
tag: string;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Plugin to produce per-target output directories for multi-registry publishing.
|
|
2216
|
+
*
|
|
2217
|
+
* @remarks
|
|
2218
|
+
* Runs in `onCloseBuild` after the primary build completes. For each additional
|
|
2219
|
+
* publish target (beyond the primary):
|
|
2220
|
+
*
|
|
2221
|
+
* 1. Creates the target directory
|
|
2222
|
+
* 2. Copies all build output from the primary output directory
|
|
2223
|
+
* 3. Reads the exposed `base-package-json` (after standard transforms, before user transform)
|
|
2224
|
+
* 4. Applies the user transform with the target-specific context
|
|
2225
|
+
* 5. Applies optional name override
|
|
2226
|
+
* 6. Copies the `files` array from the primary output's package.json
|
|
2227
|
+
* 7. Writes the final package.json to the target directory
|
|
2228
|
+
*
|
|
2229
|
+
* @param options - Plugin configuration options
|
|
2230
|
+
*
|
|
2231
|
+
* @public
|
|
2232
|
+
*/
|
|
2233
|
+
export declare const PublishTargetPlugin: (options: PublishTargetPluginOptions) => RsbuildPlugin;
|
|
2234
|
+
|
|
2235
|
+
/**
|
|
2236
|
+
* Options for the PublishTargetPlugin.
|
|
2237
|
+
*
|
|
2238
|
+
* @public
|
|
2239
|
+
*/
|
|
2240
|
+
export declare interface PublishTargetPluginOptions {
|
|
2241
|
+
/**
|
|
2242
|
+
* Additional publish targets to write output for (targets beyond the primary).
|
|
2243
|
+
*
|
|
2244
|
+
* @remarks
|
|
2245
|
+
* Each target gets a copy of the primary build output with per-target
|
|
2246
|
+
* package.json transformations applied.
|
|
2247
|
+
*/
|
|
2248
|
+
additionalTargets: PublishTarget[];
|
|
2249
|
+
/**
|
|
2250
|
+
* Absolute path to the primary output directory.
|
|
2251
|
+
*
|
|
2252
|
+
* @remarks
|
|
2253
|
+
* The primary build output is copied from this directory to each
|
|
2254
|
+
* additional target's directory.
|
|
2255
|
+
*/
|
|
2256
|
+
primaryOutdir: string;
|
|
2257
|
+
/**
|
|
2258
|
+
* Current build mode (e.g., "npm").
|
|
2259
|
+
*/
|
|
2260
|
+
mode: string;
|
|
2261
|
+
/**
|
|
2262
|
+
* Optional user transform function applied to each target's package.json.
|
|
2263
|
+
*
|
|
2264
|
+
* @remarks
|
|
2265
|
+
* Called after copying the base package.json state for each additional target.
|
|
2266
|
+
*/
|
|
2267
|
+
transform?: TransformPackageJsonFn;
|
|
2268
|
+
/**
|
|
2269
|
+
* Optional package name override.
|
|
2270
|
+
*
|
|
2271
|
+
* @remarks
|
|
2272
|
+
* When provided, overrides the `name` field in each additional target's package.json.
|
|
2273
|
+
*/
|
|
2274
|
+
name?: string;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2165
2277
|
/**
|
|
2166
2278
|
* Compiler options with enum values converted to strings.
|
|
2167
2279
|
*
|
|
@@ -2205,6 +2317,24 @@ export declare interface ResolvedTsconfig {
|
|
|
2205
2317
|
compilerOptions: ResolvedCompilerOptions;
|
|
2206
2318
|
}
|
|
2207
2319
|
|
|
2320
|
+
/**
|
|
2321
|
+
* Resolve publish targets from package.json's `publishConfig.targets`.
|
|
2322
|
+
*
|
|
2323
|
+
* @remarks
|
|
2324
|
+
* Expands shorthand strings (`"npm"`, `"github"`, `"jsr"`, or a URL) into
|
|
2325
|
+
* fully resolved {@link PublishTarget} objects. Mirrors the resolution logic
|
|
2326
|
+
* in workflow-release-action, but only produces the subset of fields
|
|
2327
|
+
* relevant to the build process.
|
|
2328
|
+
*
|
|
2329
|
+
* @param packageJson - The parsed package.json
|
|
2330
|
+
* @param cwd - The package root directory (for resolving relative directories)
|
|
2331
|
+
* @param outdir - The default output directory (used when no target directory is specified)
|
|
2332
|
+
* @returns Array of resolved publish targets (empty if none configured)
|
|
2333
|
+
*
|
|
2334
|
+
* @public
|
|
2335
|
+
*/
|
|
2336
|
+
export declare function resolvePublishTargets(packageJson: PackageJson, cwd: string, outdir: string): PublishTarget[];
|
|
2337
|
+
|
|
2208
2338
|
/**
|
|
2209
2339
|
* Async RSLib configuration function type.
|
|
2210
2340
|
* @public
|
|
@@ -2220,7 +2350,11 @@ export declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibCon
|
|
|
2220
2350
|
* Mutations to the `pkg` object are also supported.
|
|
2221
2351
|
*
|
|
2222
2352
|
* @param context - Transform context containing:
|
|
2223
|
-
* - `
|
|
2353
|
+
* - `mode`: The current build mode ("dev" or "npm")
|
|
2354
|
+
* - `target`: The publish target for the current output. For single-registry builds
|
|
2355
|
+
* or dev mode, this is `undefined`. For multi-registry builds (`publishConfig.targets`),
|
|
2356
|
+
* the primary target receives the first resolved target and additional targets receive
|
|
2357
|
+
* their respective target via `PublishTargetPlugin`
|
|
2224
2358
|
* - `pkg`: The package.json object to transform
|
|
2225
2359
|
* @returns The modified package.json object
|
|
2226
2360
|
*
|
|
@@ -2228,8 +2362,8 @@ export declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibCon
|
|
|
2228
2362
|
* ```typescript
|
|
2229
2363
|
* import type { TransformPackageJsonFn } from '@savvy-web/rslib-builder';
|
|
2230
2364
|
*
|
|
2231
|
-
* const transform: TransformPackageJsonFn = ({ target, pkg }) => {
|
|
2232
|
-
* if (
|
|
2365
|
+
* const transform: TransformPackageJsonFn = ({ mode, target, pkg }) => {
|
|
2366
|
+
* if (mode === 'npm') {
|
|
2233
2367
|
* delete pkg.devDependencies;
|
|
2234
2368
|
* delete pkg.scripts;
|
|
2235
2369
|
* }
|
|
@@ -2239,7 +2373,8 @@ export declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibCon
|
|
|
2239
2373
|
* @public
|
|
2240
2374
|
*/
|
|
2241
2375
|
export declare type TransformPackageJsonFn = (context: {
|
|
2242
|
-
|
|
2376
|
+
mode: BuildMode;
|
|
2377
|
+
target: PublishTarget | undefined;
|
|
2243
2378
|
pkg: PackageJson;
|
|
2244
2379
|
}) => PackageJson;
|
|
2245
2380
|
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
import { constants, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { constants, cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, isAbsolute, join, normalize, relative, resolve as external_node_path_resolve } from "node:path";
|
|
4
4
|
import { defineConfig } from "@rslib/core";
|
|
5
|
-
import { access, copyFile, mkdir, readFile, readdir, rm, stat, unlink as promises_unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import { access as promises_access, copyFile, mkdir, readFile, readdir, rm, stat, unlink as promises_unlink, writeFile } from "node:fs/promises";
|
|
6
6
|
import { logger as core_logger } from "@rsbuild/core";
|
|
7
7
|
import picocolors from "picocolors";
|
|
8
8
|
import { getCatalogs, getWorkspaceManagerAndRoot, getWorkspaceManagerRoot } from "workspace-tools";
|
|
@@ -548,7 +548,7 @@ class TSConfigFile {
|
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
class LibraryTSConfigFile extends TSConfigFile {
|
|
551
|
-
writeBundleTempConfig(
|
|
551
|
+
writeBundleTempConfig(_mode) {
|
|
552
552
|
const cwd = process.cwd();
|
|
553
553
|
const baseConfig = this.config;
|
|
554
554
|
const absoluteConfig = {
|
|
@@ -1140,13 +1140,13 @@ async function bundleDtsFiles(options) {
|
|
|
1140
1140
|
const dtsFileName = normalizedSourcePath.replace(/\.(tsx?|jsx?)$/, ".d.ts");
|
|
1141
1141
|
let tempDtsPath = join(tempDtsDir, dtsFileName);
|
|
1142
1142
|
try {
|
|
1143
|
-
await
|
|
1143
|
+
await promises_access(tempDtsPath, constants.F_OK);
|
|
1144
1144
|
} catch {
|
|
1145
1145
|
const withoutSrc = dtsFileName.replace(/^src\//, "");
|
|
1146
1146
|
if (withoutSrc !== dtsFileName) {
|
|
1147
1147
|
const alternativePath = join(tempDtsDir, withoutSrc);
|
|
1148
1148
|
try {
|
|
1149
|
-
await
|
|
1149
|
+
await promises_access(alternativePath, constants.F_OK);
|
|
1150
1150
|
tempDtsPath = alternativePath;
|
|
1151
1151
|
} catch {}
|
|
1152
1152
|
}
|
|
@@ -1416,11 +1416,11 @@ function runTsgo(options) {
|
|
|
1416
1416
|
const cwd = api.context.rootPath;
|
|
1417
1417
|
try {
|
|
1418
1418
|
let configTsconfigPath = options.tsconfigPath;
|
|
1419
|
-
if (options.
|
|
1419
|
+
if (options.buildMode) {
|
|
1420
1420
|
const originalCwd = process.cwd();
|
|
1421
1421
|
try {
|
|
1422
1422
|
process.chdir(cwd);
|
|
1423
|
-
configTsconfigPath = TSConfigs.node.ecma.lib.writeBundleTempConfig(options.
|
|
1423
|
+
configTsconfigPath = TSConfigs.node.ecma.lib.writeBundleTempConfig(options.buildMode);
|
|
1424
1424
|
} finally{
|
|
1425
1425
|
process.chdir(originalCwd);
|
|
1426
1426
|
}
|
|
@@ -1626,7 +1626,7 @@ function runTsgo(options) {
|
|
|
1626
1626
|
hasTsdocMetadata: !!tsdocMetadataPath,
|
|
1627
1627
|
hasTsconfig: !!state.parsedConfig && !!state.tsconfigPath,
|
|
1628
1628
|
cwd,
|
|
1629
|
-
distPath: `dist/${options.
|
|
1629
|
+
distPath: `dist/${options.buildMode ?? envId}`
|
|
1630
1630
|
});
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
@@ -1838,6 +1838,7 @@ const FilesArrayPlugin = (options)=>({
|
|
|
1838
1838
|
if (options?.transformFiles) await options.transformFiles({
|
|
1839
1839
|
compilation: context.compilation,
|
|
1840
1840
|
filesArray,
|
|
1841
|
+
mode: options.mode,
|
|
1841
1842
|
target: options.target
|
|
1842
1843
|
});
|
|
1843
1844
|
});
|
|
@@ -2326,7 +2327,7 @@ const PackageJsonTransformPlugin = (options = {})=>({
|
|
|
2326
2327
|
dualFormat: options.dualFormat
|
|
2327
2328
|
}
|
|
2328
2329
|
};
|
|
2329
|
-
const processedPackageJson = await buildPackageJson(packageJson.data, isProduction, options.processTSExports, entrypoints, exportToOutputMap, options.bundle,
|
|
2330
|
+
const processedPackageJson = await buildPackageJson(packageJson.data, isProduction, options.processTSExports, entrypoints, exportToOutputMap, options.bundle, void 0, formatConditions);
|
|
2330
2331
|
packageJson.data = processedPackageJson;
|
|
2331
2332
|
if (options.forcePrivate) packageJson.data.private = true;
|
|
2332
2333
|
if (options.format) packageJson.data.type = "esm" === options.format ? "module" : "commonjs";
|
|
@@ -2336,6 +2337,8 @@ const PackageJsonTransformPlugin = (options = {})=>({
|
|
|
2336
2337
|
delete exports["./api-extractor"];
|
|
2337
2338
|
for (const value of Object.values(exports))if (value && "object" == typeof value && "types" in value) value.types = "./index.d.ts";
|
|
2338
2339
|
}
|
|
2340
|
+
api.expose("base-package-json", JSON.parse(JSON.stringify(packageJson.data)));
|
|
2341
|
+
if (options.transform) packageJson.data = options.transform(packageJson.data);
|
|
2339
2342
|
packageJson.update();
|
|
2340
2343
|
});
|
|
2341
2344
|
api.processAssets({
|
|
@@ -2351,6 +2354,40 @@ const PackageJsonTransformPlugin = (options = {})=>({
|
|
|
2351
2354
|
});
|
|
2352
2355
|
}
|
|
2353
2356
|
});
|
|
2357
|
+
const PublishTargetPlugin = (options)=>({
|
|
2358
|
+
name: "publish-target-plugin",
|
|
2359
|
+
setup (api) {
|
|
2360
|
+
api.onCloseBuild(async ()=>{
|
|
2361
|
+
const { additionalTargets, primaryOutdir, mode, transform, name } = options;
|
|
2362
|
+
if (0 === additionalTargets.length) return;
|
|
2363
|
+
const basePackageJson = api.useExposed("base-package-json");
|
|
2364
|
+
if (!basePackageJson) return;
|
|
2365
|
+
const primaryPkgPath = join(primaryOutdir, "package.json");
|
|
2366
|
+
const primaryPkg = JSON.parse(readFileSync(primaryPkgPath, "utf-8"));
|
|
2367
|
+
for (const target of additionalTargets){
|
|
2368
|
+
if (target.directory !== primaryOutdir) {
|
|
2369
|
+
mkdirSync(target.directory, {
|
|
2370
|
+
recursive: true
|
|
2371
|
+
});
|
|
2372
|
+
cpSync(primaryOutdir, target.directory, {
|
|
2373
|
+
recursive: true
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
let targetPkg = JSON.parse(JSON.stringify(basePackageJson));
|
|
2377
|
+
if (transform) targetPkg = transform({
|
|
2378
|
+
mode: mode,
|
|
2379
|
+
target,
|
|
2380
|
+
pkg: targetPkg
|
|
2381
|
+
});
|
|
2382
|
+
if (name) targetPkg.name = name;
|
|
2383
|
+
if (primaryPkg.files) targetPkg.files = [
|
|
2384
|
+
...primaryPkg.files
|
|
2385
|
+
];
|
|
2386
|
+
writeFileSync(join(target.directory, "package.json"), `${JSON.stringify(targetPkg, null, 2)}\n`);
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2354
2391
|
function formatLintResults(results, cwd) {
|
|
2355
2392
|
if (0 === results.messages.length) return "";
|
|
2356
2393
|
const lines = [];
|
|
@@ -2728,7 +2765,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2728
2765
|
module.exports = _def;
|
|
2729
2766
|
}`;
|
|
2730
2767
|
/* v8 ignore next -- @preserve */ class NodeLibraryBuilder {
|
|
2731
|
-
static
|
|
2768
|
+
static VALID_MODES = [
|
|
2732
2769
|
"dev",
|
|
2733
2770
|
"npm"
|
|
2734
2771
|
];
|
|
@@ -2793,15 +2830,18 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2793
2830
|
static create(options = {}) {
|
|
2794
2831
|
const mergedOptions = NodeLibraryBuilder.mergeOptions(options);
|
|
2795
2832
|
return async ({ envMode })=>{
|
|
2796
|
-
const
|
|
2797
|
-
if (!NodeLibraryBuilder.
|
|
2798
|
-
return NodeLibraryBuilder.
|
|
2833
|
+
const mode = envMode || "dev";
|
|
2834
|
+
if (!NodeLibraryBuilder.VALID_MODES.includes(mode)) throw new Error(`Invalid env-mode: "${mode}". Must be one of: ${NodeLibraryBuilder.VALID_MODES.join(", ")}\nExample: rslib build --env-mode npm`);
|
|
2835
|
+
return NodeLibraryBuilder.createSingleMode(mode, mergedOptions);
|
|
2799
2836
|
};
|
|
2800
2837
|
}
|
|
2801
|
-
static async
|
|
2838
|
+
static async createSingleMode(mode, opts) {
|
|
2802
2839
|
const options = NodeLibraryBuilder.mergeOptions(opts);
|
|
2803
2840
|
const bundle = options.bundle ?? true;
|
|
2804
2841
|
const VERSION = await packageJsonVersion();
|
|
2842
|
+
const cwd = process.cwd();
|
|
2843
|
+
const packageJsonPath = join(cwd, "package.json");
|
|
2844
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
2805
2845
|
const plugins = [];
|
|
2806
2846
|
const apiModelConfig = "object" == typeof options.apiModel ? options.apiModel : {};
|
|
2807
2847
|
const tsdocConfig = apiModelConfig.tsdoc;
|
|
@@ -2830,11 +2870,6 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2830
2870
|
bundleless: true
|
|
2831
2871
|
}
|
|
2832
2872
|
}));
|
|
2833
|
-
const userTransform = options.transform;
|
|
2834
|
-
const transformFn = userTransform ? (pkg)=>userTransform({
|
|
2835
|
-
target,
|
|
2836
|
-
pkg
|
|
2837
|
-
}) : void 0;
|
|
2838
2873
|
const formatOption = options.format ?? "esm";
|
|
2839
2874
|
const formats = Array.isArray(formatOption) ? formatOption : [
|
|
2840
2875
|
formatOption
|
|
@@ -2844,9 +2879,17 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2844
2879
|
const entryFormats = options.entryFormats;
|
|
2845
2880
|
const hasFormatOverrides = void 0 !== entryFormats && Object.keys(entryFormats).length > 0;
|
|
2846
2881
|
const collapseIndex = bundle || !(options.exportsAsIndexes ?? false);
|
|
2847
|
-
const baseOutputDir = `dist/${
|
|
2848
|
-
const
|
|
2849
|
-
const
|
|
2882
|
+
const baseOutputDir = `dist/${mode}`;
|
|
2883
|
+
const publishTargets = "npm" === mode ? resolvePublishTargets(packageJson, cwd, external_node_path_resolve(cwd, baseOutputDir)) : [];
|
|
2884
|
+
const primaryTarget = publishTargets[0];
|
|
2885
|
+
const userTransform = options.transform;
|
|
2886
|
+
const transformFn = userTransform ? (pkg)=>userTransform({
|
|
2887
|
+
mode,
|
|
2888
|
+
target: primaryTarget,
|
|
2889
|
+
pkg
|
|
2890
|
+
}) : void 0;
|
|
2891
|
+
const apiModelForMode = "npm" === mode ? options.apiModel : void 0;
|
|
2892
|
+
const sourceMap = "dev" === mode;
|
|
2850
2893
|
const externalsConfig = options.externals && options.externals.length > 0 ? {
|
|
2851
2894
|
externals: options.externals
|
|
2852
2895
|
} : {};
|
|
@@ -2859,9 +2902,6 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2859
2902
|
};
|
|
2860
2903
|
let entry = options.entry;
|
|
2861
2904
|
if (!bundle && !entry) {
|
|
2862
|
-
const cwd = process.cwd();
|
|
2863
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
2864
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
2865
2905
|
const { entries } = new EntryExtractor().extract(packageJson);
|
|
2866
2906
|
const graph = new ImportGraph({
|
|
2867
2907
|
rootDir: cwd
|
|
@@ -2875,9 +2915,9 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2875
2915
|
entry = tracedEntries;
|
|
2876
2916
|
}
|
|
2877
2917
|
plugins.push(PackageJsonTransformPlugin({
|
|
2878
|
-
forcePrivate: "dev" ===
|
|
2918
|
+
forcePrivate: "dev" === mode,
|
|
2879
2919
|
bundle: collapseIndex,
|
|
2880
|
-
|
|
2920
|
+
mode,
|
|
2881
2921
|
format: primaryFormat,
|
|
2882
2922
|
...transformFn && {
|
|
2883
2923
|
transform: transformFn
|
|
@@ -2890,7 +2930,10 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2890
2930
|
}
|
|
2891
2931
|
}));
|
|
2892
2932
|
plugins.push(FilesArrayPlugin({
|
|
2893
|
-
|
|
2933
|
+
mode,
|
|
2934
|
+
...primaryTarget && {
|
|
2935
|
+
target: primaryTarget
|
|
2936
|
+
},
|
|
2894
2937
|
...options.transformFiles && {
|
|
2895
2938
|
transformFiles: options.transformFiles
|
|
2896
2939
|
},
|
|
@@ -2908,17 +2951,17 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2908
2951
|
...options.dtsBundledPackages && {
|
|
2909
2952
|
bundledPackages: options.dtsBundledPackages
|
|
2910
2953
|
},
|
|
2911
|
-
|
|
2954
|
+
buildMode: mode,
|
|
2912
2955
|
format: primaryFormat,
|
|
2913
|
-
...void 0 !==
|
|
2914
|
-
apiModel:
|
|
2956
|
+
...void 0 !== apiModelForMode && {
|
|
2957
|
+
apiModel: apiModelForMode
|
|
2915
2958
|
},
|
|
2916
2959
|
...isDualFormat && {
|
|
2917
2960
|
dtsPathPrefix: primaryFormat
|
|
2918
2961
|
}
|
|
2919
2962
|
}));
|
|
2920
2963
|
const lib = {
|
|
2921
|
-
id: isDualFormat ? `${
|
|
2964
|
+
id: isDualFormat ? `${mode}-${primaryFormat}` : mode,
|
|
2922
2965
|
outBase: bundle ? baseOutputDir : "src",
|
|
2923
2966
|
output: {
|
|
2924
2967
|
target: "node",
|
|
@@ -2958,7 +3001,8 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2958
3001
|
}
|
|
2959
3002
|
}
|
|
2960
3003
|
};
|
|
2961
|
-
const
|
|
3004
|
+
const pkgExports = packageJson.exports;
|
|
3005
|
+
const hasRegularEntries = void 0 !== options.entry || null != pkgExports && "object" == typeof pkgExports && Object.keys(pkgExports).length > 0;
|
|
2962
3006
|
const virtualEntries = options.virtualEntries ?? {};
|
|
2963
3007
|
const hasVirtualEntries = Object.keys(virtualEntries).length > 0;
|
|
2964
3008
|
if (!hasRegularEntries && !hasVirtualEntries) throw new Error("No entry points configured. Provide package.json exports, explicit entry option, or virtualEntries.");
|
|
@@ -2981,7 +3025,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2981
3025
|
name: "strip-bin-entries",
|
|
2982
3026
|
setup (api) {
|
|
2983
3027
|
api.modifyRsbuildConfig((config)=>{
|
|
2984
|
-
const envKey = `${
|
|
3028
|
+
const envKey = `${mode}-${secondaryFormat}`;
|
|
2985
3029
|
const envConfig = config.environments?.[envKey];
|
|
2986
3030
|
if (envConfig?.source?.entry) {
|
|
2987
3031
|
const filtered = {};
|
|
@@ -3001,14 +3045,14 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3001
3045
|
...options.dtsBundledPackages && {
|
|
3002
3046
|
bundledPackages: options.dtsBundledPackages
|
|
3003
3047
|
},
|
|
3004
|
-
|
|
3048
|
+
buildMode: mode,
|
|
3005
3049
|
format: secondaryFormat,
|
|
3006
3050
|
dtsPathPrefix: secondaryFormat
|
|
3007
3051
|
})
|
|
3008
3052
|
];
|
|
3009
3053
|
const secondaryEntry = entry ? Object.fromEntries(Object.entries(entry).filter(([name])=>!name.startsWith("bin/"))) : void 0;
|
|
3010
3054
|
const secondaryLib = {
|
|
3011
|
-
id: `${
|
|
3055
|
+
id: `${mode}-${secondaryFormat}`,
|
|
3012
3056
|
outBase: bundle ? baseOutputDir : "src",
|
|
3013
3057
|
output: {
|
|
3014
3058
|
target: "node",
|
|
@@ -3045,9 +3089,6 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3045
3089
|
libConfigs.push(secondaryLib);
|
|
3046
3090
|
}
|
|
3047
3091
|
if (hasFormatOverrides && !isDualFormat) {
|
|
3048
|
-
const cwd = process.cwd();
|
|
3049
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
3050
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
3051
3092
|
const { entries: extractedEntries, exportPaths } = new EntryExtractor().extract(packageJson);
|
|
3052
3093
|
const overridesByFormat = new Map();
|
|
3053
3094
|
for (const [entryName, sourcePath] of Object.entries(extractedEntries)){
|
|
@@ -3065,7 +3106,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3065
3106
|
for (const [overrideFormat, overrideEntries] of overridesByFormat){
|
|
3066
3107
|
const overridePlugins = [
|
|
3067
3108
|
FilesArrayPlugin({
|
|
3068
|
-
|
|
3109
|
+
mode
|
|
3069
3110
|
}),
|
|
3070
3111
|
DtsPlugin({
|
|
3071
3112
|
...options.tsconfigPath && {
|
|
@@ -3076,12 +3117,12 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3076
3117
|
...options.dtsBundledPackages && {
|
|
3077
3118
|
bundledPackages: options.dtsBundledPackages
|
|
3078
3119
|
},
|
|
3079
|
-
|
|
3120
|
+
buildMode: mode,
|
|
3080
3121
|
format: overrideFormat
|
|
3081
3122
|
})
|
|
3082
3123
|
];
|
|
3083
3124
|
const overrideLib = {
|
|
3084
|
-
id: `${
|
|
3125
|
+
id: `${mode}-${overrideFormat}`,
|
|
3085
3126
|
outBase: bundle ? baseOutputDir : "src",
|
|
3086
3127
|
output: {
|
|
3087
3128
|
target: "node",
|
|
@@ -3132,7 +3173,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3132
3173
|
const virtualEntryNames = new Set(entries.keys());
|
|
3133
3174
|
const entryMap = Object.fromEntries(entries);
|
|
3134
3175
|
const virtualLib = {
|
|
3135
|
-
id: `${
|
|
3176
|
+
id: `${mode}-virtual-${format}`,
|
|
3136
3177
|
format,
|
|
3137
3178
|
bundle: true,
|
|
3138
3179
|
output: {
|
|
@@ -3152,7 +3193,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3152
3193
|
virtualEntryNames
|
|
3153
3194
|
}),
|
|
3154
3195
|
FilesArrayPlugin({
|
|
3155
|
-
|
|
3196
|
+
mode
|
|
3156
3197
|
})
|
|
3157
3198
|
]
|
|
3158
3199
|
};
|
|
@@ -3170,9 +3211,16 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3170
3211
|
api.expose("virtual-entry-names", allVirtualEntryNames);
|
|
3171
3212
|
}
|
|
3172
3213
|
});
|
|
3173
|
-
lib.plugins = plugins;
|
|
3174
3214
|
}
|
|
3175
3215
|
}
|
|
3216
|
+
if (publishTargets.length > 1) plugins.push(PublishTargetPlugin({
|
|
3217
|
+
additionalTargets: publishTargets.slice(1),
|
|
3218
|
+
primaryOutdir: external_node_path_resolve(cwd, baseOutputDir),
|
|
3219
|
+
mode,
|
|
3220
|
+
...userTransform && {
|
|
3221
|
+
transform: userTransform
|
|
3222
|
+
}
|
|
3223
|
+
}));
|
|
3176
3224
|
return defineConfig({
|
|
3177
3225
|
lib: libConfigs,
|
|
3178
3226
|
...options.tsconfigPath && {
|
|
@@ -3182,20 +3230,70 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3182
3230
|
},
|
|
3183
3231
|
performance: {
|
|
3184
3232
|
buildCache: {
|
|
3185
|
-
cacheDirectory: `.rslib/cache/${
|
|
3233
|
+
cacheDirectory: `.rslib/cache/${mode}`
|
|
3186
3234
|
}
|
|
3187
3235
|
}
|
|
3188
3236
|
});
|
|
3189
3237
|
}
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3238
|
+
}
|
|
3239
|
+
const KNOWN_TARGET_SHORTHANDS = {
|
|
3240
|
+
npm: {
|
|
3241
|
+
protocol: "npm",
|
|
3242
|
+
registry: "https://registry.npmjs.org/",
|
|
3243
|
+
provenance: true
|
|
3244
|
+
},
|
|
3245
|
+
github: {
|
|
3246
|
+
protocol: "npm",
|
|
3247
|
+
registry: "https://npm.pkg.github.com/",
|
|
3248
|
+
provenance: true
|
|
3249
|
+
},
|
|
3250
|
+
jsr: {
|
|
3251
|
+
protocol: "jsr",
|
|
3252
|
+
registry: null,
|
|
3253
|
+
provenance: false
|
|
3199
3254
|
}
|
|
3255
|
+
};
|
|
3256
|
+
function resolvePublishTargets(packageJson, cwd, outdir) {
|
|
3257
|
+
const publishConfig = packageJson.publishConfig;
|
|
3258
|
+
const raw = publishConfig?.targets;
|
|
3259
|
+
if (!Array.isArray(raw) || 0 === raw.length) return [];
|
|
3260
|
+
const defaultAccess = publishConfig?.access ?? "restricted";
|
|
3261
|
+
const defaultDirectory = publishConfig?.directory ? external_node_path_resolve(cwd, String(publishConfig.directory)) : outdir;
|
|
3262
|
+
return raw.map((entry)=>{
|
|
3263
|
+
if ("string" == typeof entry) {
|
|
3264
|
+
const shorthand = KNOWN_TARGET_SHORTHANDS[entry];
|
|
3265
|
+
if (shorthand) return {
|
|
3266
|
+
protocol: shorthand.protocol,
|
|
3267
|
+
registry: shorthand.registry,
|
|
3268
|
+
directory: defaultDirectory,
|
|
3269
|
+
access: defaultAccess,
|
|
3270
|
+
provenance: shorthand.provenance,
|
|
3271
|
+
tag: "latest"
|
|
3272
|
+
};
|
|
3273
|
+
if (entry.startsWith("https://") || entry.startsWith("http://")) return {
|
|
3274
|
+
protocol: "npm",
|
|
3275
|
+
registry: entry,
|
|
3276
|
+
directory: defaultDirectory,
|
|
3277
|
+
access: defaultAccess,
|
|
3278
|
+
provenance: false,
|
|
3279
|
+
tag: "latest"
|
|
3280
|
+
};
|
|
3281
|
+
throw new Error(`Unknown publish target shorthand: ${entry}`);
|
|
3282
|
+
}
|
|
3283
|
+
const protocol = "jsr" === entry.protocol ? "jsr" : "npm";
|
|
3284
|
+
const registry = "jsr" === protocol ? null : String(entry.registry ?? "https://registry.npmjs.org/");
|
|
3285
|
+
const directory = entry.directory ? external_node_path_resolve(cwd, String(entry.directory)) : defaultDirectory;
|
|
3286
|
+
const access = "public" === entry.access || "restricted" === entry.access ? entry.access : defaultAccess;
|
|
3287
|
+
const provenance = "boolean" == typeof entry.provenance ? entry.provenance : false;
|
|
3288
|
+
const tag = "string" == typeof entry.tag ? entry.tag : "latest";
|
|
3289
|
+
return {
|
|
3290
|
+
protocol,
|
|
3291
|
+
registry,
|
|
3292
|
+
directory,
|
|
3293
|
+
access,
|
|
3294
|
+
provenance,
|
|
3295
|
+
tag
|
|
3296
|
+
};
|
|
3297
|
+
});
|
|
3200
3298
|
}
|
|
3201
|
-
export { AutoEntryPlugin, DtsPlugin, EntryExtractor, FilesArrayPlugin, ImportGraph, NodeLibraryBuilder, PackageJsonTransformPlugin, TsDocConfigBuilder, TsDocLintPlugin, TsconfigResolver, TsconfigResolverError, VirtualEntryPlugin };
|
|
3299
|
+
export { AutoEntryPlugin, DtsPlugin, EntryExtractor, FilesArrayPlugin, ImportGraph, NodeLibraryBuilder, PackageJsonTransformPlugin, PublishTargetPlugin, TsDocConfigBuilder, TsDocLintPlugin, TsconfigResolver, TsconfigResolverError, VirtualEntryPlugin, resolvePublishTargets };
|
package/package.json
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
2
|
+
"name": "@savvy-web/rslib-builder",
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "RSlib-based build system for Node.js libraries with automatic package.json transformation, TypeScript declaration bundling, and multi-target support",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"rslib",
|
|
8
|
+
"rsbuild",
|
|
9
|
+
"typescript",
|
|
10
|
+
"declarations",
|
|
11
|
+
"dts",
|
|
12
|
+
"bundler",
|
|
13
|
+
"build",
|
|
14
|
+
"esm",
|
|
15
|
+
"node",
|
|
16
|
+
"library",
|
|
17
|
+
"api-extractor",
|
|
18
|
+
"tsgo",
|
|
19
|
+
"tsdoc",
|
|
20
|
+
"monorepo"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://github.com/savvy-web/rslib-builder",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/savvy-web/rslib-builder/issues"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/savvy-web/rslib-builder.git"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"author": {
|
|
32
|
+
"name": "C. Spencer Beggs",
|
|
33
|
+
"email": "spencer@savvyweb.systems",
|
|
34
|
+
"url": "https://savvyweb.systems"
|
|
35
|
+
},
|
|
36
|
+
"type": "module",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./index.d.ts",
|
|
40
|
+
"import": "./index.js"
|
|
41
|
+
},
|
|
42
|
+
"./tsconfig/root.json": "./tsconfig/root.json",
|
|
43
|
+
"./tsconfig/ecma/lib.json": "./tsconfig/ecma/lib.json"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@microsoft/tsdoc": "^0.16.0",
|
|
47
|
+
"@microsoft/tsdoc-config": "^0.18.0",
|
|
48
|
+
"@pnpm/catalogs.config": "^1000.0.5",
|
|
49
|
+
"@pnpm/catalogs.protocol-parser": "^1001.0.0",
|
|
50
|
+
"@pnpm/exportable-manifest": "^1000.4.0",
|
|
51
|
+
"@pnpm/lockfile.fs": "^1001.1.29",
|
|
52
|
+
"@pnpm/workspace.read-manifest": "^1000.2.10",
|
|
53
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
54
|
+
"deep-equal": "^2.2.3",
|
|
55
|
+
"eslint": "^10.0.0",
|
|
56
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
57
|
+
"glob": "^13.0.1",
|
|
58
|
+
"picocolors": "^1.1.1",
|
|
59
|
+
"sort-package-json": "^3.6.1",
|
|
60
|
+
"tmp": "^0.2.4",
|
|
61
|
+
"workspace-tools": "^0.41.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@microsoft/api-extractor": ">=7.56.0 <7.57.0",
|
|
65
|
+
"@rslib/core": "^0.19.6",
|
|
66
|
+
"@types/node": "^25.2.0",
|
|
67
|
+
"@typescript/native-preview": "^7.0.0-dev.20260124.1",
|
|
68
|
+
"typescript": "^5.9.3"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@microsoft/api-extractor": {
|
|
72
|
+
"optional": false
|
|
73
|
+
},
|
|
74
|
+
"@rslib/core": {
|
|
75
|
+
"optional": false
|
|
76
|
+
},
|
|
77
|
+
"@types/node": {
|
|
78
|
+
"optional": false
|
|
79
|
+
},
|
|
80
|
+
"@typescript/native-preview": {
|
|
81
|
+
"optional": false
|
|
82
|
+
},
|
|
83
|
+
"typescript": {
|
|
84
|
+
"optional": false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=24.0.0"
|
|
89
|
+
},
|
|
90
|
+
"files": [
|
|
91
|
+
"!rslib-builder.api.json",
|
|
92
|
+
"!tsconfig.json",
|
|
93
|
+
"!tsdoc.json",
|
|
94
|
+
"LICENSE",
|
|
95
|
+
"README.md",
|
|
96
|
+
"index.d.ts",
|
|
97
|
+
"index.js",
|
|
98
|
+
"package.json",
|
|
99
|
+
"tsconfig/ecma/lib.json",
|
|
100
|
+
"tsconfig/root.json",
|
|
101
|
+
"tsdoc-metadata.json"
|
|
102
|
+
]
|
|
103
|
+
}
|