@savvy-web/rslib-builder 0.16.0 → 0.17.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 +15 -26
- package/index.js +17 -21
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -646,8 +646,6 @@ export declare interface FilesArrayPluginOptions<TMode extends string = string>
|
|
|
646
646
|
filesArray: Set<string>;
|
|
647
647
|
/** Current build mode */
|
|
648
648
|
mode: TMode;
|
|
649
|
-
/** The publish target for this build output, if configured */
|
|
650
|
-
target: PublishTarget | undefined;
|
|
651
649
|
}) => void | Promise<void>;
|
|
652
650
|
/**
|
|
653
651
|
* Build mode identifier (e.g., "dev", "npm").
|
|
@@ -656,13 +654,6 @@ export declare interface FilesArrayPluginOptions<TMode extends string = string>
|
|
|
656
654
|
* Passed to the `transformFiles` callback to allow mode-specific transformations.
|
|
657
655
|
*/
|
|
658
656
|
mode: TMode;
|
|
659
|
-
/**
|
|
660
|
-
* The publish target for this build output, if configured.
|
|
661
|
-
*
|
|
662
|
-
* @remarks
|
|
663
|
-
* Passed to the `transformFiles` callback to allow target-specific transformations.
|
|
664
|
-
*/
|
|
665
|
-
target?: PublishTarget;
|
|
666
657
|
/**
|
|
667
658
|
* Format directories to include in the files array.
|
|
668
659
|
* Used in dual format builds so npm's `files` field includes
|
|
@@ -1477,8 +1468,6 @@ export declare interface NodeLibraryBuilderOptions {
|
|
|
1477
1468
|
filesArray: Set<string>;
|
|
1478
1469
|
/** Current build mode */
|
|
1479
1470
|
mode: BuildMode;
|
|
1480
|
-
/** The publish target for this build output, if configured */
|
|
1481
|
-
target: PublishTarget | undefined;
|
|
1482
1471
|
}) => void | Promise<void>;
|
|
1483
1472
|
/**
|
|
1484
1473
|
* Optional transform function to modify package.json before it's saved.
|
|
@@ -2215,15 +2204,15 @@ export declare interface PublishTarget {
|
|
|
2215
2204
|
* Plugin to produce per-target output directories for multi-registry publishing.
|
|
2216
2205
|
*
|
|
2217
2206
|
* @remarks
|
|
2218
|
-
* Runs in `onCloseBuild` after the
|
|
2219
|
-
* publish target
|
|
2207
|
+
* Runs in `onCloseBuild` after the main RSlib build completes. For each
|
|
2208
|
+
* publish target:
|
|
2220
2209
|
*
|
|
2221
2210
|
* 1. Creates the target directory
|
|
2222
|
-
* 2. Copies all build output from the
|
|
2211
|
+
* 2. Copies all build output from the staging directory
|
|
2223
2212
|
* 3. Reads the exposed `base-package-json` (after standard transforms, before user transform)
|
|
2224
2213
|
* 4. Applies the user transform with the target-specific context
|
|
2225
2214
|
* 5. Applies optional name override
|
|
2226
|
-
* 6. Copies the `files` array from the
|
|
2215
|
+
* 6. Copies the `files` array from the staging directory's package.json
|
|
2227
2216
|
* 7. Writes the final package.json to the target directory
|
|
2228
2217
|
*
|
|
2229
2218
|
* @param options - Plugin configuration options
|
|
@@ -2239,37 +2228,37 @@ export declare const PublishTargetPlugin: (options: PublishTargetPluginOptions)
|
|
|
2239
2228
|
*/
|
|
2240
2229
|
export declare interface PublishTargetPluginOptions {
|
|
2241
2230
|
/**
|
|
2242
|
-
*
|
|
2231
|
+
* Publish targets to write output for.
|
|
2243
2232
|
*
|
|
2244
2233
|
* @remarks
|
|
2245
|
-
* Each target gets a copy of the
|
|
2234
|
+
* Each target gets a copy of the build staging output with per-target
|
|
2246
2235
|
* package.json transformations applied.
|
|
2247
2236
|
*/
|
|
2248
|
-
|
|
2237
|
+
targets: PublishTarget[];
|
|
2249
2238
|
/**
|
|
2250
|
-
* Absolute path to the
|
|
2239
|
+
* Absolute path to the build staging directory (dist/<mode>).
|
|
2251
2240
|
*
|
|
2252
2241
|
* @remarks
|
|
2253
|
-
*
|
|
2254
|
-
*
|
|
2242
|
+
* Build artifacts are copied from this directory to each target's
|
|
2243
|
+
* directory (when they differ).
|
|
2255
2244
|
*/
|
|
2256
|
-
|
|
2245
|
+
stagingDir: string;
|
|
2257
2246
|
/**
|
|
2258
|
-
* Current build mode
|
|
2247
|
+
* Current build mode.
|
|
2259
2248
|
*/
|
|
2260
|
-
mode:
|
|
2249
|
+
mode: BuildMode;
|
|
2261
2250
|
/**
|
|
2262
2251
|
* Optional user transform function applied to each target's package.json.
|
|
2263
2252
|
*
|
|
2264
2253
|
* @remarks
|
|
2265
|
-
* Called after copying the base package.json state for each
|
|
2254
|
+
* Called after copying the base package.json state for each target.
|
|
2266
2255
|
*/
|
|
2267
2256
|
transform?: TransformPackageJsonFn;
|
|
2268
2257
|
/**
|
|
2269
2258
|
* Optional package name override.
|
|
2270
2259
|
*
|
|
2271
2260
|
* @remarks
|
|
2272
|
-
* When provided, overrides the `name` field in each
|
|
2261
|
+
* When provided, overrides the `name` field in each target's package.json.
|
|
2273
2262
|
*/
|
|
2274
2263
|
name?: string;
|
|
2275
2264
|
}
|
package/index.js
CHANGED
|
@@ -1838,8 +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
|
|
1842
|
-
target: options.target
|
|
1841
|
+
mode: options.mode
|
|
1843
1842
|
});
|
|
1844
1843
|
});
|
|
1845
1844
|
api.processAssets({
|
|
@@ -2358,30 +2357,30 @@ const PublishTargetPlugin = (options)=>({
|
|
|
2358
2357
|
name: "publish-target-plugin",
|
|
2359
2358
|
setup (api) {
|
|
2360
2359
|
api.onCloseBuild(async ()=>{
|
|
2361
|
-
const {
|
|
2362
|
-
if (0 ===
|
|
2360
|
+
const { targets, stagingDir, mode, transform, name } = options;
|
|
2361
|
+
if (0 === targets.length) return;
|
|
2363
2362
|
const basePackageJson = api.useExposed("base-package-json");
|
|
2364
2363
|
if (!basePackageJson) return;
|
|
2365
|
-
const
|
|
2366
|
-
const
|
|
2367
|
-
for (const target of
|
|
2368
|
-
if (target.directory !==
|
|
2364
|
+
const stagingPkgPath = join(stagingDir, "package.json");
|
|
2365
|
+
const stagingPkg = JSON.parse(readFileSync(stagingPkgPath, "utf-8"));
|
|
2366
|
+
for (const target of targets){
|
|
2367
|
+
if (target.directory !== stagingDir) {
|
|
2369
2368
|
mkdirSync(target.directory, {
|
|
2370
2369
|
recursive: true
|
|
2371
2370
|
});
|
|
2372
|
-
cpSync(
|
|
2371
|
+
cpSync(stagingDir, target.directory, {
|
|
2373
2372
|
recursive: true
|
|
2374
2373
|
});
|
|
2375
2374
|
}
|
|
2376
2375
|
let targetPkg = JSON.parse(JSON.stringify(basePackageJson));
|
|
2377
2376
|
if (transform) targetPkg = transform({
|
|
2378
|
-
mode
|
|
2377
|
+
mode,
|
|
2379
2378
|
target,
|
|
2380
2379
|
pkg: targetPkg
|
|
2381
2380
|
});
|
|
2382
2381
|
if (name) targetPkg.name = name;
|
|
2383
|
-
if (
|
|
2384
|
-
...
|
|
2382
|
+
if (stagingPkg.files) targetPkg.files = [
|
|
2383
|
+
...stagingPkg.files
|
|
2385
2384
|
];
|
|
2386
2385
|
writeFileSync(join(target.directory, "package.json"), `${JSON.stringify(targetPkg, null, 2)}\n`);
|
|
2387
2386
|
}
|
|
@@ -2881,11 +2880,11 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2881
2880
|
const collapseIndex = bundle || !(options.exportsAsIndexes ?? false);
|
|
2882
2881
|
const baseOutputDir = `dist/${mode}`;
|
|
2883
2882
|
const publishTargets = "npm" === mode ? resolvePublishTargets(packageJson, cwd, external_node_path_resolve(cwd, baseOutputDir)) : [];
|
|
2884
|
-
const
|
|
2883
|
+
const hasTargets = publishTargets.length > 0;
|
|
2885
2884
|
const userTransform = options.transform;
|
|
2886
|
-
const transformFn = userTransform ? (pkg)=>userTransform({
|
|
2885
|
+
const transformFn = !hasTargets && userTransform ? (pkg)=>userTransform({
|
|
2887
2886
|
mode,
|
|
2888
|
-
target:
|
|
2887
|
+
target: void 0,
|
|
2889
2888
|
pkg
|
|
2890
2889
|
}) : void 0;
|
|
2891
2890
|
const apiModelForMode = "npm" === mode ? options.apiModel : void 0;
|
|
@@ -2931,9 +2930,6 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
2931
2930
|
}));
|
|
2932
2931
|
plugins.push(FilesArrayPlugin({
|
|
2933
2932
|
mode,
|
|
2934
|
-
...primaryTarget && {
|
|
2935
|
-
target: primaryTarget
|
|
2936
|
-
},
|
|
2937
2933
|
...options.transformFiles && {
|
|
2938
2934
|
transformFiles: options.transformFiles
|
|
2939
2935
|
},
|
|
@@ -3213,9 +3209,9 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
|
|
|
3213
3209
|
});
|
|
3214
3210
|
}
|
|
3215
3211
|
}
|
|
3216
|
-
if (
|
|
3217
|
-
|
|
3218
|
-
|
|
3212
|
+
if (hasTargets) plugins.push(PublishTargetPlugin({
|
|
3213
|
+
targets: publishTargets,
|
|
3214
|
+
stagingDir: external_node_path_resolve(cwd, baseOutputDir),
|
|
3219
3215
|
mode,
|
|
3220
3216
|
...userTransform && {
|
|
3221
3217
|
transform: userTransform
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/rslib-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "RSlib-based build system for Node.js libraries with automatic package.json transformation, TypeScript declaration bundling, and multi-target support",
|
|
6
6
|
"keywords": [
|