@storm-software/esbuild 0.1.0 → 0.3.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.
Files changed (69) hide show
  1. package/dist/build.cjs +11 -10
  2. package/dist/build.cjs.map +1 -0
  3. package/dist/build.d.cts +5 -3
  4. package/dist/build.d.ts +5 -3
  5. package/dist/build.js +10 -9
  6. package/dist/build.js.map +1 -0
  7. package/dist/{chunk-A6CGWMV7.cjs → chunk-263L44RM.cjs} +12 -26
  8. package/dist/chunk-263L44RM.cjs.map +1 -0
  9. package/dist/chunk-437F3SFI.js +24 -0
  10. package/dist/chunk-437F3SFI.js.map +1 -0
  11. package/dist/{chunk-WLHWKRZB.cjs → chunk-BF5W6GVP.cjs} +5 -4
  12. package/dist/chunk-BF5W6GVP.cjs.map +1 -0
  13. package/dist/{chunk-YGD5JBOH.js → chunk-CMEDJ4L4.js} +98 -83
  14. package/dist/chunk-CMEDJ4L4.js.map +1 -0
  15. package/dist/{chunk-PCGRI6Z6.js → chunk-CMWXE5MF.js} +5 -6
  16. package/dist/chunk-CMWXE5MF.js.map +1 -0
  17. package/dist/{chunk-NVGEXPTG.cjs → chunk-D5PRB2E2.cjs} +1 -0
  18. package/dist/chunk-D5PRB2E2.cjs.map +1 -0
  19. package/dist/{chunk-3C3PXJUM.cjs → chunk-DFGHPRBD.cjs} +4 -3
  20. package/dist/chunk-DFGHPRBD.cjs.map +1 -0
  21. package/dist/{chunk-ELGZJRET.js → chunk-DRRPNILS.js} +1 -0
  22. package/dist/chunk-DRRPNILS.js.map +1 -0
  23. package/dist/chunk-J34FQYKV.cjs +24 -0
  24. package/dist/chunk-J34FQYKV.cjs.map +1 -0
  25. package/dist/{chunk-5JHKW6MG.js → chunk-KJ7ZHAFS.js} +6 -20
  26. package/dist/chunk-KJ7ZHAFS.js.map +1 -0
  27. package/dist/{chunk-MTKAAECG.cjs → chunk-KVBDKVBU.cjs} +7 -8
  28. package/dist/chunk-KVBDKVBU.cjs.map +1 -0
  29. package/dist/chunk-MUYXFAKB.cjs +1 -0
  30. package/dist/chunk-MUYXFAKB.cjs.map +1 -0
  31. package/dist/{chunk-DCWECOOS.cjs → chunk-MVLEDP7K.cjs} +5 -6
  32. package/dist/chunk-MVLEDP7K.cjs.map +1 -0
  33. package/dist/{chunk-5S2XTAF2.cjs → chunk-PBHOTQGA.cjs} +116 -101
  34. package/dist/chunk-PBHOTQGA.cjs.map +1 -0
  35. package/dist/chunk-QNDLJ2W7.js +1 -0
  36. package/dist/chunk-QNDLJ2W7.js.map +1 -0
  37. package/dist/{chunk-4TW4ZA3I.js → chunk-TTHABTDU.js} +2 -1
  38. package/dist/chunk-TTHABTDU.js.map +1 -0
  39. package/dist/{chunk-3GQAWCBQ.js → chunk-WCQVDF3K.js} +1 -0
  40. package/dist/chunk-WCQVDF3K.js.map +1 -0
  41. package/dist/{chunk-BGYQAVKQ.cjs → chunk-WGEGR3DF.cjs} +1 -0
  42. package/dist/chunk-WGEGR3DF.cjs.map +1 -0
  43. package/dist/{chunk-RKSGVSXZ.js → chunk-X5TLV7MF.js} +4 -5
  44. package/dist/chunk-X5TLV7MF.js.map +1 -0
  45. package/dist/{chunk-LVDPGHWK.js → chunk-YQBU3FSL.js} +2 -1
  46. package/dist/chunk-YQBU3FSL.js.map +1 -0
  47. package/dist/config.cjs +4 -3
  48. package/dist/config.cjs.map +1 -0
  49. package/dist/config.d.cts +2 -0
  50. package/dist/config.d.ts +2 -0
  51. package/dist/config.js +3 -2
  52. package/dist/config.js.map +1 -0
  53. package/dist/index.cjs +12 -17
  54. package/dist/index.cjs.map +1 -0
  55. package/dist/index.d.cts +4 -18
  56. package/dist/index.d.ts +4 -18
  57. package/dist/index.js +12 -17
  58. package/dist/index.js.map +1 -0
  59. package/dist/types.cjs +2 -1
  60. package/dist/types.cjs.map +1 -0
  61. package/dist/types.d.cts +1169 -1
  62. package/dist/types.d.ts +1169 -1
  63. package/dist/types.js +2 -1
  64. package/dist/types.js.map +1 -0
  65. package/package.json +13 -6
  66. package/dist/chunk-GGNOJ77I.js +0 -0
  67. package/dist/chunk-RJQ3LCGJ.cjs +0 -14
  68. package/dist/chunk-SFZRYJZ2.cjs +0 -1
  69. package/dist/chunk-YIAZ64WG.js +0 -14
@@ -1,38 +1,38 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkDCWECOOScjs = require('./chunk-DCWECOOS.cjs');
3
+ var _chunkBF5W6GVPcjs = require('./chunk-BF5W6GVP.cjs');
4
4
 
5
5
 
6
- var _chunkWLHWKRZBcjs = require('./chunk-WLHWKRZB.cjs');
6
+ var _chunk263L44RMcjs = require('./chunk-263L44RM.cjs');
7
7
 
8
8
 
9
- var _chunkA6CGWMV7cjs = require('./chunk-A6CGWMV7.cjs');
9
+ var _chunkD5PRB2E2cjs = require('./chunk-D5PRB2E2.cjs');
10
10
 
11
11
 
12
- var _chunkNVGEXPTGcjs = require('./chunk-NVGEXPTG.cjs');
12
+ var _chunkKVBDKVBUcjs = require('./chunk-KVBDKVBU.cjs');
13
13
 
14
14
 
15
- var _chunkMTKAAECGcjs = require('./chunk-MTKAAECG.cjs');
15
+ var _chunkJ34FQYKVcjs = require('./chunk-J34FQYKV.cjs');
16
16
 
17
17
 
18
- var _chunkRJQ3LCGJcjs = require('./chunk-RJQ3LCGJ.cjs');
18
+ var _chunkDFGHPRBDcjs = require('./chunk-DFGHPRBD.cjs');
19
19
 
20
20
 
21
- var _chunk3C3PXJUMcjs = require('./chunk-3C3PXJUM.cjs');
21
+ var _chunkMVLEDP7Kcjs = require('./chunk-MVLEDP7K.cjs');
22
22
 
23
23
 
24
- var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
24
+ var _chunkWGEGR3DFcjs = require('./chunk-WGEGR3DF.cjs');
25
25
 
26
26
  // src/build.ts
27
27
  var _node = require('@humanfs/node');
28
28
  var _devkit = require('@nx/devkit');
29
- var _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils');
29
+ var _buildtools = require('@storm-software/build-tools');
30
+ var _configtools = require('@storm-software/config-tools');
30
31
  var _chokidar = require('chokidar');
31
32
  var _estoolkit = require('es-toolkit');
32
33
  var _compat = require('es-toolkit/compat');
33
34
  var _esbuild = require('esbuild'); var esbuild = _interopRequireWildcard(_esbuild);
34
35
  var _globby = require('globby');
35
- var _fs = require('fs');
36
36
  var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
37
37
 
38
38
  // src/utilities/helpers.ts
@@ -43,7 +43,7 @@ function handleSync(fn) {
43
43
  return error_;
44
44
  }
45
45
  }
