@savvy-web/rslib-builder 0.14.0 → 0.14.2

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.
Files changed (2) hide show
  1. package/index.js +31 -2
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -2224,6 +2224,10 @@ async function buildPackageJson(packageJson, isProduction = false, processTSExpo
2224
2224
  result = applyRslibTransformations(pnpmTransformed, packageJson, processTSExports, entrypoints, exportToOutputMap, bundle);
2225
2225
  } else result = applyRslibTransformations(packageJson, packageJson, processTSExports, entrypoints, exportToOutputMap, bundle);
2226
2226
  if (formatConditions && result.exports) result.exports = applyFormatConditions(result.exports, formatConditions);
2227
+ if (formatConditions?.dualFormat && result.bin) {
2228
+ const prefixedBin = applyFormatPrefixToBin(result.bin, formatConditions.format ?? "esm");
2229
+ if (prefixedBin) result.bin = prefixedBin;
2230
+ }
2227
2231
  if (transform) result = transform(result);
2228
2232
  return result;
2229
2233
  }
@@ -2239,6 +2243,15 @@ function addFormatDirPrefix(path, format) {
2239
2243
  if (path.startsWith("./")) return `./${format}/${path.slice(2)}`;
2240
2244
  return `./${format}/${path}`;
2241
2245
  }
2246
+ function applyFormatPrefixToBin(bin, format) {
2247
+ if ("string" == typeof bin) return bin.endsWith(".js") ? addFormatDirPrefix(bin, format) : bin;
2248
+ if (bin && "object" == typeof bin) {
2249
+ const result = {};
2250
+ for (const [command, path] of Object.entries(bin))if (void 0 !== path) result[command] = path.endsWith(".js") ? addFormatDirPrefix(path, format) : path;
2251
+ return result;
2252
+ }
2253
+ return bin;
2254
+ }
2242
2255
  function applyFormatConditions(exports, options) {
2243
2256
  if (!exports || "object" != typeof exports || Array.isArray(exports)) return exports;
2244
2257
  const { format = "esm", entryFormats, dualFormat } = options;
@@ -2952,6 +2965,21 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
2952
2965
  });
2953
2966
  }
2954
2967
  },
2968
+ {
2969
+ name: "strip-bin-entries",
2970
+ setup (api) {
2971
+ api.modifyRsbuildConfig((config)=>{
2972
+ const envKey = `${target}-${secondaryFormat}`;
2973
+ const envConfig = config.environments?.[envKey];
2974
+ if (envConfig?.source?.entry) {
2975
+ const filtered = {};
2976
+ for (const [name, value] of Object.entries(envConfig.source.entry))if (!name.startsWith("bin/")) filtered[name] = value;
2977
+ envConfig.source.entry = filtered;
2978
+ }
2979
+ return config;
2980
+ });
2981
+ }
2982
+ },
2955
2983
  DtsPlugin({
2956
2984
  ...options.tsconfigPath && {
2957
2985
  tsconfigPath: options.tsconfigPath
@@ -2966,6 +2994,7 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
2966
2994
  dtsPathPrefix: secondaryFormat
2967
2995
  })
2968
2996
  ];
2997
+ const secondaryEntry = entry ? Object.fromEntries(Object.entries(entry).filter(([name])=>!name.startsWith("bin/"))) : void 0;
2969
2998
  const secondaryLib = {
2970
2999
  id: `${target}-${secondaryFormat}`,
2971
3000
  outBase: bundle ? baseOutputDir : "src",
@@ -2990,8 +3019,8 @@ if (module.exports && module.exports.__esModule && 'default' in module.exports)
2990
3019
  ...options.tsconfigPath && {
2991
3020
  tsconfigPath: options.tsconfigPath
2992
3021
  },
2993
- ...entry && {
2994
- entry
3022
+ ...secondaryEntry && {
3023
+ entry: secondaryEntry
2995
3024
  },
2996
3025
  define: sourceDefine
2997
3026
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/rslib-builder",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
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": [
@@ -62,9 +62,9 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@microsoft/api-extractor": "^7.56.3",
65
- "@rslib/core": "^0.19.5",
65
+ "@rslib/core": "^0.19.6",
66
66
  "@types/node": "^25.2.3",
67
- "@typescript/native-preview": "7.0.0-dev.20260210.1",
67
+ "@typescript/native-preview": "7.0.0-dev.20260214.1",
68
68
  "typescript": "^5.9.3"
69
69
  },
70
70
  "peerDependenciesMeta": {