@storm-software/unbuild 0.30.2 → 0.30.4

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/README.md CHANGED
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
21
21
 
22
22
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
23
23
 
24
- [![Version](https://img.shields.io/badge/version-0.30.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
24
+ [![Version](https://img.shields.io/badge/version-0.30.3-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
package/bin/unbuild.cjs CHANGED
@@ -1204,8 +1204,10 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
1204
1204
  if (!buildTarget) {
1205
1205
  throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
1206
1206
  }
1207
+ writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
1208
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
1207
1209
  const result = await (0, import_js.copyAssets)({
1208
- assets,
1210
+ assets: pendingAssets,
1209
1211
  watch: false,
1210
1212
  outputPath
1211
1213
  }, {
@@ -2977,11 +2979,12 @@ async function resolveOptions(options, config) {
2977
2979
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
2978
2980
  dependencies.push(tsLibDependency);
2979
2981
  }
2982
+ const name = options.name || projectName;
2980
2983
  const entries = options.entry ?? [
2981
2984
  sourceRoot
2982
2985
  ];
2983
2986
  const resolvedOptions = {
2984
- name: projectName,
2987
+ name,
2985
2988
  config,
2986
2989
  projectRoot: options.projectRoot,
2987
2990
  sourceRoot,
@@ -2990,14 +2993,15 @@ async function resolveOptions(options, config) {
2990
2993
  clean: false,
2991
2994
  entries: entries.reduce((ret, entry) => {
2992
2995
  let entryPath = entry.replace(options.projectRoot, "");
2993
- if (entryPath.startsWith(".")) {
2996
+ while (entryPath.startsWith(".")) {
2994
2997
  entryPath = entryPath.substring(1);
2995
2998
  }
2996
- if (entryPath.startsWith("/")) {
2999
+ while (entryPath.startsWith("/")) {
2997
3000
  entryPath = entryPath.substring(1);
2998
3001
  }
2999
3002
  const outDir = joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
3000
3003
  ret.push({
3004
+ name: `${name}-esm`,
3001
3005
  builder: "mkdist",
3002
3006
  input: `./${entryPath}`,
3003
3007
  outDir,
@@ -3005,6 +3009,7 @@ async function resolveOptions(options, config) {
3005
3009
  format: "esm"
3006
3010
  });
3007
3011
  ret.push({
3012
+ name: `${name}-cjs`,
3008
3013
  builder: "mkdist",
3009
3014
  input: `./${entryPath}`,
3010
3015
  outDir,
@@ -3062,8 +3067,8 @@ async function resolveOptions(options, config) {
3062
3067
  ]
3063
3068
  },
3064
3069
  esbuild: {
3065
- minify: options.minify || !options.debug,
3066
- sourceMap: options.sourcemap || !!options.debug,
3070
+ minify: options.minify ?? !options.debug,
3071
+ sourceMap: options.sourcemap ?? !!options.debug,
3067
3072
  splitting: options.splitting !== false,
3068
3073
  treeShaking: options.treeShaking !== false,
3069
3074
  color: true,
@@ -3102,10 +3107,20 @@ async function resolveOptions(options, config) {
3102
3107
  return resolvedOptions;
3103
3108
  }
3104
3109
  __name(resolveOptions, "resolveOptions");
3105
- var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
3106
- let entry = file.replaceAll("\\", "/");
3107
- if (sourceRoot) {
3108
- entry = entry.replace(sourceRoot, "");
3110
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot, projectRoot) => {
3111
+ let root = sourceRoot.replace(projectRoot, "");
3112
+ while (root.startsWith(".")) {
3113
+ root = root.substring(1);
3114
+ }
3115
+ while (root.startsWith("/")) {
3116
+ root = root.substring(1);
3117
+ }
3118
+ let entry = file.replaceAll("\\", "/").replace(sourceRoot, "");
3119
+ while (entry.startsWith(".")) {
3120
+ entry = entry.substring(1);
3121
+ }
3122
+ while (entry.startsWith("/")) {
3123
+ entry = entry.substring(1);
3109
3124
  }
3110
3125
  return {
3111
3126
  "import": {
@@ -3139,7 +3154,15 @@ async function generatePackageJson(options) {
3139
3154
  packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
3140
3155
  packageJson.exports ??= {};
3141
3156
  await Promise.all(options.entries.reduce((ret, entry) => {
3142
- const entryPath = typeof entry === "string" ? entry : entry.input;
3157
+ let entryPath = typeof entry === "string" ? entry : entry.input;
3158
+ entryPath = entryPath.replaceAll("\\", "/");
3159
+ while (entryPath.startsWith(".")) {
3160
+ entryPath = entryPath.substring(1);
3161
+ }
3162
+ while (entryPath.startsWith("/")) {
3163
+ entryPath = entryPath.substring(1);
3164
+ }
3165
+ entryPath = `./${joinPaths(options.projectRoot, entryPath)}`;
3143
3166
  if (!ret.includes(entryPath)) {
3144
3167
  ret.push(entryPath);
3145
3168
  }
@@ -3151,11 +3174,11 @@ async function generatePackageJson(options) {
3151
3174
  root: entryPath
3152
3175
  }).walk();
3153
3176
  files.forEach((file) => {
3154
- addPackageJsonExport(file, packageJson.type, options.sourceRoot);
3177
+ addPackageJsonExport(file, packageJson.type, options.sourceRoot, options.projectRoot);
3155
3178
  const split = file.split(".");
3156
3179
  split.pop();
3157
3180
  const entry = split.join(".").replaceAll("\\", "/");
3158
- packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
3181
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot, options.projectRoot);
3159
3182
  });
3160
3183
  }));
3161
3184
  packageJson.main ??= "./dist/index.cjs";
@@ -3169,7 +3192,7 @@ async function generatePackageJson(options) {
3169
3192
  return ret;
3170
3193
  }, packageJson.exports);
3171
3194
  packageJson.exports["./package.json"] ??= "./package.json";
3172
- packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
3195
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
3173
3196
  await (0, import_devkit6.writeJsonFile)(joinPaths(options.outDir, "package.json"), packageJson);
3174
3197
  stopwatch();
3175
3198
  }
package/bin/unbuild.js CHANGED
@@ -1179,8 +1179,10 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
1179
1179
  if (!buildTarget) {
1180
1180
  throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
1181
1181
  }
1182
+ writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
1183
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
1182
1184
  const result = await copyAssetsBase({
1183
- assets,
1185
+ assets: pendingAssets,
1184
1186
  watch: false,
1185
1187
  outputPath
1186
1188
  }, {
@@ -2952,11 +2954,12 @@ async function resolveOptions(options, config) {
2952
2954
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
2953
2955
  dependencies.push(tsLibDependency);
2954
2956
  }
2957
+ const name = options.name || projectName;
2955
2958
  const entries = options.entry ?? [
2956
2959
  sourceRoot
2957
2960
  ];
2958
2961
  const resolvedOptions = {
2959
- name: projectName,
2962
+ name,
2960
2963
  config,
2961
2964
  projectRoot: options.projectRoot,
2962
2965
  sourceRoot,
@@ -2965,14 +2968,15 @@ async function resolveOptions(options, config) {
2965
2968
  clean: false,
2966
2969
  entries: entries.reduce((ret, entry) => {
2967
2970
  let entryPath = entry.replace(options.projectRoot, "");
2968
- if (entryPath.startsWith(".")) {
2971
+ while (entryPath.startsWith(".")) {
2969
2972
  entryPath = entryPath.substring(1);
2970
2973
  }
2971
- if (entryPath.startsWith("/")) {
2974
+ while (entryPath.startsWith("/")) {
2972
2975
  entryPath = entryPath.substring(1);
2973
2976
  }
2974
2977
  const outDir = joinPaths(relative4(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
2975
2978
  ret.push({
2979
+ name: `${name}-esm`,
2976
2980
  builder: "mkdist",
2977
2981
  input: `./${entryPath}`,
2978
2982
  outDir,
@@ -2980,6 +2984,7 @@ async function resolveOptions(options, config) {
2980
2984
  format: "esm"
2981
2985
  });
2982
2986
  ret.push({
2987
+ name: `${name}-cjs`,
2983
2988
  builder: "mkdist",
2984
2989
  input: `./${entryPath}`,
2985
2990
  outDir,
@@ -3037,8 +3042,8 @@ async function resolveOptions(options, config) {
3037
3042
  ]
3038
3043
  },
3039
3044
  esbuild: {
3040
- minify: options.minify || !options.debug,
3041
- sourceMap: options.sourcemap || !!options.debug,
3045
+ minify: options.minify ?? !options.debug,
3046
+ sourceMap: options.sourcemap ?? !!options.debug,
3042
3047
  splitting: options.splitting !== false,
3043
3048
  treeShaking: options.treeShaking !== false,
3044
3049
  color: true,
@@ -3077,10 +3082,20 @@ async function resolveOptions(options, config) {
3077
3082
  return resolvedOptions;
3078
3083
  }
3079
3084
  __name(resolveOptions, "resolveOptions");
3080
- var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
3081
- let entry = file.replaceAll("\\", "/");
3082
- if (sourceRoot) {
3083
- entry = entry.replace(sourceRoot, "");
3085
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot, projectRoot) => {
3086
+ let root = sourceRoot.replace(projectRoot, "");
3087
+ while (root.startsWith(".")) {
3088
+ root = root.substring(1);
3089
+ }
3090
+ while (root.startsWith("/")) {
3091
+ root = root.substring(1);
3092
+ }
3093
+ let entry = file.replaceAll("\\", "/").replace(sourceRoot, "");
3094
+ while (entry.startsWith(".")) {
3095
+ entry = entry.substring(1);
3096
+ }
3097
+ while (entry.startsWith("/")) {
3098
+ entry = entry.substring(1);
3084
3099
  }
3085
3100
  return {
3086
3101
  "import": {
@@ -3114,7 +3129,15 @@ async function generatePackageJson(options) {
3114
3129
  packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
3115
3130
  packageJson.exports ??= {};
3116
3131
  await Promise.all(options.entries.reduce((ret, entry) => {
3117
- const entryPath = typeof entry === "string" ? entry : entry.input;
3132
+ let entryPath = typeof entry === "string" ? entry : entry.input;
3133
+ entryPath = entryPath.replaceAll("\\", "/");
3134
+ while (entryPath.startsWith(".")) {
3135
+ entryPath = entryPath.substring(1);
3136
+ }
3137
+ while (entryPath.startsWith("/")) {
3138
+ entryPath = entryPath.substring(1);
3139
+ }
3140
+ entryPath = `./${joinPaths(options.projectRoot, entryPath)}`;
3118
3141
  if (!ret.includes(entryPath)) {
3119
3142
  ret.push(entryPath);
3120
3143
  }
@@ -3126,11 +3149,11 @@ async function generatePackageJson(options) {
3126
3149
  root: entryPath
3127
3150
  }).walk();
3128
3151
  files.forEach((file) => {
3129
- addPackageJsonExport(file, packageJson.type, options.sourceRoot);
3152
+ addPackageJsonExport(file, packageJson.type, options.sourceRoot, options.projectRoot);
3130
3153
  const split = file.split(".");
3131
3154
  split.pop();
3132
3155
  const entry = split.join(".").replaceAll("\\", "/");
3133
- packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
3156
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot, options.projectRoot);
3134
3157
  });
3135
3158
  }));
3136
3159
  packageJson.main ??= "./dist/index.cjs";
@@ -3144,7 +3167,7 @@ async function generatePackageJson(options) {
3144
3167
  return ret;
3145
3168
  }, packageJson.exports);
3146
3169
  packageJson.exports["./package.json"] ??= "./package.json";
3147
- packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
3170
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
3148
3171
  await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
3149
3172
  stopwatch();
3150
3173
  }
package/dist/build.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkP7LBAA5Ocjs = require('./chunk-P7LBAA5O.cjs');
8
+ var _chunkF77T2VZVcjs = require('./chunk-F77T2VZV.cjs');
9
9
  require('./chunk-5E3NJ26L.cjs');
10
10
  require('./chunk-Y2DOCJBE.cjs');
11
11
  require('./chunk-V627S7QU.cjs');
@@ -21,4 +21,4 @@ require('./chunk-YDYGZTJK.cjs');
21
21
 
22
22
 
23
23
 
24
- exports.build = _chunkP7LBAA5Ocjs.build; exports.cleanOutputPath = _chunkP7LBAA5Ocjs.cleanOutputPath; exports.copyBuildAssets = _chunkP7LBAA5Ocjs.copyBuildAssets; exports.executeUnbuild = _chunkP7LBAA5Ocjs.executeUnbuild; exports.generatePackageJson = _chunkP7LBAA5Ocjs.generatePackageJson; exports.resolveOptions = _chunkP7LBAA5Ocjs.resolveOptions;
24
+ exports.build = _chunkF77T2VZVcjs.build; exports.cleanOutputPath = _chunkF77T2VZVcjs.cleanOutputPath; exports.copyBuildAssets = _chunkF77T2VZVcjs.copyBuildAssets; exports.executeUnbuild = _chunkF77T2VZVcjs.executeUnbuild; exports.generatePackageJson = _chunkF77T2VZVcjs.generatePackageJson; exports.resolveOptions = _chunkF77T2VZVcjs.resolveOptions;
package/dist/build.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  executeUnbuild,
6
6
  generatePackageJson,
7
7
  resolveOptions
8
- } from "./chunk-ZQVJCLMA.js";
8
+ } from "./chunk-VD6EE7HD.js";
9
9
  import "./chunk-VC7N2YVM.js";
10
10
  import "./chunk-K2D7TQ7G.js";
11
11
  import "./chunk-C5IHRWT3.js";
@@ -590,8 +590,10 @@ var copyAssets = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, async (co
590
590
  if (!buildTarget) {
591
591
  throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${_chunkFG6XQ26Mcjs.joinPaths.call(void 0, projectRoot, "project.json")}`);
592
592
  }
593
+ _chunkFG6XQ26Mcjs.writeTrace.call(void 0, `\u{1F4DD} Copying the following assets to the output directory:
594
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${_chunkFG6XQ26Mcjs.joinPaths.call(void 0, outputPath, pendingAsset.output)}`).join("\n")}`, config);
593
595
  const result = await _js.copyAssets.call(void 0, {
594
- assets,
596
+ assets: pendingAssets,
595
597
  watch: false,
596
598
  outputPath
597
599
  }, {
@@ -2210,11 +2212,12 @@ async function resolveOptions(options, config) {
2210
2212
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
2211
2213
  dependencies.push(tsLibDependency);
2212
2214
  }
2215
+ const name = options.name || projectName;
2213
2216
  const entries = _nullishCoalesce(options.entry, () => ( [
2214
2217
  sourceRoot
2215
2218
  ]));
2216
2219
  const resolvedOptions = {
2217
- name: projectName,
2220
+ name,
2218
2221
  config,
2219
2222
  projectRoot: options.projectRoot,
2220
2223
  sourceRoot,
@@ -2223,14 +2226,15 @@ async function resolveOptions(options, config) {
2223
2226
  clean: false,
2224
2227
  entries: entries.reduce((ret, entry) => {
2225
2228
  let entryPath = entry.replace(options.projectRoot, "");
2226
- if (entryPath.startsWith(".")) {
2229
+ while (entryPath.startsWith(".")) {
2227
2230
  entryPath = entryPath.substring(1);
2228
2231
  }
2229
- if (entryPath.startsWith("/")) {
2232
+ while (entryPath.startsWith("/")) {
2230
2233
  entryPath = entryPath.substring(1);
2231
2234
  }
2232
2235
  const outDir = _chunkFG6XQ26Mcjs.joinPaths.call(void 0, _path.relative.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
2233
2236
  ret.push({
2237
+ name: `${name}-esm`,
2234
2238
  builder: "mkdist",
2235
2239
  input: `./${entryPath}`,
2236
2240
  outDir,
@@ -2238,6 +2242,7 @@ async function resolveOptions(options, config) {
2238
2242
  format: "esm"
2239
2243
  });
2240
2244
  ret.push({
2245
+ name: `${name}-cjs`,
2241
2246
  builder: "mkdist",
2242
2247
  input: `./${entryPath}`,
2243
2248
  outDir,
@@ -2295,8 +2300,8 @@ async function resolveOptions(options, config) {
2295
2300
  ]
2296
2301
  },
2297
2302
  esbuild: {
2298
- minify: options.minify || !options.debug,
2299
- sourceMap: options.sourcemap || !!options.debug,
2303
+ minify: _nullishCoalesce(options.minify, () => ( !options.debug)),
2304
+ sourceMap: _nullishCoalesce(options.sourcemap, () => ( !!options.debug)),
2300
2305
  splitting: options.splitting !== false,
2301
2306
  treeShaking: options.treeShaking !== false,
2302
2307
  color: true,
@@ -2335,10 +2340,20 @@ async function resolveOptions(options, config) {
2335
2340
  return resolvedOptions;
2336
2341
  }
2337
2342
  _chunkYDYGZTJKcjs.__name.call(void 0, resolveOptions, "resolveOptions");
2338
- var addPackageJsonExport = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (file, type = "module", sourceRoot) => {
2339
- let entry = file.replaceAll("\\", "/");
2340
- if (sourceRoot) {
2341
- entry = entry.replace(sourceRoot, "");
2343
+ var addPackageJsonExport = /* @__PURE__ */ _chunkYDYGZTJKcjs.__name.call(void 0, (file, type = "module", sourceRoot, projectRoot) => {
2344
+ let root = sourceRoot.replace(projectRoot, "");
2345
+ while (root.startsWith(".")) {
2346
+ root = root.substring(1);
2347
+ }
2348
+ while (root.startsWith("/")) {
2349
+ root = root.substring(1);
2350
+ }
2351
+ let entry = file.replaceAll("\\", "/").replace(sourceRoot, "");
2352
+ while (entry.startsWith(".")) {
2353
+ entry = entry.substring(1);
2354
+ }
2355
+ while (entry.startsWith("/")) {
2356
+ entry = entry.substring(1);
2342
2357
  }
2343
2358
  return {
2344
2359
  "import": {
@@ -2372,7 +2387,15 @@ async function generatePackageJson(options) {
2372
2387
  packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
2373
2388
  packageJson.exports ??= {};
2374
2389
  await Promise.all(options.entries.reduce((ret, entry) => {
2375
- const entryPath = typeof entry === "string" ? entry : entry.input;
2390
+ let entryPath = typeof entry === "string" ? entry : entry.input;
2391
+ entryPath = entryPath.replaceAll("\\", "/");
2392
+ while (entryPath.startsWith(".")) {
2393
+ entryPath = entryPath.substring(1);
2394
+ }
2395
+ while (entryPath.startsWith("/")) {
2396
+ entryPath = entryPath.substring(1);
2397
+ }
2398
+ entryPath = `./${_chunkFG6XQ26Mcjs.joinPaths.call(void 0, options.projectRoot, entryPath)}`;
2376
2399
  if (!ret.includes(entryPath)) {
2377
2400
  ret.push(entryPath);
2378
2401
  }
@@ -2384,11 +2407,11 @@ async function generatePackageJson(options) {
2384
2407
  root: entryPath
2385
2408
  }).walk();
2386
2409
  files.forEach((file) => {
2387
- addPackageJsonExport(file, packageJson.type, options.sourceRoot);
2410
+ addPackageJsonExport(file, packageJson.type, options.sourceRoot, options.projectRoot);
2388
2411
  const split = file.split(".");
2389
2412
  split.pop();
2390
2413
  const entry = split.join(".").replaceAll("\\", "/");
2391
- packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
2414
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot, options.projectRoot);
2392
2415
  });
2393
2416
  }));
2394
2417
  packageJson.main ??= "./dist/index.cjs";
@@ -2402,7 +2425,7 @@ async function generatePackageJson(options) {
2402
2425
  return ret;
2403
2426
  }, packageJson.exports);
2404
2427
  packageJson.exports["./package.json"] ??= "./package.json";
2405
- packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
2428
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
2406
2429
  await _devkit.writeJsonFile.call(void 0, _chunkFG6XQ26Mcjs.joinPaths.call(void 0, options.outDir, "package.json"), packageJson);
2407
2430
  stopwatch();
2408
2431
  }
@@ -589,8 +589,10 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
589
589
  if (!buildTarget) {
590
590
  throw new Error(`The Build process failed because the project does not have a valid build target in the project.json file. Check if the file exists in the root of the project at ${joinPaths(projectRoot, "project.json")}`);
591
591
  }
592
+ writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
593
+ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
592
594
  const result = await copyAssetsBase({
593
- assets,
595
+ assets: pendingAssets,
594
596
  watch: false,
595
597
  outputPath
596
598
  }, {
@@ -2209,11 +2211,12 @@ async function resolveOptions(options, config) {
2209
2211
  dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
2210
2212
  dependencies.push(tsLibDependency);
2211
2213
  }
2214
+ const name = options.name || projectName;
2212
2215
  const entries = options.entry ?? [
2213
2216
  sourceRoot
2214
2217
  ];
2215
2218
  const resolvedOptions = {
2216
- name: projectName,
2219
+ name,
2217
2220
  config,
2218
2221
  projectRoot: options.projectRoot,
2219
2222
  sourceRoot,
@@ -2222,14 +2225,15 @@ async function resolveOptions(options, config) {
2222
2225
  clean: false,
2223
2226
  entries: entries.reduce((ret, entry) => {
2224
2227
  let entryPath = entry.replace(options.projectRoot, "");
2225
- if (entryPath.startsWith(".")) {
2228
+ while (entryPath.startsWith(".")) {
2226
2229
  entryPath = entryPath.substring(1);
2227
2230
  }
2228
- if (entryPath.startsWith("/")) {
2231
+ while (entryPath.startsWith("/")) {
2229
2232
  entryPath = entryPath.substring(1);
2230
2233
  }
2231
2234
  const outDir = joinPaths(relative3(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
2232
2235
  ret.push({
2236
+ name: `${name}-esm`,
2233
2237
  builder: "mkdist",
2234
2238
  input: `./${entryPath}`,
2235
2239
  outDir,
@@ -2237,6 +2241,7 @@ async function resolveOptions(options, config) {
2237
2241
  format: "esm"
2238
2242
  });
2239
2243
  ret.push({
2244
+ name: `${name}-cjs`,
2240
2245
  builder: "mkdist",
2241
2246
  input: `./${entryPath}`,
2242
2247
  outDir,
@@ -2294,8 +2299,8 @@ async function resolveOptions(options, config) {
2294
2299
  ]
2295
2300
  },
2296
2301
  esbuild: {
2297
- minify: options.minify || !options.debug,
2298
- sourceMap: options.sourcemap || !!options.debug,
2302
+ minify: options.minify ?? !options.debug,
2303
+ sourceMap: options.sourcemap ?? !!options.debug,
2299
2304
  splitting: options.splitting !== false,
2300
2305
  treeShaking: options.treeShaking !== false,
2301
2306
  color: true,
@@ -2334,10 +2339,20 @@ async function resolveOptions(options, config) {
2334
2339
  return resolvedOptions;
2335
2340
  }
2336
2341
  __name(resolveOptions, "resolveOptions");
2337
- var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot) => {
2338
- let entry = file.replaceAll("\\", "/");
2339
- if (sourceRoot) {
2340
- entry = entry.replace(sourceRoot, "");
2342
+ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot, projectRoot) => {
2343
+ let root = sourceRoot.replace(projectRoot, "");
2344
+ while (root.startsWith(".")) {
2345
+ root = root.substring(1);
2346
+ }
2347
+ while (root.startsWith("/")) {
2348
+ root = root.substring(1);
2349
+ }
2350
+ let entry = file.replaceAll("\\", "/").replace(sourceRoot, "");
2351
+ while (entry.startsWith(".")) {
2352
+ entry = entry.substring(1);
2353
+ }
2354
+ while (entry.startsWith("/")) {
2355
+ entry = entry.substring(1);
2341
2356
  }
2342
2357
  return {
2343
2358
  "import": {
@@ -2371,7 +2386,15 @@ async function generatePackageJson(options) {
2371
2386
  packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
2372
2387
  packageJson.exports ??= {};
2373
2388
  await Promise.all(options.entries.reduce((ret, entry) => {
2374
- const entryPath = typeof entry === "string" ? entry : entry.input;
2389
+ let entryPath = typeof entry === "string" ? entry : entry.input;
2390
+ entryPath = entryPath.replaceAll("\\", "/");
2391
+ while (entryPath.startsWith(".")) {
2392
+ entryPath = entryPath.substring(1);
2393
+ }
2394
+ while (entryPath.startsWith("/")) {
2395
+ entryPath = entryPath.substring(1);
2396
+ }
2397
+ entryPath = `./${joinPaths(options.projectRoot, entryPath)}`;
2375
2398
  if (!ret.includes(entryPath)) {
2376
2399
  ret.push(entryPath);
2377
2400
  }
@@ -2383,11 +2406,11 @@ async function generatePackageJson(options) {
2383
2406
  root: entryPath
2384
2407
  }).walk();
2385
2408
  files.forEach((file) => {
2386
- addPackageJsonExport(file, packageJson.type, options.sourceRoot);
2409
+ addPackageJsonExport(file, packageJson.type, options.sourceRoot, options.projectRoot);
2387
2410
  const split = file.split(".");
2388
2411
  split.pop();
2389
2412
  const entry = split.join(".").replaceAll("\\", "/");
2390
- packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot);
2413
+ packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry, packageJson.type, options.sourceRoot, options.projectRoot);
2391
2414
  });
2392
2415
  }));
2393
2416
  packageJson.main ??= "./dist/index.cjs";
@@ -2401,7 +2424,7 @@ async function generatePackageJson(options) {
2401
2424
  return ret;
2402
2425
  }, packageJson.exports);
2403
2426
  packageJson.exports["./package.json"] ??= "./package.json";
2404
- packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot);
2427
+ packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
2405
2428
  await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
2406
2429
  stopwatch();
2407
2430
  }
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkP7LBAA5Ocjs = require('./chunk-P7LBAA5O.cjs');
8
+ var _chunkF77T2VZVcjs = require('./chunk-F77T2VZV.cjs');
9
9
 
10
10
 
11
11
 
@@ -35,4 +35,4 @@ require('./chunk-YDYGZTJK.cjs');
35
35
 
36
36
 
37
37
 
38
- exports.build = _chunkP7LBAA5Ocjs.build; exports.clean = _chunk5E3NJ26Lcjs.clean; exports.cleanDirectories = _chunk5E3NJ26Lcjs.cleanDirectories; exports.cleanOutputPath = _chunkP7LBAA5Ocjs.cleanOutputPath; exports.copyBuildAssets = _chunkP7LBAA5Ocjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkV627S7QUcjs.createTsCompilerOptions; exports.executeUnbuild = _chunkP7LBAA5Ocjs.executeUnbuild; exports.generatePackageJson = _chunkP7LBAA5Ocjs.generatePackageJson; exports.getDefaultBuildPlugins = _chunkY2DOCJBEcjs.getDefaultBuildPlugins; exports.loadConfig = _chunkV627S7QUcjs.loadConfig; exports.resolveOptions = _chunkP7LBAA5Ocjs.resolveOptions;
38
+ exports.build = _chunkF77T2VZVcjs.build; exports.clean = _chunk5E3NJ26Lcjs.clean; exports.cleanDirectories = _chunk5E3NJ26Lcjs.cleanDirectories; exports.cleanOutputPath = _chunkF77T2VZVcjs.cleanOutputPath; exports.copyBuildAssets = _chunkF77T2VZVcjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkV627S7QUcjs.createTsCompilerOptions; exports.executeUnbuild = _chunkF77T2VZVcjs.executeUnbuild; exports.generatePackageJson = _chunkF77T2VZVcjs.generatePackageJson; exports.getDefaultBuildPlugins = _chunkY2DOCJBEcjs.getDefaultBuildPlugins; exports.loadConfig = _chunkV627S7QUcjs.loadConfig; exports.resolveOptions = _chunkF77T2VZVcjs.resolveOptions;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  executeUnbuild,
6
6
  generatePackageJson,
7
7
  resolveOptions
8
- } from "./chunk-ZQVJCLMA.js";
8
+ } from "./chunk-VD6EE7HD.js";
9
9
  import {
10
10
  clean,
11
11
  cleanDirectories
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/unbuild",
3
- "version": "0.30.2",
3
+ "version": "0.30.4",
4
4
  "type": "module",
5
5
  "description": "A package containing `unbuild` utilities for building Storm Software libraries and applications",
6
6
  "repository": {
@@ -171,9 +171,9 @@
171
171
  "@nx/devkit": "^20.3.1",
172
172
  "@nx/js": "^20.3.1",
173
173
  "@rollup/pluginutils": "^5.1.4",
174
- "@storm-software/build-tools": "0.135.2",
175
- "@storm-software/config": "1.98.1",
176
- "@storm-software/config-tools": "1.141.2",
174
+ "@storm-software/build-tools": "0.135.4",
175
+ "@storm-software/config": "1.98.2",
176
+ "@storm-software/config-tools": "1.141.4",
177
177
  "@swc/core": "1.7.26",
178
178
  "@types/node": "^22.10.2",
179
179
  "commander": "^12.1.0",