46
- _chunkBGYQAVKQcjs.__name.call(void 0, handleSync, "handleSync");
46
+ _chunkWGEGR3DFcjs.__name.call(void 0, handleSync, "handleSync");
47
47
  async function handleAsync(fn) {
48
48
  try {
49
49
  return await fn();
@@ -51,7 +51,7 @@ async function handleAsync(fn) {
51
51
  return error_;
52
52
  }
53
53
  }
54
- _chunkBGYQAVKQcjs.__name.call(void 0, handleAsync, "handleAsync");
54
+ _chunkWGEGR3DFcjs.__name.call(void 0, handleAsync, "handleAsync");
55
55
  var handle = handleSync;
56
56
  handle.async = handleAsync;
57
57
  var skip = Symbol("skip");
@@ -65,7 +65,7 @@ function transduceSync(list, transformer) {
65
65
  }
66
66
  return transduced;
67
67
  }
68
- _chunkBGYQAVKQcjs.__name.call(void 0, transduceSync, "transduceSync");
68
+ _chunkWGEGR3DFcjs.__name.call(void 0, transduceSync, "transduceSync");
69
69
  async function transduceAsync(list, transformer) {
70
70
  const transduced = [];
71
71
  await Promise.all(list.entries().map(async ([i, element_]) => {
@@ -76,11 +76,11 @@ async function transduceAsync(list, transformer) {
76
76
  }));
77
77
  return transduced;
78
78
  }
79
- _chunkBGYQAVKQcjs.__name.call(void 0, transduceAsync, "transduceAsync");
80
- var Filter = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (filter) => (item) => {
79
+ _chunkWGEGR3DFcjs.__name.call(void 0, transduceAsync, "transduceAsync");
80
+ var Filter = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (filter) => (item) => {
81
81
  return filter(item) ? item : skip;
82
82
  }, "Filter");
83
- var Mapper = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (mapper) => (item) => {
83
+ var Mapper = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (mapper) => (item) => {
84
84
  return mapper(item);
85
85
  }, "Mapper");
86
86
  var transduce = transduceSync;
@@ -94,7 +94,7 @@ function pipeSync(fn, ...fns) {
94
94
  return result;
95
95
  };
96
96
  }
