@storm-software/esbuild 0.33.7 → 0.34.1

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.33.7-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.34.0-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/esbuild.cjs CHANGED
@@ -69,9 +69,7 @@ var import_build_tools = require("@storm-software/build-tools");
69
69
  var DEFAULT_BUILD_OPTIONS = {
70
70
  assets: [],
71
71
  platform: "node",
72
- target: [
73
- "esnext"
74
- ],
72
+ target: "node22",
75
73
  format: "esm",
76
74
  tsconfig: "tsconfig.json",
77
75
  mode: "production",
@@ -80,9 +78,11 @@ var DEFAULT_BUILD_OPTIONS = {
80
78
  keepNames: true,
81
79
  metafile: false,
82
80
  treeshake: true,
81
+ splitting: true,
83
82
  shims: false,
84
83
  watch: false,
85
84
  bundle: true,
85
+ distDir: "dist",
86
86
  loader: {
87
87
  ".aac": "file",
88
88
  ".css": "file",
@@ -228,29 +228,23 @@ async function resolveContext(userOptions) {
228
228
  throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
229
229
  }
230
230
  const options = (0, import_defu.default)(userOptions, DEFAULT_BUILD_OPTIONS);
231
- options.name ??= `${projectName}-${options.format}`;
232
- options.target ??= import_build_tools2.DEFAULT_TARGET;
233
231
  const packageJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, options.projectRoot, "package.json");
234
232
  if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
235
233
  throw new Error("Cannot find package.json configuration");
236
234
  }
237
235
  const env = (0, import_build_tools2.getEnv)("esbuild", options);
236
+ const define = (0, import_defu.default)(options.define ?? {}, env ?? {});
238
237
  const resolvedOptions = {
238
+ name: projectName,
239
239
  ...options,
240
240
  tsconfig: (0, import_correct_paths.joinPaths)(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
241
- distDir: "dist",
242
- name: projectName,
243
241
  metafile: userOptions.mode === "development",
244
- ...userOptions,
245
242
  clean: false,
246
- target: userOptions.target || options.target,
247
- splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
248
243
  env,
249
244
  define: {
250
245
  STORM_FORMAT: JSON.stringify(options.format),
251
- ...options.define,
252
- ...Object.keys(env || {}).reduce((res, key) => {
253
- const value = JSON.stringify(env[key]);
246
+ ...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
247
+ const value = JSON.stringify(define[key]);
254
248
  const safeKey = key.replaceAll("(", "").replaceAll(")", "");
255
249
  return {
256
250
  ...res,
@@ -292,26 +286,79 @@ async function generatePackageJson(context) {
292
286
  if (context.options.entry) {
293
287
  packageJson.exports ??= {};
294
288
  packageJson.exports["./package.json"] ??= "./package.json";
295
- packageJson.exports["."] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js`;
296
289
  const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
297
- for (const entryPoint of entryPoints) {
298
- if (context.options.entry[entryPoint]) {
299
- const entry = context.options.entry[entryPoint].replaceAll("\\", "/").replaceAll(/^(\.\/)*/g, "").replace(/\.([cm])?[jt]s(x)?$/g, "");
300
- packageJson.exports[`./${entry}`] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entry}.js`;
290
+ if (entryPoints.length > 0) {
291
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
292
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
293
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
294
+ const isDts = context.options.dts || context.options.experimentalDts;
295
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
296
+ for (const entryPoint of entryPoints) {
297
+ packageJson.exports[`./${entryPoint}`] ??= {};
298
+ if (isEsm) {
299
+ if (isDts) {
300
+ packageJson.exports[`./${entryPoint}`].import = {
301
+ types: `./dist/${entryPoint}.d.mts`,
302
+ default: `./dist/${entryPoint}.mjs`
303
+ };
304
+ } else {
305
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
306
+ }
307
+ if (isDts) {
308
+ packageJson.exports[`./${entryPoint}`].default = {
309
+ types: `./dist/${entryPoint}.d.mts`,
310
+ default: `./dist/${entryPoint}.mjs`
311
+ };
312
+ } else {
313
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
314
+ }
315
+ }
316
+ if (isCjs) {
317
+ if (isDts) {
318
+ packageJson.exports[`./${entryPoint}`].require = {
319
+ types: `./dist/${entryPoint}.d.cts`,
320
+ default: `./dist/${entryPoint}.cjs`
321
+ };
322
+ } else {
323
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
324
+ }
325
+ if (!isEsm) {
326
+ if (isDts) {
327
+ packageJson.exports[`./${entryPoint}`].default = {
328
+ types: `./dist/${entryPoint}.d.cts`,
329
+ default: `./dist/${entryPoint}.cjs`
330
+ };
331
+ } else {
332
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
333
+ }
334
+ }
335
+ }
336
+ if (!isEsm && !isCjs) {
337
+ if (isDts) {
338
+ packageJson.exports[`./${entryPoint}`].default = {
339
+ types: `./dist/${entryPoint}.d.ts`,
340
+ default: `./dist/${entryPoint}.js`
341
+ };
342
+ } else {
343
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
344
+ }
345
+ }
301
346
  }
302
- }
303
- if (context.options.format === "esm") {
304
- packageJson.module = packageJson.type === "module" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.mjs`;
305
- } else {
306
- packageJson.main = packageJson.type === "commonjs" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.cjs`;
307
- }
308
- packageJson.types = `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.d.ts`;
309
- packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
310
- if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
311
- ret[key.replace("/index", "")] = packageJson.exports[key];
347
+ if (isEsm) {
348
+ packageJson.module = `${defaultEntry}.mjs`;
349
+ } else {
350
+ packageJson.main = `${defaultEntry}.cjs`;
351
+ }
352
+ if (isDts) {
353
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
312
354
  }
313
- return ret;
314
- }, packageJson.exports);
355
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
356
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
357
+ ret[key.replace("/index", "")] = packageJson.exports[key];
358
+ }
359
+ return ret;
360
+ }, packageJson.exports);
361
+ }
315
362
  }
316
363
  await (0, import_devkit.writeJsonFile)((0, import_correct_paths.joinPaths)(context.outputPath, "package.json"), packageJson);
317
364
  stopwatch();
@@ -324,7 +371,7 @@ async function executeTsup(context) {
324
371
  const stopwatch = (0, import_console2.getStopwatch)(`${context.options.name} build`);
325
372
  await (0, import_tsup.build)({
326
373
  ...context.options,
327
- outDir: context.outputPath,
374
+ outDir: context.options.distDir ? (0, import_correct_paths.joinPaths)(context.outputPath, context.options.distDir) : context.outputPath,
328
375
  workspaceConfig: context.workspaceConfig
329
376
  });
330
377
  stopwatch();
package/dist/build.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkCH6OII7Bcjs = require('./chunk-CH6OII7B.cjs');
4
+ var _chunkRVMQBDDKcjs = require('./chunk-RVMQBDDK.cjs');
5
5
  require('./chunk-Y4XWI6JJ.cjs');
6
- require('./chunk-NWVUAY67.cjs');
6
+ require('./chunk-DZPLKD6O.cjs');
7
7
  require('./chunk-EZGTDCYM.cjs');
8
8
  require('./chunk-S6M44SSZ.cjs');
9
9
  require('./chunk-WRBUO7H6.cjs');
@@ -18,4 +18,4 @@ require('./chunk-BGYQAVKQ.cjs');
18
18
 
19
19
 
20
20
 
21
- exports.build = _chunkCH6OII7Bcjs.build; exports.watch = _chunkCH6OII7Bcjs.watch;
21
+ exports.build = _chunkRVMQBDDKcjs.build; exports.watch = _chunkRVMQBDDKcjs.watch;
package/dist/build.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  build,
3
3
  watch
4
- } from "./chunk-L6SPT5J7.js";
4
+ } from "./chunk-7A6JPBG7.js";
5
5
  import "./chunk-35YNFZCF.js";
6
- import "./chunk-HTVMQVFT.js";
6
+ import "./chunk-RTDGFM3J.js";
7
7
  import "./chunk-GWG4HOQ6.js";
8
8
  import "./chunk-T5272PC2.js";
9
9
  import "./chunk-LYDEMC26.js";
@@ -3,13 +3,12 @@ import {
3
3
  } from "./chunk-35YNFZCF.js";
4
4
  import {
5
5
  DEFAULT_BUILD_OPTIONS,
6
- DEFAULT_TARGET,
7
6
  addPackageDependencies,
8
7
  addWorkspacePackageJsonFields,
9
8
  copyAssets,
10
9
  getEnv,
11
10
  getWorkspaceConfig
12
- } from "./chunk-HTVMQVFT.js";
11
+ } from "./chunk-RTDGFM3J.js";
13
12
  import {
14
13
  depsCheckPlugin
15
14
  } from "./chunk-IX6DNVUR.js";
