@savvy-web/rslib-builder 0.15.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 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 primary build completes. For each additional
2219
- * publish target (beyond the primary):
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 primary output directory
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 primary output's package.json
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
- * Additional publish targets to write output for (targets beyond the primary).
2231
+ * Publish targets to write output for.
2243
2232
  *
2244
2233
  * @remarks
2245
- * Each target gets a copy of the primary build output with per-target
2234
+ * Each target gets a copy of the build staging output with per-target
2246
2235
  * package.json transformations applied.
2247
2236
  */
2248
- additionalTargets: PublishTarget[];
2237
+ targets: PublishTarget[];
2249
2238
  /**
2250
- * Absolute path to the primary output directory.
2239
+ * Absolute path to the build staging directory (dist/&lt;mode&gt;).
2251
2240
  *
2252
2241
  * @remarks
2253
- * The primary build output is copied from this directory to each
2254
- * additional target's directory.
2242
+ * Build artifacts are copied from this directory to each target's
2243
+ * directory (when they differ).
2255
2244
  */
2256
- primaryOutdir: string;
2245
+ stagingDir: string;
2257
2246
  /**
2258
- * Current build mode (e.g., "npm").
2247
+ * Current build mode.
2259
2248
  */
2260
- mode: string;
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 additional target.
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 additional target's package.json.
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 { additionalTargets, primaryOutdir, mode, transform, name } = options;
2362
- if (0 === additionalTargets.length) return;
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 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) {
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(primaryOutdir, target.directory, {
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: mode,
2377
+ mode,
2379
2378
  target,
2380
2379
  pkg: targetPkg
2381
2380
  });
2382
2381
  if (name) targetPkg.name = name;
2383
- if (primaryPkg.files) targetPkg.files = [
2384
- ...primaryPkg.files
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 primaryTarget = publishTargets[0];
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: primaryTarget,
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 (publishTargets.length > 1) plugins.push(PublishTargetPlugin({
3217
- additionalTargets: publishTargets.slice(1),
3218
- primaryOutdir: external_node_path_resolve(cwd, baseOutputDir),
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.15.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": [
@@ -44,24 +44,24 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@microsoft/tsdoc": "^0.16.0",
47
- "@microsoft/tsdoc-config": "^0.18.0",
47
+ "@microsoft/tsdoc-config": "^0.18.1",
48
48
  "@pnpm/catalogs.config": "^1000.0.5",
49
49
  "@pnpm/catalogs.protocol-parser": "^1001.0.0",
50
- "@pnpm/exportable-manifest": "^1000.4.0",
51
- "@pnpm/lockfile.fs": "^1001.1.29",
50
+ "@pnpm/exportable-manifest": "^1000.4.1",
51
+ "@pnpm/lockfile.fs": "^1001.1.31",
52
52
  "@pnpm/workspace.read-manifest": "^1000.2.10",
53
- "@typescript-eslint/parser": "^8.56.0",
53
+ "@typescript-eslint/parser": "^8.56.1",
54
54
  "deep-equal": "^2.2.3",
55
- "eslint": "^10.0.0",
55
+ "eslint": "^10.0.2",
56
56
  "eslint-plugin-tsdoc": "^0.5.2",
57
- "glob": "^13.0.1",
57
+ "glob": "^13.0.6",
58
58
  "picocolors": "^1.1.1",
59
59
  "sort-package-json": "^3.6.1",
60
- "tmp": "^0.2.4",
60
+ "tmp": "^0.2.5",
61
61
  "workspace-tools": "^0.41.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@microsoft/api-extractor": ">=7.56.0 <7.57.0",
64
+ "@microsoft/api-extractor": "^7.57.6",
65
65
  "@rslib/core": "^0.19.6",
66
66
  "@types/node": "^25.2.0",
67
67
  "@typescript/native-preview": "^7.0.0-dev.20260124.1",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.3"
8
+ "packageVersion": "7.57.6"
9
9
  }
10
10
  ]
11
11
  }