97
- _chunkBGYQAVKQcjs.__name.call(void 0, pipeSync, "pipeSync");
97
+ _chunkWGEGR3DFcjs.__name.call(void 0, pipeSync, "pipeSync");
98
98
  function pipeAsync(fn, ...fns) {
99
99
  return async (...args) => {
100
100
  let result = await fn(...args);
@@ -104,12 +104,12 @@ function pipeAsync(fn, ...fns) {
104
104
  return result;
105
105
  };
106
106
  }
107
- _chunkBGYQAVKQcjs.__name.call(void 0, pipeAsync, "pipeAsync");
107
+ _chunkWGEGR3DFcjs.__name.call(void 0, pipeAsync, "pipeAsync");
108
108
  var pipe = pipeSync;
109
109
  pipe.async = pipeAsync;
110
110
 
111
111
  // src/build.ts
112
- var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (options) => {
112
+ var resolveOptions = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, async (options) => {
113
113
  const projectRoot = options.projectRoot;
114
114
  const workspaceRoot = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot);
115
115
  if (!workspaceRoot) {
@@ -132,8 +132,10 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
132
132
  if (!_optionalChain([projectConfigurations, 'optionalAccess', _5 => _5.projects, 'optionalAccess', _6 => _6[projectName]])) {
133
133
  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.");
134
134
  }
135
+ const config = await _configtools.loadStormConfig.call(void 0, workspaceRoot.dir);
135
136
  return {
136
- ..._chunkNVGEXPTGcjs.DEFAULT_BUILD_OPTIONS,
137
+ ..._chunkD5PRB2E2cjs.DEFAULT_BUILD_OPTIONS,
138
+ config,
137
139
  format: "cjs",
138
140
  outExtension: {
139
141
  ".js": ".js"
@@ -143,23 +145,22 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
143
145
  ".js",
144
146
  ".node"
145
147
  ],
146
- entryPoints: _globby.globbySync.call(void 0, "./src/**/*.{j,t}s", {
147
- ignore: [
148
- "./src/__tests__/**/*"
149
- ]
150
- }),
151
148
  mainFields: [
152
149
  "module",
153
150
  "main"
154
151
  ],
155
152
  ...options,
153
+ entryPoints: options.entryPoints || [
154
+ "./src/index.ts"
155
+ ],
156
156
  outdir: options.outdir || _devkit.joinPathFragments.call(void 0, workspaceRoot.dir, "dist", projectRoot),
157
157
  plugins: [
158
158
  ..._nullishCoalesce(options.plugins, () => ( [])),
159
- _chunkWLHWKRZBcjs.resolvePathsPlugin,
160
- _chunk3C3PXJUMcjs.fixImportsPlugin,
161
- _chunkA6CGWMV7cjs.tscPlugin.call(void 0, options.emitTypes),
162
- _chunkDCWECOOScjs.onErrorPlugin
159
+ _chunkBF5W6GVPcjs.resolvePathsPlugin,
160
+ _chunkDFGHPRBDcjs.fixImportsPlugin,
161
+ _chunkJ34FQYKVcjs.esmSplitCodeToCjsPlugin,
162
+ _chunk263L44RMcjs.tscPlugin.call(void 0, options.emitTypes),
163
+ _chunkMVLEDP7Kcjs.onErrorPlugin
163
164
  ],
164
165
  external: [
165
166
  ..._nullishCoalesce(options.external, () => ( []))
@@ -168,69 +169,55 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
168
169
  projectConfigurations,
169
170
  projectName,
170
171
  projectGraph,
171
- workspaceRoot
172
+ workspaceRoot,
173
+ sourceRoot: options.sourceRoot || _devkit.joinPathFragments.call(void 0, workspaceRoot.dir, projectRoot, "src")
172
174
  };
173
175
  }, "resolveOptions");
174
- var generatePackageJson = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (options) => {
175
- const nxJsonPath = _devkit.joinPathFragments.call(void 0, options.workspaceRoot.dir, "nx.json");
176
- if (!await _node.hfs.isFile(nxJsonPath)) {
177
- throw new Error("Cannot find Nx workspace configuration");
178
- }
179
- const projectJsonPath = _devkit.joinPathFragments.call(void 0, options.workspaceRoot.dir, options.projectRoot, "project.json");
180
- if (!await _node.hfs.isFile(projectJsonPath)) {
181
- throw new Error("Cannot find project.json configuration");
182
- }
183
- if (!_optionalChain([options, 'access', _7 => _7.projectConfigurations, 'optionalAccess', _8 => _8.projects, 'optionalAccess', _9 => _9[options.projectName]])) {
184
- 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.");
185
- }
186
- const packageJsonPath = _devkit.joinPathFragments.call(void 0, options.projectRoot, "project.json");
187
- if (!await _node.hfs.isFile(packageJsonPath)) {
188
- throw new Error("Cannot find package.json configuration");
189
- }
190
- const packageJson = await _node.hfs.json(_devkit.joinPathFragments.call(void 0, options.workspaceRoot.dir, options.projectRoot, "package.json"));
191
- const projectDependencies = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, options.projectGraph, options.workspaceRoot.dir, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
192
- const localPackages = projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== options.projectRoot && dep.node.data.root !== options.workspaceRoot.dir).reduce((ret, project) => {
193
- const projectNode = project.node;
194
- if (projectNode.data.root) {
195
- const projectPackageJsonPath = _devkit.joinPathFragments.call(void 0, options.workspaceRoot.dir, projectNode.data.root, "package.json");
196
- if (_fs.existsSync.call(void 0, projectPackageJsonPath)) {
197
- const projectPackageJson = _devkit.readJsonFile.call(void 0, projectPackageJsonPath);
198
- if (projectPackageJson.private !== false) {
199
- ret.push(projectPackageJson);
200
- }
201
- }
176
+ var generatePackageJson = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, async (options) => {
177
+ if (options.generatePackageJson !== false && await _node.hfs.isFile(_devkit.joinPathFragments.call(void 0, options.projectRoot, "package.json"))) {
178
+ _configtools.writeDebug.call(void 0, "\u270D\uFE0F Writing package.json file", options.config);
179
+ const packageJsonPath = _devkit.joinPathFragments.call(void 0, options.projectRoot, "project.json");
180
+ if (!await _node.hfs.isFile(packageJsonPath)) {
181
+ throw new Error("Cannot find package.json configuration");
202
182
  }
203
- return ret;
204
- }, []);
205
- if (localPackages.length > 0) {
206
- _chunkRJQ3LCGJcjs.writeLog.call(void 0, "trace", `\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
207
- packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
208
- if (!ret[localPackage.name]) {
209
- ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
210
- }
211
- return ret;
212
- }, _nullishCoalesce(packageJson.peerDependencies, () => ( {})));
213
- packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
214
- if (!ret[localPackage.name]) {
215
- ret[localPackage.name] = {
216
- optional: false
217
- };
183
+ let packageJson = await _node.hfs.json(_devkit.joinPathFragments.call(void 0, options.workspaceRoot.dir, options.projectRoot, "package.json"));
184
+ if (!packageJson) {
185
+ throw new Error("Cannot find package.json configuration file");
186
+ }
187
+ packageJson = await _buildtools.addPackageDependencies.call(void 0, options.workspaceRoot.dir, options.projectRoot, options.projectName, packageJson);
188
+ packageJson = await _buildtools.addWorkspacePackageJsonFields.call(void 0, options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
189
+ let entryPoints = [
190
+ {
191
+ in: "./src/index.ts",
192
+ out: "./src/index.ts"
218
193
  }
219
- return ret;
220
- }, _nullishCoalesce(packageJson.peerDependenciesMeta, () => ( {})));
221
- packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
222
- if (!ret[localPackage.name]) {
223
- ret[localPackage.name] = localPackage.version || "0.0.1";
194
+ ];
195
+ if (options.entryPoints) {
196
+ if (Array.isArray(options.entryPoints)) {
197
+ entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
198
+ in: entryPoint,
199
+ out: entryPoint
200
+ } : entryPoint);
201
+ } else {
202
+ entryPoints = Object.entries(options.entryPoints).map(([key, value]) => ({
203
+ in: key,
204
+ out: value
205
+ }));
224
206
  }
225
- return ret;
226
- }, _nullishCoalesce(packageJson.peerDependencies, () => ( {})));
227
- } else {
228
- _chunkRJQ3LCGJcjs.writeLog.call(void 0, "trace", "\u{1F4E6} No local packages dependencies to add to package.json");
207
+ }
208
+ for (const entryPoint of entryPoints) {
209
+ const split = entryPoint.out.split(".");
210
+ split.pop();
211
+ const entry = split.join(".").replaceAll("\\", "/");
212
+ packageJson.exports[`./${entry}`] ??= _buildtools.addPackageJsonExport.call(void 0, entry);
213
+ }
214
+ packageJson.exports["./package.json"] ??= "./package.json";
215
+ packageJson.exports["."] ??= _buildtools.addPackageJsonExport.call(void 0, "./src/index.ts");
216
+ packageJson.main = "./dist/index.cjs";
217
+ packageJson.module = "./dist/index.js";
218
+ packageJson.types = "./dist/index.d.ts";
219
+ await _devkit.writeJsonFile.call(void 0, _devkit.joinPathFragments.call(void 0, options.outdir, "package.json"), packageJson);
229
220
  }
230
- packageJson.main = "./dist/index.cjs";
231
- packageJson.module = "./dist/index.mjs";
232
- packageJson.types = "./dist/index.d.ts";
233
- await _devkit.writeJsonFile.call(void 0, _devkit.joinPathFragments.call(void 0, options.outdir, "package.json"), packageJson);
234
221
  return options;
235
222
  }, "generatePackageJson");
236
223
  async function createOptions(options) {
@@ -239,12 +226,13 @@ async function createOptions(options) {
239
226
  () => resolveOptions(options2)
240
227
  ])));
241
228
  }
242
- _chunkBGYQAVKQcjs.__name.call(void 0, createOptions, "createOptions");
229
+ _chunkWGEGR3DFcjs.__name.call(void 0, createOptions, "createOptions");
243
230
  async function computeOptions(options) {
244
231
  return options();
245
232
  }
246
- _chunkBGYQAVKQcjs.__name.call(void 0, computeOptions, "computeOptions");
233
+ _chunkWGEGR3DFcjs.__name.call(void 0, computeOptions, "computeOptions");
247
234
  async function executeEsBuild(options) {
235
+ const stopwatch = _configtools.getStopwatch.call(void 0, `${options.name} build`);
248
236
  if (process.env.WATCH === "true") {
249
237
  const context2 = await esbuild.context(_estoolkit.omit.call(void 0, options, [
250
238
  "name",
@@ -253,21 +241,41 @@ async function executeEsBuild(options) {
253
241
  ]));
254
242
  watch(context2, options);
255
243
  }
256
- const build3 = await esbuild.build(_estoolkit.omit.call(void 0, options, [
244
+ const result = await esbuild.build(_estoolkit.omit.call(void 0, options, [
257
245
  "name",
258
246
  "emitTypes",
259
247
  "emitMetafile"
260
248
  ]));
261
- if (build3.metafile && options.emitMetafile) {
249
+ if (result.metafile && options.emitMetafile) {
262
250
  const metafilePath = `${options.outdir}/${options.name}.meta.json`;
263
- await _node.hfs.write(metafilePath, JSON.stringify(build3.metafile));
251
+ await _node.hfs.write(metafilePath, JSON.stringify(result.metafile));
264
252
  }
253
+ stopwatch();
265
254
  return [
266
255
  options,
267
- build3
256
+ result
268
257
  ];
269
258
  }
270
- _chunkBGYQAVKQcjs.__name.call(void 0, executeEsBuild, "executeEsBuild");
259
+ _chunkWGEGR3DFcjs.__name.call(void 0, executeEsBuild, "executeEsBuild");
260
+ async function copyBuildAssets([options, result]) {
261
+ if (result.errors.length === 0) {
262
+ await _buildtools.copyAssets.call(void 0, options.config, _nullishCoalesce(options.assets, () => ( [])), options.outdir, options.projectRoot, options.projectName, options.sourceRoot, true, false);
263
+ }
264
+ return [
265
+ options,
266
+ result
267
+ ];
268
+ }
269
+ _chunkWGEGR3DFcjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
270
+ async function reportResults([options, result]) {
271
+ if (result.errors.length === 0) {
272
+ if (result.warnings.length > 0) {
273
+ _configtools.writeWarning.call(void 0, `The following warnings occurred during the build: ${result.warnings.map((warning) => warning.text).join("\n")}`, options.config);
274
+ }
275
+ _configtools.writeSuccess.call(void 0, `The ${options.name} build completed successfully`, options.config);
276
+ }
277
+ }
278
+ _chunkWGEGR3DFcjs.__name.call(void 0, reportResults, "reportResults");
271
279
  async function dependencyCheck(options) {
272
280
  if (process.env.DEV === "true") return void 0;
273
281
  if (process.env.CI && !process.env.BUILDKITE) return void 0;
@@ -286,20 +294,26 @@ async function dependencyCheck(options) {
286
294
  write: false,
287
295
  outdir: "out",
288
296
  plugins: [
289
- _chunkMTKAAECGcjs.depsCheckPlugin.call(void 0, options.bundle)
297
+ _chunkKVBDKVBUcjs.depsCheckPlugin.call(void 0, options.bundle)
290
298
  ]
291
299
  });
292
300
  await buildPromise.catch(() => {
293
301
  });
294
302
  return void 0;
295
303
  }
296
- _chunkBGYQAVKQcjs.__name.call(void 0, dependencyCheck, "dependencyCheck");
304
+ _chunkWGEGR3DFcjs.__name.call(void 0, dependencyCheck, "dependencyCheck");
297
305
  async function build2(options) {
298
- void transduce.async(options, dependencyCheck);
299
- return transduce.async(await createOptions(options), pipe.async(computeOptions, generatePackageJson, executeEsBuild));
306
+ const stopwatch = _configtools.getStopwatch.call(void 0, "full build");
307
+ try {
308
+ void transduce.async(options, dependencyCheck);
309
+ await transduce.async(await createOptions(options), pipe.async(computeOptions, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
310
+ } catch (error) {
311
+ _configtools.writeFatal.call(void 0, "Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
312
+ }
313
+ stopwatch();
300
314
  }
301
- _chunkBGYQAVKQcjs.__name.call(void 0, build2, "build");
302
- var watch = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (context2, options) => {
315
+ _chunkWGEGR3DFcjs.__name.call(void 0, build2, "build");
316
+ var watch = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (context2, options) => {
303
317
  if (process.env.WATCH !== "true") return context2;
304
318
  const config = {
305
319
  ignoreInitial: true,
@@ -318,9 +332,9 @@ var watch = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (context2, opt
318
332
  return context2.rebuild();
319
333
  });
320
334
  if (rebuildResult instanceof Error) {
321
- _chunkRJQ3LCGJcjs.writeLog.call(void 0, "error", rebuildResult.message);
335
+ _configtools.writeError.call(void 0, rebuildResult.message);
322
336
  }
323
- _chunkRJQ3LCGJcjs.writeLog.call(void 0, "log", `${Date.now() - timeBefore}ms [${_nullishCoalesce(options.name, () => ( ""))}]`);
337
+ _configtools.writeTrace.call(void 0, `${Date.now() - timeBefore}ms [${_nullishCoalesce(options.name, () => ( ""))}]`);
324
338
  }, 10);
325
339
  changeWatcher.on("change", fastRebuild);
326
340
  return void 0;
@@ -335,3 +349,4 @@ var watch = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (context2, opt
335
349
 
336
350
 
337
351
  exports.handle = handle; exports.skip = skip; exports.Filter = Filter; exports.Mapper = Mapper; exports.transduce = transduce; exports.pipe = pipe; exports.build = build2;
352
+ //# sourceMappingURL=chunk-PBHOTQGA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-PBHOTQGA.cjs","../src/build.ts","../src/utilities/helpers.ts"],"names":["handleSync","fn","error_","handleAsync","handle","async","skip","Symbol","transduceSync","list","transformer","transduced","i","element_","entries","transformed","length","transduceAsync","Promise","all","map","Filter","filter","item","Mapper","mapper","transduce","pipeSync","fns","args","result","pipeAsync","pipe","resolveOptions","options","projectRoot","workspaceRoot","findWorkspaceRoot","Error","nxJsonPath","joinPathFragments","dir","hfs","isFile","projectGraph","createProjectGraphAsync","exitOnError","projectJsonPath","projectJson","json","projectName","name","projectConfigurations","readProjectsConfigurationFromProjectGraph","projects","config","loadStormConfig","DEFAULT_BUILD_OPTIONS","format","outExtension","resolveExtensions","mainFields","entryPoints","outdir","plugins","resolvePathsPlugin","fixImportsPlugin","esmSplitCodeToCjsPlugin","tscPlugin","emitTypes","onErrorPlugin","external","sourceRoot","generatePackageJson","writeDebug","packageJsonPath","packageJson","in","out","Array","split","writeJsonFile","flatten","createOptions","computeOptions","stopwatch","process","context","metafilePath","executeEsBuild","copyAssets","copyBuildAssets","writeWarning","writeSuccess","reportResults","buildPromise","ignore","gitignore","logLevel","bundle","depsCheckPlugin","undefined","dependencyCheck","error","writeFatal","build","watch","ignoreInitial","useFsEvents","ignored","changeWatcher","fastRebuild","timeBefore","rebuildResult","writeError","writeTrace"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACRA,qCAAoB;AACpB,oCAKO;AACP,yDAKO;AACP,2DASO;AACP,oCAAuC;AACvC,uCAAwC;AACxC,2CAAoB;AACpB,mFAAyB;AAEzB,gCAA2B;AAC3B,qEAAkC;ADVlC;AACA;AEpBA,SAASA,UAAAA,CAA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IML,EAAAA;AAA0B,EAAA;AAEzBM,EAAAA;AACT;AA3BeC;AAmCf;AACQjB,EAAAA;AAEF,EAAA;AACG3D,IAAAA;AAECA,IAAAA;AAUC6E,EAAAA;AACPC,IAAAA;AAGF,EAAA;AAEAnB,EAAAA;AACF;AAvBsBoB;AAgChBC;AACApB,EAAAA;AAGE/B,EAAAA;AACJoD,IAAAA;AACAC,IAAAA;AACAC,IAAAA;AAAU,MAAA;AAAwB,MAAA;ADzG3B,IAAA;AC0GT,EAAA;AAGMC,EAAAA;AAA+B,IAAA;AAAevD,EAAAA;AAG9CwD,EAAAA;AACEC,IAAAA;AAGAC,IAAAA;AACJ,MAAA;AACF,IAAA;AAEIA,IAAAA;AACFC,MAAAA;AACF,IAAA;AAEAC,IAAAA;AACC,EAAA;AAEHL,EAAAA;AAEOT,EAAAA;AA/BK;ADhFH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-PBHOTQGA.cjs","sourcesContent":[null,"/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport { hfs } from \"@humanfs/node\";\nimport {\n createProjectGraphAsync,\n joinPathFragments,\n readProjectsConfigurationFromProjectGraph,\n writeJsonFile\n} from \"@nx/devkit\";\nimport {\n addPackageDependencies,\n addPackageJsonExport,\n addWorkspacePackageJsonFields,\n copyAssets\n} from \"@storm-software/build-tools\";\nimport {\n getStopwatch,\n loadStormConfig,\n writeDebug,\n writeError,\n writeFatal,\n writeSuccess,\n writeTrace,\n writeWarning\n} from \"@storm-software/config-tools\";\nimport { watch as createWatcher } from \"chokidar\";\nimport { debounce, flatten, omit } from \"es-toolkit\";\nimport { map } from \"es-toolkit/compat\";\nimport * as esbuild from \"esbuild\";\nimport { BuildContext } from \"esbuild\";\nimport { globbySync } from \"globby\";\nimport { findWorkspaceRoot } from \"nx/src/utils/find-workspace-root\";\nimport { DEFAULT_BUILD_OPTIONS } from \"./config\";\nimport { depsCheckPlugin } from \"./plugins/deps-check\";\nimport { esmSplitCodeToCjsPlugin } from \"./plugins/esm-split-code-to-cjs\";\nimport { fixImportsPlugin } from \"./plugins/fix-imports\";\nimport { onErrorPlugin } from \"./plugins/on-error\";\nimport { resolvePathsPlugin } from \"./plugins/resolve-paths\";\nimport { tscPlugin } from \"./plugins/tsc\";\nimport { ESBuildResolvedOptions, type ESBuildOptions } from \"./types\";\nimport { handle, pipe, transduce } from \"./utilities/helpers\";\n\n/**\n * Apply defaults to the original build options\n *\n * @param options - the original build options\n * @returns the build options with defaults applied\n */\nconst resolveOptions = async (\n options: ESBuildOptions\n): Promise<ESBuildResolvedOptions> => {\n const projectRoot = options.projectRoot;\n\n const workspaceRoot = findWorkspaceRoot(projectRoot);\n if (!workspaceRoot) {\n throw new Error(\"Cannot find Nx workspace root\");\n }\n\n const nxJsonPath = joinPathFragments(workspaceRoot.dir, \"nx.json\");\n if (!(await hfs.isFile(nxJsonPath))) {\n throw new Error(\"Cannot find Nx workspace configuration\");\n }\n\n const projectGraph = await createProjectGraphAsync({\n exitOnError: true\n });\n\n const projectJsonPath = joinPathFragments(\n workspaceRoot.dir,\n projectRoot,\n \"project.json\"\n );\n if (!(await hfs.isFile(projectJsonPath))) {\n throw new Error(\"Cannot find project.json configuration\");\n }\n\n const projectJson = await hfs.json(projectJsonPath);\n const projectName = projectJson.name;\n\n const projectConfigurations =\n readProjectsConfigurationFromProjectGraph(projectGraph);\n if (!projectConfigurations?.projects?.[projectName]) {\n throw new Error(\n \"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.\"\n );\n }\n\n const config = await loadStormConfig(workspaceRoot.dir);\n\n return {\n ...DEFAULT_BUILD_OPTIONS,\n config,\n format: \"cjs\",\n outExtension: { \".js\": \".js\" },\n resolveExtensions: [\".ts\", \".js\", \".node\"],\n mainFields: [\"module\", \"main\"],\n ...options,\n entryPoints: options.entryPoints || [\"./src/index.ts\"],\n outdir:\n options.outdir ||\n joinPathFragments(workspaceRoot.dir, \"dist\", projectRoot),\n plugins: [\n ...(options.plugins ?? []),\n resolvePathsPlugin,\n fixImportsPlugin,\n esmSplitCodeToCjsPlugin,\n tscPlugin(options.emitTypes),\n onErrorPlugin\n ],\n external: [...(options.external ?? [])],\n name: `${options.name || projectName}-${options.format || \"cjs\"}`,\n projectConfigurations,\n projectName,\n projectGraph,\n workspaceRoot,\n sourceRoot:\n options.sourceRoot ||\n joinPathFragments(workspaceRoot.dir, projectRoot, \"src\")\n };\n};\n\nconst generatePackageJson = async (options: ESBuildResolvedOptions) => {\n if (\n options.generatePackageJson !== false &&\n (await hfs.isFile(joinPathFragments(options.projectRoot, \"package.json\")))\n ) {\n writeDebug(\"✍️ Writing package.json file\", options.config);\n\n const packageJsonPath = joinPathFragments(\n options.projectRoot,\n \"project.json\"\n );\n if (!(await hfs.isFile(packageJsonPath))) {\n throw new Error(\"Cannot find package.json configuration\");\n }\n\n let packageJson = await hfs.json(\n joinPathFragments(\n options.workspaceRoot.dir,\n options.projectRoot,\n \"package.json\"\n )\n );\n if (!packageJson) {\n throw new Error(\"Cannot find package.json configuration file\");\n }\n\n packageJson = await addPackageDependencies(\n options.workspaceRoot.dir,\n options.projectRoot,\n options.projectName,\n packageJson\n );\n\n packageJson = await addWorkspacePackageJsonFields(\n options.config,\n options.projectRoot,\n options.sourceRoot,\n options.projectName,\n false,\n packageJson\n );\n\n let entryPoints = [{ in: \"./src/index.ts\", out: \"./src/index.ts\" }];\n if (options.entryPoints) {\n if (Array.isArray(options.entryPoints)) {\n entryPoints = (\n options.entryPoints as (string | { in: string; out: string })[]\n ).map(entryPoint =>\n typeof entryPoint === \"string\"\n ? { in: entryPoint, out: entryPoint }\n : entryPoint\n );\n } else {\n entryPoints = Object.entries(options.entryPoints).map(\n ([key, value]) => ({\n in: key,\n out: value\n })\n );\n }\n }\n\n for (const entryPoint of entryPoints) {\n const split = entryPoint.out.split(\".\");\n split.pop();\n const entry = split.join(\".\").replaceAll(\"\\\\\", \"/\");\n\n packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry);\n }\n\n packageJson.exports[\"./package.json\"] ??= \"./package.json\";\n packageJson.exports[\".\"] ??= addPackageJsonExport(\"./src/index.ts\");\n\n packageJson.main = \"./dist/index.cjs\";\n packageJson.module = \"./dist/index.js\";\n packageJson.types = \"./dist/index.d.ts\";\n\n await writeJsonFile(\n joinPathFragments(options.outdir, \"package.json\"),\n packageJson\n );\n }\n\n return options;\n};\n\n/**\n * Create two deferred builds for esm and cjs. The one follows the other:\n * - 1. The code gets compiled to an optimized tree-shaken esm output\n * - 2. We take that output and compile it to an optimized cjs output\n *\n * @param options - the original build options\n * @returns if options = [a, b], we get [a-esm, a-cjs, b-esm, b-cjs]\n */\nasync function createOptions(options: ESBuildOptions[]) {\n return flatten(\n await Promise.all(\n map(options, options => [\n // we defer it so that we don't trigger glob immediately\n () => resolveOptions(options)\n ])\n )\n );\n}\n\n/**\n * We only want to trigger the glob search once we are ready, and that is when\n * the previous build has finished. We get the build options from the deferred.\n */\nasync function computeOptions(\n options: () => Promise<ESBuildResolvedOptions>\n): Promise<ESBuildResolvedOptions> {\n return options();\n}\n\n// /**\n// * Extensions are not automatically by esbuild set for `options.outfile`. We\n// * look at the set `options.outExtension` and we add that to `options.outfile`.\n// */\n// function addExtensionFormat(options: ESBuildOptions) {\n// if (options.outfile && options.outExtension) {\n// const ext = options.outExtension[\".js\"];\n\n// options.outfile = `${options.outfile}${ext}`;\n// }\n\n// return options;\n// }\n\n// /**\n// * If we don't have `options.outfile`, we default `options.outdir`\n// */\n// function addDefaultOutDir(options: ESBuildOptions) {\n// if (options.outfile === undefined) {\n// options.outdir = getOutDir(options);\n// }\n\n// return options;\n// }\n\n/**\n * Execute esbuild with all the configurations we pass\n */\nasync function executeEsBuild(options: ESBuildResolvedOptions) {\n const stopwatch = getStopwatch(`${options.name} build`);\n\n if (process.env.WATCH === \"true\") {\n const context = await esbuild.context(\n omit(options, [\"name\", \"emitTypes\", \"emitMetafile\"]) as any\n );\n\n watch(context, options);\n }\n\n const result = await esbuild.build(\n omit(options, [\"name\", \"emitTypes\", \"emitMetafile\"]) as any\n );\n\n if (result.metafile && options.emitMetafile) {\n const metafilePath = `${options.outdir}/${options.name}.meta.json`;\n await hfs.write(metafilePath, JSON.stringify(result.metafile));\n }\n\n stopwatch();\n\n return [options, result] as const;\n}\n\n/**\n * Copy the assets to the build directory\n */\nasync function copyBuildAssets([options, result]: [\n ESBuildResolvedOptions,\n esbuild.BuildResult\n]) {\n if (result.errors.length === 0) {\n await copyAssets(\n options.config,\n options.assets ?? [],\n options.outdir,\n options.projectRoot,\n options.projectName,\n options.sourceRoot,\n true,\n false\n );\n }\n\n return [options, result] as const;\n}\n\n/**\n * Report the results of the build\n */\nasync function reportResults([options, result]: [\n ESBuildResolvedOptions,\n esbuild.BuildResult\n]) {\n if (result.errors.length === 0) {\n if (result.warnings.length > 0) {\n writeWarning(\n `The following warnings occurred during the build: ${result.warnings\n .map(warning => warning.text)\n .join(\"\\n\")}`,\n options.config\n );\n }\n\n writeSuccess(\n `The ${options.name} build completed successfully`,\n options.config\n );\n }\n}\n\n/**\n * A blank esbuild run to do an analysis of our deps\n */\nasync function dependencyCheck(options: ESBuildResolvedOptions) {\n // we only check our dependencies for a full build\n if (process.env.DEV === \"true\") return undefined;\n // Only run on test and publish pipelines on Buildkite\n // Meaning we skip on GitHub Actions\n // Because it's slow and runs for each job, during setup, making each job slower\n if (process.env.CI && !process.env.BUILDKITE) return undefined;\n\n // we need to bundle everything to do the analysis\n const buildPromise = esbuild.build({\n entryPoints: globbySync(\"**/*.{j,t}s\", {\n // We don't check dependencies in ecosystem tests because tests are isolated from the build.\n ignore: [\"./src/__tests__/**/*\", \"./tests/e2e/**/*\", \"./dist/**/*\"],\n gitignore: true\n }),\n logLevel: \"silent\", // there will be errors\n bundle: true, // we bundle to get everything\n write: false, // no need to write for analysis\n outdir: \"out\",\n plugins: [depsCheckPlugin(options.bundle)]\n });\n\n // we absolutely don't care if it has any errors\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n await buildPromise.catch(() => {});\n\n return undefined;\n}\n\n/**\n * Execution pipeline that applies a set of actions\n *\n * @param options - the build options\n * @returns the build result\n */\nexport async function build(options: ESBuildOptions[]) {\n const stopwatch = getStopwatch(\"full build\");\n\n try {\n void transduce.async(options, dependencyCheck);\n\n await transduce.async(\n await createOptions(options),\n pipe.async(\n computeOptions,\n generatePackageJson,\n executeEsBuild,\n copyBuildAssets,\n reportResults\n )\n );\n } catch (error) {\n writeFatal(\n \"Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.\"\n );\n }\n\n stopwatch();\n}\n\n/**\n * Executes the build and rebuilds what is necessary\n *\n * @param context - the build context\n * @param options - the build options\n * @returns the build result\n */\nconst watch = (context: BuildContext, options: ESBuildResolvedOptions) => {\n if (process.env.WATCH !== \"true\") return context;\n\n // common chokidar options for the watchers\n const config = {\n ignoreInitial: true,\n useFsEvents: true,\n ignored: [\"./src/__tests__/**/*\", \"./package.json\"]\n };\n\n // prepare the incremental builds watcher\n const changeWatcher = createWatcher([\"./src/**/*\"], config);\n\n // triggers quick rebuild on file change\n const fastRebuild = debounce(async () => {\n const timeBefore = Date.now();\n\n // we handle possible rebuild exceptions\n const rebuildResult = await handle.async(() => {\n return context.rebuild();\n });\n\n if (rebuildResult instanceof Error) {\n writeError(rebuildResult.message);\n }\n\n writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? \"\"}]`);\n }, 10);\n\n changeWatcher.on(\"change\", fastRebuild);\n\n return undefined;\n};\n\n// Utils ::::::::::::::::::::::::::::::::::::::::::::::::::\n\n// get the current project externals this helps to mark dependencies as external\n// by having convention in the package.json (dev = bundled, non-dev = external)\n// function getProjectExternals(options: ESBuildOptions) {\n// const pkg = require(`${process.cwd()}/package.json`);\n// const peerDeps = Object.keys(pkg.peerDependencies ?? {});\n// const regDeps = Object.keys(pkg.dependencies ?? {});\n\n// // when bundling, only the devDeps will be bundled\n// if (!process.env.IGNORE_EXTERNALS && options.bundle === true) {\n// return [...new Set([...peerDeps, ...regDeps])];\n// }\n\n// // otherwise, all the dependencies will be bundled\n// return [];\n// }\n","/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nfunction handleSync<R, E = Error>(fn: () => R): R | E {\n try {\n return fn();\n } catch (error_: unknown) {\n return error_ as E;\n }\n}\n\nasync function handleAsync<R, E = Error>(\n fn: () => Promise<R> | R\n): Promise<R | E> {\n try {\n return await fn();\n } catch (error_: unknown) {\n return error_ as E;\n }\n}\n\n/**\n * Executes a function, catches exceptions, and returns any outcome.\n * @param fn - to be executed\n */\nconst handle = handleSync as typeof handleSync & {\n async: typeof handleAsync;\n};\n\nhandle.async = handleAsync;\n\nexport { handle };\n\nconst skip = Symbol(\"skip\");\n\ntype SyncTransformer<I, R> = (item: I, key: number) => R | typeof skip;\ntype ASyncTransformer<I, R> = (\n item: I,\n key: number\n) => Promise<R | typeof skip>;\n\nfunction transduceSync<I, R>(\n list: Array<I>,\n transformer: SyncTransformer<I, R>\n) {\n const transduced = [] as R[];\n\n for (const [i, element_] of list.entries()) {\n const transformed = transformer(element_, i);\n\n if (transformed !== skip) {\n transduced[transduced.length] = transformed;\n }\n }\n\n return transduced;\n}\n\nasync function transduceAsync<I, R>(\n list: Array<I>,\n transformer: ASyncTransformer<I, R>\n) {\n const transduced = [] as R[];\n\n await Promise.all(\n list.entries().map(async ([i, element_]) => {\n const transformed = await transformer(element_, i);\n\n if (transformed !== skip) {\n transduced[transduced.length] = transformed;\n }\n })\n );\n\n return transduced;\n}\n\nconst Filter =\n <I>(filter: (item: I) => boolean) =>\n (item: I) => {\n return filter(item) ? item : (skip as never);\n };\n\nconst Mapper =\n <I, R>(mapper: (item: I) => R) =>\n (item: I) => {\n return mapper(item);\n };\n\n/**\n * Transducers enable efficient data processing. They allow the composition of\n * mappers and filters to be applied on a list. And this is applied in a single\n * pass, that's the efficient pipeline processing.\n *\n * (does not reduce at the same time)\n *\n * @see https://medium.com/javascript-scene/7985330fe73d\n *\n * @param list - to transform\n * @param transformer - to apply\n\n * @example\n * ```ts\n * const filterEven = Filter(<U>(unit: U) =>\n * typeof unit === 'number' ? !(unit % 2) : true,\n * )\n * const mapTimes2 = Mapper(<U>(unit: U) =>\n * typeof unit === 'number' ? unit * 2 : unit,\n * )\n * const mapString = Mapper(<U>(unit: U) => `${unit}`)\n *\n * const test0 = transduce(\n * [1, 2, 3, 4, 5, 6, 7, 'a'],\n * pipe(filterEven, mapTimes2, mapTimes2, mapString, filterEven),\n * )\n * ```\n */\nconst transduce = transduceSync as typeof transduceSync & {\n async: typeof transduceAsync;\n};\n\ntransduce.async = transduceAsync;\n\nexport { Filter, Mapper, skip, transduce };\n\ntype FunctionLike<P extends Array<any> = any, R = any> = (...args: P) => R;\ntype Await<P> = P extends Promise<infer A> ? A : P;\n\nfunction pipeSync(fn: FunctionLike, ...fns: FunctionLike[]) {\n return (...args: unknown[]) => {\n let result = fn(...args);\n\n for (let i = 0; result !== skip && i < fns.length; ++i) {\n result = fns[i]?.(result);\n }\n\n return result;\n };\n}\n\nfunction pipeAsync(fn: FunctionLike, ...fns: FunctionLike[]) {\n return async (...args: unknown[]) => {\n let result = await fn(...args);\n\n for (let i = 0; result !== skip && i < fns.length; ++i) {\n // eslint-disable-next-line no-await-in-loop\n result = await fns[i]?.(result);\n }\n\n return result;\n };\n}\n\n/**\n * Pipe the input and output of functions.\n *\n * @param fn - parameter-taking function\n * @param fns - subsequent piped functions\n * @returns\n */\nconst pipe = pipeSync as PipeMultiSync & {\n async: PipeMultiAsync;\n};\n\npipe.async = pipeAsync;\n\n// TODO: use the one from ts-toolbelt (broken atm since ts 4.1)\nexport declare type PipeMultiSync = {\n <R0, P extends any[]>(...fns: [FunctionLike<P, R0>]): FunctionLike<P, R0>;\n <R0, R1, P extends any[]>(\n ...fns: [FunctionLike<P, R0>, FunctionLike<[R0], R1>]\n ): FunctionLike<P, R1>;\n <R0, R1, R2, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>\n ]\n ): FunctionLike<P, R2>;\n <R0, R1, R2, R3, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>\n ]\n ): FunctionLike<P, R3>;\n <R0, R1, R2, R3, R4, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>\n ]\n ): FunctionLike<P, R4>;\n <R0, R1, R2, R3, R4, R5, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>\n ]\n ): FunctionLike<P, R5>;\n <R0, R1, R2, R3, R4, R5, R6, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>\n ]\n ): FunctionLike<P, R6>;\n <R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>\n ]\n ): FunctionLike<P, R7>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>,\n FunctionLike<[R7], R8>\n ]\n ): FunctionLike<P, R8>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>,\n FunctionLike<[R7], R8>,\n FunctionLike<[R8], R9>\n ]\n ): FunctionLike<P, R9>;\n};\n\nexport declare type PipeMultiAsync = {\n <R0, P extends any[]>(\n ...fns: [FunctionLike<P, R0>]\n ): FunctionLike<P, Promise<Await<R0>>>;\n <R0, R1, P extends any[]>(\n ...fns: [FunctionLike<P, R0>, FunctionLike<[Await<R0>], R1>]\n ): FunctionLike<P, Promise<Await<R1>>>;\n <R0, R1, R2, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>\n ]\n ): FunctionLike<P, Promise<Await<R2>>>;\n <R0, R1, R2, R3, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>\n ]\n ): FunctionLike<P, Promise<Await<R3>>>;\n <R0, R1, R2, R3, R4, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>\n ]\n ): FunctionLike<P, Promise<Await<R4>>>;\n <R0, R1, R2, R3, R4, R5, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>\n ]\n ): FunctionLike<P, Promise<Await<R5>>>;\n <R0, R1, R2, R3, R4, R5, R6, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>\n ]\n ): FunctionLike<P, Promise<Await<R6>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>\n ]\n ): FunctionLike<P, Promise<Await<R7>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>,\n FunctionLike<[Await<R7>], R8>\n ]\n ): FunctionLike<P, Promise<Await<R8>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>,\n FunctionLike<[Await<R7>], R8>,\n FunctionLike<[Await<R8>], R9>\n ]\n ): FunctionLike<P, Promise<Await<R9>>>;\n};\n\nexport { pipe };\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-QNDLJ2W7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __name,
3
3
  __require
4
- } from "./chunk-3GQAWCBQ.js";
4
+ } from "./chunk-WCQVDF3K.js";
5
5
 
6
6
  // src/plugins/resolve-paths.ts
7
7
  import path from "node:path";
@@ -50,3 +50,4 @@ var resolvePathsPlugin = {
50
50
  export {
51
51
  resolvePathsPlugin
52
52
  };
53
+ //# sourceMappingURL=chunk-TTHABTDU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/resolve-paths.ts"],"sourcesContent":["/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport type * as esbuild from \"esbuild\";\nimport path from \"node:path\";\n\ntype TsConfig = {\n compilerOptions?: {\n paths?: Record<string, string[]>;\n };\n extends?: string;\n};\n\n/**\n * Recursive function to resolve the paths config from a tsconfig.json, whether\n * it is in the config directly or via an inherited config (via \"extends\").\n * @param options\n * @param cwd\n * @returns\n */\nfunction resolvePathsConfig(options: TsConfig, cwd: string) {\n if (options?.compilerOptions?.paths) {\n const paths = Object.entries(options.compilerOptions.paths);\n\n const resolvedPaths = paths.map(([key, paths]) => {\n return [key, paths.map(v => path.resolve(cwd, v))] as const;\n });\n\n return Object.fromEntries(resolvedPaths);\n }\n\n if (options.extends) {\n const extendsPath = path.resolve(cwd, options.extends);\n const extendsDir = path.dirname(extendsPath);\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const extendsConfig = require(extendsPath);\n\n return resolvePathsConfig(extendsConfig, extendsDir);\n }\n\n return [];\n}\n\n/**\n * Forces `esbuild` to always use the TS compiler paths, even when we are\n * bundling a local dependency of a local dependency, ensuring maximum\n * tree-shaking. Note: `esbuild` has some support for this, though it is limited\n * in the amount of dependency nesting it supports.\n */\nexport const resolvePathsPlugin: esbuild.Plugin = {\n name: \"storm:resolve-paths\",\n setup(build) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parentTsConfig = require(\n `${process.cwd()}/${build.initialOptions.tsconfig}`\n );\n const resolvedTsPaths = resolvePathsConfig(parentTsConfig, process.cwd());\n const packagesRegex = new RegExp(\n `^(${Object.keys(resolvedTsPaths).join(\"|\")})$`\n );\n\n build.onResolve({ filter: packagesRegex }, args => {\n if (build.initialOptions.external?.includes(args.path)) {\n return { path: args.path, external: true };\n }\n\n return { path: `${resolvedTsPaths[args.path][0]}/index.ts` };\n });\n }\n};\n"],"mappings":";;;;;;AAkBA,OAAOA,UAAU;AAgBjB,SAASC,mBAAmBC,SAAmBC,KAAW;AACxD,MAAID,SAASE,iBAAiBC,OAAO;AACnC,UAAMA,QAAQC,OAAOC,QAAQL,QAAQE,gBAAgBC,KAAK;AAE1D,UAAMG,gBAAgBH,MAAMI,IAAI,CAAC,CAACC,KAAKL,MAAAA,MAAM;AAC3C,aAAO;QAACK;QAAKL,OAAMI,IAAIE,CAAAA,MAAKC,KAAKC,QAAQV,KAAKQ,CAAAA,CAAAA;;IAChD,CAAA;AAEA,WAAOL,OAAOQ,YAAYN,aAAAA;EAC5B;AAEA,MAAIN,QAAQa,SAAS;AACnB,UAAMC,cAAcJ,KAAKC,QAAQV,KAAKD,QAAQa,OAAO;AACrD,UAAME,aAAaL,KAAKM,QAAQF,WAAAA;AAEhC,UAAMG,gBAAgBC,UAAQJ,WAAAA;AAE9B,WAAOf,mBAAmBkB,eAAeF,UAAAA;EAC3C;AAEA,SAAO,CAAA;AACT;AArBShB;AA6BF,IAAMoB,qBAAqC;EAChDC,MAAM;EACNC,MAAMC,OAAK;AAET,UAAMC,iBAAiBL,UACrB,GAAGM,QAAQvB,IAAG,CAAA,IAAMqB,MAAMG,eAAeC,QAAQ,EAAE;AAErD,UAAMC,kBAAkB5B,mBAAmBwB,gBAAgBC,QAAQvB,IAAG,CAAA;AACtE,UAAM2B,gBAAgB,IAAIC,OACxB,KAAKzB,OAAO0B,KAAKH,eAAAA,EAAiBI,KAAK,GAAA,CAAA,IAAQ;AAGjDT,UAAMU,UAAU;MAAEC,QAAQL;IAAc,GAAGM,CAAAA,SAAAA;AACzC,UAAIZ,MAAMG,eAAeU,UAAUC,SAASF,KAAKxB,IAAI,GAAG;AACtD,eAAO;UAAEA,MAAMwB,KAAKxB;UAAMyB,UAAU;QAAK;MAC3C;AAEA,aAAO;QAAEzB,MAAM,GAAGiB,gBAAgBO,KAAKxB,IAAI,EAAE,CAAA,CAAE;MAAY;IAC7D,CAAA;EACF;AACF;","names":["path","resolvePathsConfig","options","cwd","compilerOptions","paths","Object","entries","resolvedPaths","map","key","v","path","resolve","fromEntries","extends","extendsPath","extendsDir","dirname","extendsConfig","require","resolvePathsPlugin","name","setup","build","parentTsConfig","process","initialOptions","tsconfig","resolvedTsPaths","packagesRegex","RegExp","keys","join","onResolve","filter","args","external","includes"]}
@@ -11,3 +11,4 @@ export {
11
11
  __name,
12
12
  __require
13
13
  };
14
+ //# sourceMappingURL=chunk-WCQVDF3K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -11,3 +11,4 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
11
11
 
12
12
 
13
13
  exports.__name = __name; exports.__require = __require;
14
+ //# sourceMappingURL=chunk-WGEGR3DF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-WGEGR3DF.cjs"],"names":[],"mappings":"AAAA,6EAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;AACxF,IAAI,UAAU,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,QAAQ,IAAI,YAAY,EAAE,QAAQ,EAAE,OAAO,MAAM,IAAI,YAAY,EAAE,IAAI,KAAK,CAAC,CAAC,EAAE;AAC/H,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,QAAQ,IAAI,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE;AACpB,EAAE,GAAG,CAAC,OAAO,QAAQ,IAAI,WAAW,EAAE,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;AAC3E,EAAE,MAAM,KAAK,CAAC,uBAAuB,EAAE,EAAE,EAAE,oBAAoB,CAAC;AAChE,CAAC,CAAC;AACF;AACA;AACE;AACA;AACF,uDAAC","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-WGEGR3DF.cjs"}
@@ -1,15 +1,13 @@
1
- import {
2
- writeLog
3
- } from "./chunk-YIAZ64WG.js";
4
-
5
1
  // src/plugins/on-error.ts
2
+ import { writeError } from "@storm-software/config-tools";
6
3
  var onErrorPlugin = {
7
4
  name: "storm:on-error",
8
5
  setup(build) {
9
6
  build.onEnd((result) => {
10
7
  if (result.errors.length > 0 && process.env.WATCH !== "true") {
11
- writeLog("error", `The following errors occurred during the build:
8
+ writeError(`The following errors occurred during the build:
12
9
  ${result.errors.map((error) => error.text).join("\n")}
10
+
13
11
  `);
14
12
  throw new Error("ESBuild process failed with errors.");
15
13
  }
@@ -20,3 +18,4 @@ ${result.errors.map((error) => error.text).join("\n")}
20
18
  export {
21
19
  onErrorPlugin
22
20
  };
21
+ //# sourceMappingURL=chunk-X5TLV7MF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/on-error.ts"],"sourcesContent":["/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport { writeError } from \"@storm-software/config-tools\";\nimport type * as esbuild from \"esbuild\";\n\n/**\n * Causes esbuild to exit immediately with an error code.\n */\nexport const onErrorPlugin: esbuild.Plugin = {\n name: \"storm:on-error\",\n setup(build) {\n build.onEnd(result => {\n // if there were errors found on the build\n if (result.errors.length > 0 && process.env.WATCH !== \"true\") {\n writeError(\n `The following errors occurred during the build:\n${result.errors.map(error => error.text).join(\"\\n\")}\n\n`\n );\n\n throw new Error(\"ESBuild process failed with errors.\");\n }\n });\n }\n};\n"],"mappings":";AAiBA,SAASA,kBAAkB;AAMpB,IAAMC,gBAAgC;EAC3CC,MAAM;EACNC,MAAMC,OAAK;AACTA,UAAMC,MAAMC,CAAAA,WAAAA;AAEV,UAAIA,OAAOC,OAAOC,SAAS,KAAKC,QAAQC,IAAIC,UAAU,QAAQ;AAC5DX,mBACE;EACRM,OAAOC,OAAOK,IAAIC,CAAAA,UAASA,MAAMC,IAAI,EAAEC,KAAK,IAAA,CAAA;;CAE7C;AAGO,cAAM,IAAIC,MAAM,qCAAA;MAClB;IACF,CAAA;EACF;AACF;","names":["writeError","onErrorPlugin","name","setup","build","onEnd","result","errors","length","process","env","WATCH","map","error","text","join","Error"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __require
3
- } from "./chunk-3GQAWCBQ.js";
3
+ } from "./chunk-WCQVDF3K.js";
4
4
 
5
5
  // src/plugins/fix-imports.ts
6
6
  var fixImportsPlugin = {
@@ -26,3 +26,4 @@ var fixImportsPlugin = {
26
26
  export {
27
27
  fixImportsPlugin
28
28
  };
29
+ //# sourceMappingURL=chunk-YQBU3FSL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugins/fix-imports.ts"],"sourcesContent":["/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\n is maintained by Storm Software under the Apache-2.0 License, and is\n free for commercial and private use. For more information, please visit\n our licensing page.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport type * as esbuild from \"esbuild\";\n\n/**\n * For dependencies that forgot to add them into their package.json.\n */\nexport const fixImportsPlugin: esbuild.Plugin = {\n name: \"storm:fix-imports\",\n setup(build) {\n build.onResolve({ filter: /^spdx-exceptions/ }, () => {\n return { path: require.resolve(\"spdx-exceptions\") };\n });\n build.onResolve({ filter: /^spdx-license-ids/ }, () => {\n return { path: require.resolve(\"spdx-license-ids\") };\n });\n }\n};\n"],"mappings":";;;;;AAsBO,IAAMA,mBAAmC;EAC9CC,MAAM;EACNC,MAAMC,OAAK;AACTA,UAAMC,UAAU;MAAEC,QAAQ;IAAmB,GAAG,MAAA;AAC9C,aAAO;QAAEC,MAAMC,UAAQC,QAAQ,iBAAA;MAAmB;IACpD,CAAA;AACAL,UAAMC,UAAU;MAAEC,QAAQ;IAAoB,GAAG,MAAA;AAC/C,aAAO;QAAEC,MAAMC,UAAQC,QAAQ,kBAAA;MAAoB;IACrD,CAAA;EACF;AACF;","names":["fixImportsPlugin","name","setup","build","onResolve","filter","path","require","resolve"]}
package/dist/config.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkNVGEXPTGcjs = require('./chunk-NVGEXPTG.cjs');
5
- require('./chunk-BGYQAVKQ.cjs');
4
+ var _chunkD5PRB2E2cjs = require('./chunk-D5PRB2E2.cjs');
5
+ require('./chunk-WGEGR3DF.cjs');
6
6
 
7
7
 
8
8
 
9
- exports.DEFAULT_BUILD_OPTIONS = _chunkNVGEXPTGcjs.DEFAULT_BUILD_OPTIONS; exports.adapterConfig = _chunkNVGEXPTGcjs.adapterConfig;
9
+ exports.DEFAULT_BUILD_OPTIONS = _chunkD5PRB2E2cjs.DEFAULT_BUILD_OPTIONS; exports.adapterConfig = _chunkD5PRB2E2cjs.adapterConfig;
10
+ //# sourceMappingURL=config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/config.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,iIAAC","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/config.cjs"}
package/dist/config.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ESBuildOptions } from './types.cjs';
2
2
  import '@nx/devkit';
3
+ import '@storm-software/build-tools';
4
+ import 'zod';
3
5
  import 'esbuild';
4
6
  import 'nx/src/utils/find-workspace-root';
5
7
 
package/dist/config.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ESBuildOptions } from './types.js';
2
2
  import '@nx/devkit';
3
+ import '@storm-software/build-tools';
4
+ import 'zod';
3
5
  import 'esbuild';
4
6
  import 'nx/src/utils/find-workspace-root';
5
7
 
package/dist/config.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  DEFAULT_BUILD_OPTIONS,
3
3
  adapterConfig
4
- } from "./chunk-ELGZJRET.js";
5
- import "./chunk-3GQAWCBQ.js";
4
+ } from "./chunk-DRRPNILS.js";
5
+ import "./chunk-WCQVDF3K.js";
6
6
  export {
7
7
  DEFAULT_BUILD_OPTIONS,
8
8
  adapterConfig
9
9
  };
10
+ //# sourceMappingURL=config.js.map