@@ -141,29 +140,23 @@ async function resolveContext(userOptions) {
141
140
  throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
142
141
  }
143
142
  const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
144
- options.name ??= `${projectName}-${options.format}`;
145
- options.target ??= DEFAULT_TARGET;
146
143
  const packageJsonPath = joinPaths(workspaceRoot.dir, options.projectRoot, "package.json");
147
144
  if (!existsSync(packageJsonPath)) {
148
145
  throw new Error("Cannot find package.json configuration");
149
146
  }
150
147
  const env = getEnv("esbuild", options);
148
+ const define = defu(options.define ?? {}, env ?? {});
151
149
  const resolvedOptions = {
150
+ name: projectName,
152
151
  ...options,
153
152
  tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
154
- distDir: "dist",
155
- name: projectName,
156
153
  metafile: userOptions.mode === "development",
157
- ...userOptions,
158
154
  clean: false,
159
- target: userOptions.target || options.target,
160
- splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
161
155
  env,
162
156
  define: {
163
157
  STORM_FORMAT: JSON.stringify(options.format),
164
- ...options.define,
165
- ...Object.keys(env || {}).reduce((res, key) => {
166
- const value = JSON.stringify(env[key]);
158
+ ...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
159
+ const value = JSON.stringify(define[key]);
167
160
  const safeKey = key.replaceAll("(", "").replaceAll(")", "");
168
161
  return {
169
162
  ...res,
@@ -205,26 +198,79 @@ async function generatePackageJson(context) {
205
198
  if (context.options.entry) {
206
199
  packageJson.exports ??= {};
207
200
  packageJson.exports["./package.json"] ??= "./package.json";
208
- packageJson.exports["."] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js`;
209
201
  const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
210
- for (const entryPoint of entryPoints) {
211
- if (context.options.entry[entryPoint]) {
212
- const entry = context.options.entry[entryPoint].replaceAll("\\", "/").replaceAll(/^(\.\/)*/g, "").replace(/\.([cm])?[jt]s(x)?$/g, "");
213
- packageJson.exports[`./${entry}`] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entry}.js`;
202
+ if (entryPoints.length > 0) {
203
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
204
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
205
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
206
+ const isDts = context.options.dts || context.options.experimentalDts;
207
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
208
+ for (const entryPoint of entryPoints) {
209
+ packageJson.exports[`./${entryPoint}`] ??= {};
210
+ if (isEsm) {
211
+ if (isDts) {
212
+ packageJson.exports[`./${entryPoint}`].import = {
213
+ types: `./dist/${entryPoint}.d.mts`,
214
+ default: `./dist/${entryPoint}.mjs`
215
+ };
216
+ } else {
217
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
218
+ }
219
+ if (isDts) {
220
+ packageJson.exports[`./${entryPoint}`].default = {
221
+ types: `./dist/${entryPoint}.d.mts`,
222
+ default: `./dist/${entryPoint}.mjs`
223
+ };
224
+ } else {
225
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
226
+ }
227
+ }
228
+ if (isCjs) {
229
+ if (isDts) {
230
+ packageJson.exports[`./${entryPoint}`].require = {
231
+ types: `./dist/${entryPoint}.d.cts`,
232
+ default: `./dist/${entryPoint}.cjs`
233
+ };
234
+ } else {
235
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
236
+ }
237
+ if (!isEsm) {
238
+ if (isDts) {
239
+ packageJson.exports[`./${entryPoint}`].default = {
240
+ types: `./dist/${entryPoint}.d.cts`,
241
+ default: `./dist/${entryPoint}.cjs`
242
+ };
243
+ } else {
244
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
245
+ }
246
+ }
247
+ }
248
+ if (!isEsm && !isCjs) {
249
+ if (isDts) {
250
+ packageJson.exports[`./${entryPoint}`].default = {
251
+ types: `./dist/${entryPoint}.d.ts`,
252
+ default: `./dist/${entryPoint}.js`
253
+ };
254
+ } else {
255
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
256
+ }
257
+ }
214
258
  }
215
- }
216
- if (context.options.format === "esm") {
217
- packageJson.module = packageJson.type === "module" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.mjs`;
218
- } else {
219
- packageJson.main = packageJson.type === "commonjs" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.cjs`;
220
- }
221
- packageJson.types = `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.d.ts`;
222
- packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
223
- if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
224
- ret[key.replace("/index", "")] = packageJson.exports[key];
259
+ if (isEsm) {
260
+ packageJson.module = `${defaultEntry}.mjs`;
261
+ } else {
262
+ packageJson.main = `${defaultEntry}.cjs`;
263
+ }
264
+ if (isDts) {
265
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
225
266
  }
226
- return ret;
227
- }, packageJson.exports);
267
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
268
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
269
+ ret[key.replace("/index", "")] = packageJson.exports[key];
270
+ }
271
+ return ret;
272
+ }, packageJson.exports);
273
+ }
228
274
  }
