@storm-software/esbuild 0.33.6 → 0.34.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/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.5-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.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)
25
25
 
26
26
  <!-- prettier-ignore-start -->
27
27
  <!-- markdownlint-disable -->
@@ -40,7 +40,6 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
40
40
 
41
41
  <!-- START doctoc -->
42
42
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
43
-
44
43
  ## Table of Contents
45
44
 
46
45
  - [Storm ESBuild Package](#storm-esbuild-package)
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",
@@ -83,6 +81,7 @@ var DEFAULT_BUILD_OPTIONS = {
83
81
  shims: false,
84
82
  watch: false,
85
83
  bundle: true,
84
+ distDir: "dist",
86
85
  loader: {
87
86
  ".aac": "file",
88
87
  ".css": "file",
@@ -228,22 +227,17 @@ async function resolveContext(userOptions) {
228
227
  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
228
  }
230
229
  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
230
  const packageJsonPath = (0, import_correct_paths.joinPaths)(workspaceRoot.dir, options.projectRoot, "package.json");
234
231
  if (!(0, import_node_fs.existsSync)(packageJsonPath)) {
235
232
  throw new Error("Cannot find package.json configuration");
236
233
  }
237
234
  const env = (0, import_build_tools2.getEnv)("esbuild", options);
238
235
  const resolvedOptions = {
236
+ name: projectName,
239
237
  ...options,
240
238
  tsconfig: (0, import_correct_paths.joinPaths)(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
241
- distDir: "dist",
242
- name: projectName,
243
239
  metafile: userOptions.mode === "development",
244
- ...userOptions,
245
240
  clean: false,
246
- target: userOptions.target || options.target,
247
241
  splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
248
242
  env,
249
243
  define: {
@@ -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 _chunkE5AAO2PHcjs = require('./chunk-E5AAO2PH.cjs');
5
5
  require('./chunk-Y4XWI6JJ.cjs');
6
- require('./chunk-NWVUAY67.cjs');
6
+ require('./chunk-AXEZCHZS.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 = _chunkE5AAO2PHcjs.build; exports.watch = _chunkE5AAO2PHcjs.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-X6OXFNDR.js";
5
5
  import "./chunk-35YNFZCF.js";
6
- import "./chunk-HTVMQVFT.js";
6
+ import "./chunk-KGKL7VDG.js";
7
7
  import "./chunk-GWG4HOQ6.js";
8
8
  import "./chunk-T5272PC2.js";
9
9
  import "./chunk-LYDEMC26.js";
@@ -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",
@@ -892,6 +889,7 @@ var DEFAULT_BUILD_OPTIONS = {
892
889
  shims: false,
893
890
  watch: false,
894
891
  bundle: true,
892
+ distDir: "dist",
895
893
  loader: {
896
894
  ".aac": "file",
897
895
  ".css": "file",
@@ -927,5 +925,4 @@ var DEFAULT_BUILD_OPTIONS = {
927
925
 
928
926
 
929
927
 
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;
928
+ 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;
@@ -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 _chunkAXEZCHZScjs = require('./chunk-AXEZCHZS.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 _chunkAXEZCHZScjs.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,23 +139,18 @@ 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, _chunkAXEZCHZScjs.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 = _chunkAXEZCHZScjs.getEnv.call(void 0, "esbuild", options);
151
148
  const resolvedOptions = {
149
+ name: projectName,
152
150
  ...options,
153
151
  tsconfig: _chunkXITTOHOGcjs.joinPaths.call(void 0, projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
154
- distDir: "dist",
155
- name: projectName,
156
152
  metafile: userOptions.mode === "development",
157
- ...userOptions,
158
153
  clean: false,
159
- target: userOptions.target || options.target,
160
154
  splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
161
155
  env,
162
156
  define: {
@@ -200,31 +194,84 @@ async function generatePackageJson(context) {
200
194
  if (!packageJson) {
201
195
  throw new Error("Cannot find package.json configuration file");
202
196
  }
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);
197
+ packageJson = await _chunkAXEZCHZScjs.addPackageDependencies.call(void 0, context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
198
+ packageJson = await _chunkAXEZCHZScjs.addWorkspacePackageJsonFields.call(void 0, context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
205
199
  if (context.options.entry) {
206
200
  packageJson.exports ??= {};
207
201
  packageJson.exports["./package.json"] ??= "./package.json";
208
- packageJson.exports["."] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js`;
209
202
  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`;
203
+ if (entryPoints.length > 0) {
204
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
205
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
206
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
207
+ const isDts = context.options.dts || context.options.experimentalDts;
208
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
209
+ for (const entryPoint of entryPoints) {
210
+ packageJson.exports[`./${entryPoint}`] ??= {};
211
+ if (isEsm) {
212
+ if (isDts) {
213
+ packageJson.exports[`./${entryPoint}`].import = {
214
+ types: `./dist/${entryPoint}.d.mts`,
215
+ default: `./dist/${entryPoint}.mjs`
216
+ };
217
+ } else {
218
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
219
+ }
220
+ if (isDts) {
221
+ packageJson.exports[`./${entryPoint}`].default = {
222
+ types: `./dist/${entryPoint}.d.mts`,
223
+ default: `./dist/${entryPoint}.mjs`
224
+ };
225
+ } else {
226
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
227
+ }
228
+ }
229
+ if (isCjs) {
230
+ if (isDts) {
231
+ packageJson.exports[`./${entryPoint}`].require = {
232
+ types: `./dist/${entryPoint}.d.cts`,
233
+ default: `./dist/${entryPoint}.cjs`
234
+ };
235
+ } else {
236
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
237
+ }
238
+ if (!isEsm) {
239
+ if (isDts) {
240
+ packageJson.exports[`./${entryPoint}`].default = {
241
+ types: `./dist/${entryPoint}.d.cts`,
242
+ default: `./dist/${entryPoint}.cjs`
243
+ };
244
+ } else {
245
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
246
+ }
247
+ }
248
+ }
249
+ if (!isEsm && !isCjs) {
250
+ if (isDts) {
251
+ packageJson.exports[`./${entryPoint}`].default = {
252
+ types: `./dist/${entryPoint}.d.ts`,
253
+ default: `./dist/${entryPoint}.js`
254
+ };
255
+ } else {
256
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
257
+ }
258
+ }
214
259
  }
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];
260
+ if (isEsm) {
261
+ packageJson.module = `${defaultEntry}.mjs`;
262
+ } else {
263
+ packageJson.main = `${defaultEntry}.cjs`;
264
+ }
265
+ if (isDts) {
266
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
225
267
  }
226
- return ret;
227
- }, packageJson.exports);
268
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
269
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
270
+ ret[key.replace("/index", "")] = packageJson.exports[key];
271
+ }
272
+ return ret;
273
+ }, packageJson.exports);
274
+ }
228
275
  }
229
276
  await _devkit.writeJsonFile.call(void 0, _chunkXITTOHOGcjs.joinPaths.call(void 0, context.outputPath, "package.json"), packageJson);
230
277
  stopwatch();
@@ -237,7 +284,7 @@ async function executeTsup(context) {
237
284
  const stopwatch = _chunkY3LXNK5Ccjs.getStopwatch.call(void 0, `${context.options.name} build`);
238
285
  await _tsup.build.call(void 0, {
239
286
  ...context.options,
240
- outDir: context.outputPath,
287
+ outDir: context.options.distDir ? _chunkXITTOHOGcjs.joinPaths.call(void 0, context.outputPath, context.options.distDir) : context.outputPath,
241
288
  workspaceConfig: context.workspaceConfig
242
289
  });
243
290
  stopwatch();
@@ -248,7 +295,7 @@ async function copyBuildAssets(context) {
248
295
  if (_optionalChain([context, 'access', _7 => _7.result, 'optionalAccess', _8 => _8.errors, 'access', _9 => _9.length]) === 0) {
249
296
  _chunkY3LXNK5Ccjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
250
297
  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);
298
+ await _chunkAXEZCHZScjs.copyAssets.call(void 0, context.workspaceConfig, _nullishCoalesce(context.options.assets, () => ( [])), context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
252
299
  stopwatch();
253
300
  }
254
301
  return context;
@@ -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",
@@ -892,6 +889,7 @@ var DEFAULT_BUILD_OPTIONS = {
892
889
  shims: false,
893
890
  watch: false,
894
891
  bundle: true,
892
+ distDir: "dist",
895
893
  loader: {
896
894
  ".aac": "file",
897
895
  ".css": "file",
@@ -920,7 +918,6 @@ var DEFAULT_BUILD_OPTIONS = {
920
918
  };
921
919
 
922
920
  export {
923
- DEFAULT_TARGET,
924
921
  copyAssets,
925
922
  addPackageDependencies,
926
923
  addWorkspacePackageJsonFields,
@@ -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-KGKL7VDG.js";
13
12
  import {
14
13
  depsCheckPlugin
15
14
  } from "./chunk-IX6DNVUR.js";
@@ -141,22 +140,17 @@ 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);
151
148
  const resolvedOptions = {
149
+ name: projectName,
152
150
  ...options,
153
151
  tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
154
- distDir: "dist",
155
- name: projectName,
156
152
  metafile: userOptions.mode === "development",
157
- ...userOptions,
158
153
  clean: false,
159
- target: userOptions.target || options.target,
160
154
  splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
161
155
  env,
162
156
  define: {
@@ -205,26 +199,79 @@ async function generatePackageJson(context) {
205
199
  if (context.options.entry) {
206
200
  packageJson.exports ??= {};
207
201
  packageJson.exports["./package.json"] ??= "./package.json";
208
- packageJson.exports["."] ??= `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index.js`;
209
202
  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`;
203
+ if (entryPoints.length > 0) {
204
+ const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
205
+ const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
206
+ const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
207
+ const isDts = context.options.dts || context.options.experimentalDts;
208
+ packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
209
+ for (const entryPoint of entryPoints) {
210
+ packageJson.exports[`./${entryPoint}`] ??= {};
211
+ if (isEsm) {
212
+ if (isDts) {
213
+ packageJson.exports[`./${entryPoint}`].import = {
214
+ types: `./dist/${entryPoint}.d.mts`,
215
+ default: `./dist/${entryPoint}.mjs`
216
+ };
217
+ } else {
218
+ packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
219
+ }
220
+ if (isDts) {
221
+ packageJson.exports[`./${entryPoint}`].default = {
222
+ types: `./dist/${entryPoint}.d.mts`,
223
+ default: `./dist/${entryPoint}.mjs`
224
+ };
225
+ } else {
226
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
227
+ }
228
+ }
229
+ if (isCjs) {
230
+ if (isDts) {
231
+ packageJson.exports[`./${entryPoint}`].require = {
232
+ types: `./dist/${entryPoint}.d.cts`,
233
+ default: `./dist/${entryPoint}.cjs`
234
+ };
235
+ } else {
236
+ packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
237
+ }
238
+ if (!isEsm) {
239
+ if (isDts) {
240
+ packageJson.exports[`./${entryPoint}`].default = {
241
+ types: `./dist/${entryPoint}.d.cts`,
242
+ default: `./dist/${entryPoint}.cjs`
243
+ };
244
+ } else {
245
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
246
+ }
247
+ }
248
+ }
249
+ if (!isEsm && !isCjs) {
250
+ if (isDts) {
251
+ packageJson.exports[`./${entryPoint}`].default = {
252
+ types: `./dist/${entryPoint}.d.ts`,
253
+ default: `./dist/${entryPoint}.js`
254
+ };
255
+ } else {
256
+ packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
257
+ }
258
+ }
214
259
  }
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];
260
+ if (isEsm) {
261
+ packageJson.module = `${defaultEntry}.mjs`;
262
+ } else {
263
+ packageJson.main = `${defaultEntry}.cjs`;
264
+ }
265
+ if (isDts) {
266
+ packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
225
267
  }
226
- return ret;
227
- }, packageJson.exports);
268
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
269
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
270
+ ret[key.replace("/index", "")] = packageJson.exports[key];
271
+ }
272
+ return ret;
273
+ }, packageJson.exports);
274
+ }
228
275
  }
229
276
  await writeJsonFile(joinPaths(context.outputPath, "package.json"), packageJson);
230
277
  stopwatch();
@@ -237,7 +284,7 @@ async function executeTsup(context) {
237
284
  const stopwatch = getStopwatch(`${context.options.name} build`);
238
285
  await tsup({
239
286
  ...context.options,
240
- outDir: context.outputPath,
287
+ outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
241
288
  workspaceConfig: context.workspaceConfig
242
289
  });
243
290
  stopwatch();
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 _chunkAXEZCHZScjs = require('./chunk-AXEZCHZS.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 = _chunkAXEZCHZScjs.DEFAULT_BUILD_OPTIONS; exports.getDefaultBuildPlugins = _chunkAXEZCHZScjs.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" | "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" | "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-KGKL7VDG.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 _chunkE5AAO2PHcjs = require('./chunk-E5AAO2PH.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 _chunkAXEZCHZScjs = require('./chunk-AXEZCHZS.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 = _chunkAXEZCHZScjs.DEFAULT_BUILD_OPTIONS; exports.Filter = _chunkE5AAO2PHcjs.Filter; exports.Mapper = _chunkE5AAO2PHcjs.Mapper; exports.build = _chunkE5AAO2PHcjs.build; exports.clean = _chunkY4XWI6JJcjs.clean; exports.cleanDirectories = _chunkY4XWI6JJcjs.cleanDirectories; exports.emitDts = _chunkETTFFUNGcjs.emitDts; exports.emitDtsFiles = _chunkETTFFUNGcjs.emitDtsFiles; exports.ensureTempDeclarationDir = _chunkETTFFUNGcjs.ensureTempDeclarationDir; exports.getDefaultBuildPlugins = _chunkAXEZCHZScjs.getDefaultBuildPlugins; exports.handle = _chunkE5AAO2PHcjs.handle; exports.pipe = _chunkE5AAO2PHcjs.pipe; exports.skip = _chunkE5AAO2PHcjs.skip; exports.slash = _chunkETTFFUNGcjs.slash; exports.toAbsolutePath = _chunkETTFFUNGcjs.toAbsolutePath; exports.transduce = _chunkE5AAO2PHcjs.transduce; exports.watch = _chunkE5AAO2PHcjs.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-X6OXFNDR.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-KGKL7VDG.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.6",
3
+ "version": "0.34.0",
4
4
  "type": "module",
5
5
  "description": "A package containing `esbuild` utilities for building Storm Software libraries and applications",
6
6
  "repository": {