229
275
  await writeJsonFile(joinPaths(context.outputPath, "package.json"), packageJson);
230
276
  stopwatch();
@@ -237,7 +283,7 @@ async function executeTsup(context) {
237
283
  const stopwatch = getStopwatch(`${context.options.name} build`);
238
284
  await tsup({
239
285
  ...context.options,
240
- outDir: context.outputPath,
286
+ outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
241
287
  workspaceConfig: context.workspaceConfig
242
288
  });
243
289
  stopwatch();
@@ -51,7 +51,6 @@ var DEFAULT_COMPILED_BANNER = `/*****************************************
51
51
  *****************************************/
52
52
  `;
53
53
  var DEFAULT_ENVIRONMENT = "production";
54
- var DEFAULT_TARGET = "esnext";
55
54
  var DEFAULT_ORGANIZATION = "storm-software";
56
55
 
57
56
  // ../build-tools/src/plugins/swc.ts
@@ -878,9 +877,7 @@ var getDefaultBuildPlugins = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void
878
877
  var DEFAULT_BUILD_OPTIONS = {
879
878
  assets: [],
880
879
  platform: "node",
881
- target: [
882
- "esnext"
883
- ],
880
+ target: "node22",
884
881
  format: "esm",
885
882
  tsconfig: "tsconfig.json",
886
883
  mode: "production",
@@ -889,9 +886,11 @@ var DEFAULT_BUILD_OPTIONS = {
889
886
  keepNames: true,
890
887
  metafile: false,
891
888
  treeshake: true,
889
+ splitting: true,
892
890
  shims: false,
893
891
  watch: false,
894
892
  bundle: true,
893
+ distDir: "dist",
895
894
  loader: {
896
895
  ".aac": "file",
897
896
  ".css": "file",
@@ -927,5 +926,4 @@ var DEFAULT_BUILD_OPTIONS = {
927
926
 
928
927
 
929
928
 
930
-
931
- exports.DEFAULT_TARGET = DEFAULT_TARGET; exports.copyAssets = copyAssets; exports.addPackageDependencies = addPackageDependencies; exports.addWorkspacePackageJsonFields = addWorkspacePackageJsonFields; exports.getWorkspaceConfig = getWorkspaceConfig; exports.getEnv = getEnv; exports.getDefaultBuildPlugins = getDefaultBuildPlugins; exports.DEFAULT_BUILD_OPTIONS = DEFAULT_BUILD_OPTIONS;
929
+ exports.copyAssets = copyAssets; exports.addPackageDependencies = addPackageDependencies; exports.addWorkspacePackageJsonFields = addWorkspacePackageJsonFields; exports.getWorkspaceConfig = getWorkspaceConfig; exports.getEnv = getEnv; exports.getDefaultBuildPlugins = getDefaultBuildPlugins; exports.DEFAULT_BUILD_OPTIONS = DEFAULT_BUILD_OPTIONS;
@@ -51,7 +51,6 @@ var DEFAULT_COMPILED_BANNER = `/*****************************************
51
51
  *****************************************/
52
52
  `;
53
53
  var DEFAULT_ENVIRONMENT = "production";
54
- var DEFAULT_TARGET = "esnext";
55
54
  var DEFAULT_ORGANIZATION = "storm-software";
56
55
 
57
56
  // ../build-tools/src/plugins/swc.ts
@@ -878,9 +877,7 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name((options, context) => [
878
877
  var DEFAULT_BUILD_OPTIONS = {
879
878
  assets: [],
880
879
  platform: "node",
881
- target: [
882
- "esnext"
883
- ],
880
+ target: "node22",
884
881
  format: "esm",
885
882
  tsconfig: "tsconfig.json",
886
883
  mode: "production",
@@ -889,9 +886,11 @@ var DEFAULT_BUILD_OPTIONS = {
889
886
  keepNames: true,
890
887
  metafile: false,
891
888
  treeshake: true,
889
+ splitting: true,
892
890
  shims: false,
893
891
  watch: false,
894
892
  bundle: true,
893
+ distDir: "dist",
895
894
  loader: {
896
895
  ".aac": "file",
897
896
  ".css": "file",
@@ -920,7 +919,6 @@ var DEFAULT_BUILD_OPTIONS = {
920
919
  };
921
920
 
922
921
  export {
923
- DEFAULT_TARGET,
924
922
  copyAssets,
925
923
  addPackageDependencies,
926
924
  addWorkspacePackageJsonFields,
@@ -8,8 +8,7 @@ var _chunkY4XWI6JJcjs = require('./chunk-Y4XWI6JJ.cjs');
8
8
 
9
9
 
10
10
 
11
-
12
- var _chunkNWVUAY67cjs = require('./chunk-NWVUAY67.cjs');
11
+ var _chunkDZPLKD6Ocjs = require('./chunk-DZPLKD6O.cjs');
13
12
 
14
13
 
15
14
  var _chunkMWGFCZF4cjs = require('./chunk-MWGFCZF4.cjs');
@@ -121,7 +120,7 @@ async function resolveContext(userOptions) {
121
120
  if (!workspaceRoot) {
122
121
  throw new Error("Cannot find Nx workspace root");
123
122
  }
124
- const workspaceConfig = await _chunkNWVUAY67cjs.getWorkspaceConfig.call(void 0, true, {
123
+ const workspaceConfig = await _chunkDZPLKD6Ocjs.getWorkspaceConfig.call(void 0, true, {
125
124
  workspaceRoot: workspaceRoot.dir
126
125
  });
127
126
  _chunkY3LXNK5Ccjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", workspaceConfig);
@@ -140,30 +139,24 @@ async function resolveContext(userOptions) {
140
139
  if (!_optionalChain([projectConfigurations, 'optionalAccess', _5 => _5.projects, 'optionalAccess', _6 => _6[projectName]])) {
141
140
  throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
142
141
  }
143
- const options = _defu2.default.call(void 0, userOptions, _chunkNWVUAY67cjs.DEFAULT_BUILD_OPTIONS);
144
- options.name ??= `${projectName}-${options.format}`;
145
- options.target ??= _chunkNWVUAY67cjs.DEFAULT_TARGET;
142
+ const options = _defu2.default.call(void 0, userOptions, _chunkDZPLKD6Ocjs.DEFAULT_BUILD_OPTIONS);
146
143
  const packageJsonPath = _chunkXITTOHOGcjs.joinPaths.call(void 0, workspaceRoot.dir, options.projectRoot, "package.json");
147
144
  if (!_fs.existsSync.call(void 0, packageJsonPath)) {
148
145
  throw new Error("Cannot find package.json configuration");
149
146
  }
150
- const env = _chunkNWVUAY67cjs.getEnv.call(void 0, "esbuild", options);
147
+ const env = _chunkDZPLKD6Ocjs.getEnv.call(void 0, "esbuild", options);
148
+ const define = _defu2.default.call(void 0, _nullishCoalesce(options.define, () => ( {})), _nullishCoalesce(env, () => ( {})));
151
149
  const resolvedOptions = {
150
+ name: projectName,
152
151
  ...options,
153
152
  tsconfig: _chunkXITTOHOGcjs.joinPaths.call(void 0, projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
154
- distDir: "dist",
155
- name: projectName,
156
153
  metafile: userOptions.mode === "development",
157
- ...userOptions,
158
154
  clean: false,
159
- target: userOptions.target || options.target,
160
- splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
161
155
  env,
162
156
  define: {
163
157
  STORM_FORMAT: JSON.stringify(options.format),
164
- ...options.define,
165
- ...Object.keys(env || {}).reduce((res, key) => {
166
- const value = JSON.stringify(env[key]);
158
+ ...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
159
+ const value = JSON.stringify(define[key]);
167
160
  const safeKey = key.replaceAll("(", "").replaceAll(")", "");
168
161
  return {
169
162
  ...res,
@@ -200,31 +193,84 @@ async function generatePackageJson(context) {
200
193
  if (!packageJson) {
201
194
  throw new Error("Cannot find package.json configuration file");
202
195
  }
203
- packageJson = await _chunkNWVUAY67cjs.addPackageDependencies.call(void 0, context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
204
- packageJson = await _chunkNWVUAY67cjs.addWorkspacePackageJsonFields.call(void 0, context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
196
+ packageJson = await _chunkDZPLKD6Ocjs.addPackageDependencies.call(void 0, context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
197
+ packageJson = await _chunkDZPLKD6Ocjs.addWorkspacePackageJsonFields.call(void 0, context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
205
198
  if (context.options.entry) {
206
199
  packageJson.exports ??= {};
207
200
  packageJson.exports["./package.json"] ??= "./package.json";
208
- packageJson.exports["."] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js`;
209
201
  const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
210
- for (const entryPoint of entryPoints) {
211
- if (context.options.entry[entryPoint]) {
212
- const entry = context.options.entry[entryPoint].replaceAll("\\", "/").replaceAll(/^(\.\/)*/g, "").replace(/\.([cm])?[jt]s(x)?$/g, "");
213
- packageJson.exports[`./${entry}`] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entry}.js`;
202
+ if (entryPoints.length > 0) {
203
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
204
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
205
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
206
+ const isDts = context.options.dts || context.options.experimentalDts;
207
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
208
+ for (const entryPoint of entryPoints) {
209
+ packageJson.exports[`./${entryPoint}`] ??= {};
210
+ if (isEsm) {
211
+ if (isDts) {
212
+ packageJson.exports[`./${entryPoint}`].import = {
213
+ types: `./dist/${entryPoint}.d.mts`,
214
+ default: `./dist/${entryPoint}.mjs`
215
+ };
216
+ } else {
217
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
218
+ }
219
+ if (isDts) {
220
+ packageJson.exports[`./${entryPoint}`].default = {
221
+ types: `./dist/${entryPoint}.d.mts`,
222
+ default: `./dist/${entryPoint}.mjs`
223
+ };
224
+ } else {
225
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
226
+ }
227
+ }
228
+ if (isCjs) {
229
+ if (isDts) {
230
+ packageJson.exports[`./${entryPoint}`].require = {
231
+ types: `./dist/${entryPoint}.d.cts`,
232
+ default: `./dist/${entryPoint}.cjs`
233
+ };
234
+ } else {
235
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
236
+ }
237
+ if (!isEsm) {
238
+ if (isDts) {
239
+ packageJson.exports[`./${entryPoint}`].default = {
240
+ types: `./dist/${entryPoint}.d.cts`,
241
+ default: `./dist/${entryPoint}.cjs`
242
+ };
243
+ } else {
244
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
245
+ }
246
+ }
247
+ }
248
+ if (!isEsm && !isCjs) {
249
+ if (isDts) {
250
+ packageJson.exports[`./${entryPoint}`].default = {
251
+ types: `./dist/${entryPoint}.d.ts`,
252
+ default: `./dist/${entryPoint}.js`
253
+ };
254
+ } else {
255
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
256
+ }
257
+ }
214
258
  }
215
- }
216
- if (context.options.format === "esm") {
217
- packageJson.module = packageJson.type === "module" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.mjs`;
218
- } else {
219
- packageJson.main = packageJson.type === "commonjs" ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.cjs`;
220
- }
221
- packageJson.types = `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.d.ts`;
222
- packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
223
- if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
224
- ret[key.replace("/index", "")] = packageJson.exports[key];
259
+ if (isEsm) {
260
+ packageJson.module = `${defaultEntry}.mjs`;
261
+ } else {
262
+ packageJson.main = `${defaultEntry}.cjs`;
263
+ }
264
+ if (isDts) {
265
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
225
266
  }
226
- return ret;
227
- }, packageJson.exports);
267
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
268
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
269
+ ret[key.replace("/index", "")] = packageJson.exports[key];
270
+ }
271
+ return ret;
272
+ }, packageJson.exports);
273
+ }
228
274
  }
229
275
  await _devkit.writeJsonFile.call(void 0, _chunkXITTOHOGcjs.joinPaths.call(void 0, context.outputPath, "package.json"), packageJson);
230
276
  stopwatch();
@@ -237,7 +283,7 @@ async function executeTsup(context) {
237
283
  const stopwatch = _chunkY3LXNK5Ccjs.getStopwatch.call(void 0, `${context.options.name} build`);
238
284
  await _tsup.build.call(void 0, {
239
285
  ...context.options,
240
- outDir: context.outputPath,
286
+ outDir: context.options.distDir ? _chunkXITTOHOGcjs.joinPaths.call(void 0, context.outputPath, context.options.distDir) : context.outputPath,
241
287
  workspaceConfig: context.workspaceConfig
242
288
  });
243
289
  stopwatch();
@@ -248,7 +294,7 @@ async function copyBuildAssets(context) {
248
294
  if (_optionalChain([context, 'access', _7 => _7.result, 'optionalAccess', _8 => _8.errors, 'access', _9 => _9.length]) === 0) {
249
295
  _chunkY3LXNK5Ccjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
250
296
  const stopwatch = _chunkY3LXNK5Ccjs.getStopwatch.call(void 0, `${context.options.name} asset copy`);
251
- await _chunkNWVUAY67cjs.copyAssets.call(void 0, context.workspaceConfig, _nullishCoalesce(context.options.assets, () => ( [])), context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
297
+ await _chunkDZPLKD6Ocjs.copyAssets.call(void 0, context.workspaceConfig, _nullishCoalesce(context.options.assets, () => ( [])), context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
252
298
  stopwatch();
253
299
  }
254
300
  return context;
package/dist/config.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkNWVUAY67cjs = require('./chunk-NWVUAY67.cjs');
4
+ var _chunkDZPLKD6Ocjs = require('./chunk-DZPLKD6O.cjs');
5
5
  require('./chunk-EZGTDCYM.cjs');
6
6
  require('./chunk-S6M44SSZ.cjs');
7
7
  require('./chunk-WRBUO7H6.cjs');
@@ -15,4 +15,4 @@ require('./chunk-BGYQAVKQ.cjs');
15
15
 
16
16
 
17
17
 
18
- exports.DEFAULT_BUILD_OPTIONS = _chunkNWVUAY67cjs.DEFAULT_BUILD_OPTIONS; exports.getDefaultBuildPlugins = _chunkNWVUAY67cjs.getDefaultBuildPlugins;
18
+ exports.DEFAULT_BUILD_OPTIONS = _chunkDZPLKD6Ocjs.DEFAULT_BUILD_OPTIONS; exports.getDefaultBuildPlugins = _chunkDZPLKD6Ocjs.getDefaultBuildPlugins;
package/dist/config.d.cts CHANGED
@@ -7,6 +7,6 @@ import 'zod';
7
7
  import 'tsup';
8
8
 
9
9
  declare const getDefaultBuildPlugins: (options: ESBuildOptions, context: ESBuildContext) => esbuild.Plugin[];
10
- declare const DEFAULT_BUILD_OPTIONS: Required<Pick<ESBuildOptions, "assets" | "format" | "platform" | "target" | "tsconfig" | "mode" | "includeSrc" | "generatePackageJson" | "keepNames" | "metafile" | "treeshake" | "shims" | "watch" | "bundle" | "loader" | "banner">>;
10
+ declare const DEFAULT_BUILD_OPTIONS: Required<Pick<ESBuildOptions, "assets" | "format" | "platform" | "target" | "tsconfig" | "mode" | "includeSrc" | "generatePackageJson" | "keepNames" | "metafile" | "treeshake" | "splitting" | "shims" | "watch" | "bundle" | "loader" | "banner" | "distDir">>;
11
11
 
12
12
  export { DEFAULT_BUILD_OPTIONS, getDefaultBuildPlugins };
package/dist/config.d.ts CHANGED
@@ -7,6 +7,6 @@ import 'zod';
7
7
  import 'tsup';
8
8
 
9
9
  declare const getDefaultBuildPlugins: (options: ESBuildOptions, context: ESBuildContext) => esbuild.Plugin[];
10
- declare const DEFAULT_BUILD_OPTIONS: Required<Pick<ESBuildOptions, "assets" | "format" | "platform" | "target" | "tsconfig" | "mode" | "includeSrc" | "generatePackageJson" | "keepNames" | "metafile" | "treeshake" | "shims" | "watch" | "bundle" | "loader" | "banner">>;
10
+ declare const DEFAULT_BUILD_OPTIONS: Required<Pick<ESBuildOptions, "assets" | "format" | "platform" | "target" | "tsconfig" | "mode" | "includeSrc" | "generatePackageJson" | "keepNames" | "metafile" | "treeshake" | "splitting" | "shims" | "watch" | "bundle" | "loader" | "banner" | "distDir">>;
11
11
 
12
12
  export { DEFAULT_BUILD_OPTIONS, getDefaultBuildPlugins };
package/dist/config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_BUILD_OPTIONS,
3
3
  getDefaultBuildPlugins
4
- } from "./chunk-HTVMQVFT.js";
4
+ } from "./chunk-RTDGFM3J.js";
5
5
  import "./chunk-GWG4HOQ6.js";
6
6
  import "./chunk-T5272PC2.js";
7
7
  import "./chunk-LYDEMC26.js";
package/dist/index.cjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkCH6OII7Bcjs = require('./chunk-CH6OII7B.cjs');
10
+ var _chunkRVMQBDDKcjs = require('./chunk-RVMQBDDK.cjs');
11
11
 
12
12
 
13
13
 
@@ -15,7 +15,7 @@ var _chunkY4XWI6JJcjs = require('./chunk-Y4XWI6JJ.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkNWVUAY67cjs = require('./chunk-NWVUAY67.cjs');
18
+ var _chunkDZPLKD6Ocjs = require('./chunk-DZPLKD6O.cjs');
19
19
  require('./chunk-EZGTDCYM.cjs');
20
20
  require('./chunk-S6M44SSZ.cjs');
21
21
  require('./chunk-WRBUO7H6.cjs');
@@ -53,4 +53,4 @@ require('./chunk-BGYQAVKQ.cjs');
53
53
 
54
54
 
55
55
 
56
- exports.DEFAULT_BUILD_OPTIONS = _chunkNWVUAY67cjs.DEFAULT_BUILD_OPTIONS; exports.Filter = _chunkCH6OII7Bcjs.Filter; exports.Mapper = _chunkCH6OII7Bcjs.Mapper; exports.build = _chunkCH6OII7Bcjs.build; exports.clean = _chunkY4XWI6JJcjs.clean; exports.cleanDirectories = _chunkY4XWI6JJcjs.cleanDirectories; exports.emitDts = _chunkETTFFUNGcjs.emitDts; exports.emitDtsFiles = _chunkETTFFUNGcjs.emitDtsFiles; exports.ensureTempDeclarationDir = _chunkETTFFUNGcjs.ensureTempDeclarationDir; exports.getDefaultBuildPlugins = _chunkNWVUAY67cjs.getDefaultBuildPlugins; exports.handle = _chunkCH6OII7Bcjs.handle; exports.pipe = _chunkCH6OII7Bcjs.pipe; exports.skip = _chunkCH6OII7Bcjs.skip; exports.slash = _chunkETTFFUNGcjs.slash; exports.toAbsolutePath = _chunkETTFFUNGcjs.toAbsolutePath; exports.transduce = _chunkCH6OII7Bcjs.transduce; exports.watch = _chunkCH6OII7Bcjs.watch;
56
+ exports.DEFAULT_BUILD_OPTIONS = _chunkDZPLKD6Ocjs.DEFAULT_BUILD_OPTIONS; exports.Filter = _chunkRVMQBDDKcjs.Filter; exports.Mapper = _chunkRVMQBDDKcjs.Mapper; exports.build = _chunkRVMQBDDKcjs.build; exports.clean = _chunkY4XWI6JJcjs.clean; exports.cleanDirectories = _chunkY4XWI6JJcjs.cleanDirectories; exports.emitDts = _chunkETTFFUNGcjs.emitDts; exports.emitDtsFiles = _chunkETTFFUNGcjs.emitDtsFiles; exports.ensureTempDeclarationDir = _chunkETTFFUNGcjs.ensureTempDeclarationDir; exports.getDefaultBuildPlugins = _chunkDZPLKD6Ocjs.getDefaultBuildPlugins; exports.handle = _chunkRVMQBDDKcjs.handle; exports.pipe = _chunkRVMQBDDKcjs.pipe; exports.skip = _chunkRVMQBDDKcjs.skip; exports.slash = _chunkETTFFUNGcjs.slash; exports.toAbsolutePath = _chunkETTFFUNGcjs.toAbsolutePath; exports.transduce = _chunkRVMQBDDKcjs.transduce; exports.watch = _chunkRVMQBDDKcjs.watch;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  skip,
8
8
  transduce,
9
9
  watch
10
- } from "./chunk-L6SPT5J7.js";
10
+ } from "./chunk-7A6JPBG7.js";
11
11
  import {
12
12
  clean,
13
13
  cleanDirectories
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  DEFAULT_BUILD_OPTIONS,
17
17
  getDefaultBuildPlugins
18
- } from "./chunk-HTVMQVFT.js";
18
+ } from "./chunk-RTDGFM3J.js";
19
19
  import "./chunk-GWG4HOQ6.js";
20
20
  import "./chunk-T5272PC2.js";
21
21
  import "./chunk-LYDEMC26.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/esbuild",
3
- "version": "0.33.7",
3
+ "version": "0.34.1",
4
4
  "type": "module",
5
5
  "description": "A package containing `esbuild` utilities for building Storm Software libraries and applications",
6
6
  "repository": {