@storm-software/esbuild 0.4.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/build.cjs +15 -11
  3. package/dist/build.d.cts +3 -3
  4. package/dist/build.d.ts +3 -3
  5. package/dist/build.js +14 -10
  6. package/dist/{chunk-WCQVDF3K.js → chunk-3GQAWCBQ.js} +0 -1
  7. package/dist/chunk-4JLYXTKD.cjs +26 -0
  8. package/dist/chunk-5I2MGPRN.cjs +919 -0
  9. package/dist/{chunk-CMWXE5MF.js → chunk-7KR3YBS6.js} +5 -3
  10. package/dist/chunk-7MDMXJ5V.js +26 -0
  11. package/dist/{chunk-WGEGR3DF.cjs → chunk-BGYQAVKQ.cjs} +0 -1
  12. package/dist/{chunk-J34FQYKV.cjs → chunk-CGFDQ5AJ.cjs} +8 -5
  13. package/dist/{chunk-TTHABTDU.js → chunk-DAGDNKO5.js} +8 -6
  14. package/dist/{chunk-DFGHPRBD.cjs → chunk-EZGTDCYM.cjs} +6 -6
  15. package/dist/chunk-GGNOJ77I.js +0 -0
  16. package/dist/{chunk-YQBU3FSL.js → chunk-GWG4HOQ6.js} +4 -4
  17. package/dist/chunk-HQGUIF4U.js +537 -0
  18. package/dist/{chunk-X5TLV7MF.js → chunk-KE5DL2BG.js} +11 -6
  19. package/dist/{chunk-KJ7ZHAFS.js → chunk-KOK4WCHS.js} +52 -28
  20. package/dist/chunk-LVWQSCJM.cjs +26 -0
  21. package/dist/chunk-LYDEMC26.js +23 -0
  22. package/dist/chunk-MAMLS55E.js +582 -0
  23. package/dist/chunk-NVWDQVN6.js +21 -0
  24. package/dist/chunk-PQ6YIJ72.cjs +136 -0
  25. package/dist/{chunk-BF5W6GVP.cjs → chunk-RMB62XEL.cjs} +10 -8
  26. package/dist/chunk-S6M44SSZ.cjs +60 -0
  27. package/dist/chunk-SFZRYJZ2.cjs +1 -0
  28. package/dist/chunk-T5272PC2.js +60 -0
  29. package/dist/chunk-TP5EOMRD.cjs +21 -0
  30. package/dist/chunk-VBINBV4Z.cjs +537 -0
  31. package/dist/chunk-VLP3P6HF.js +919 -0
  32. package/dist/{chunk-KVBDKVBU.cjs → chunk-VZBOWHCM.cjs} +9 -7
  33. package/dist/chunk-WRBUO7H6.cjs +23 -0
  34. package/dist/chunk-WYMD6YG2.cjs +582 -0
  35. package/dist/{chunk-437F3SFI.js → chunk-YNQ45EAM.js} +7 -4
  36. package/dist/clean.cjs +9 -0
  37. package/dist/clean.d.cts +1194 -0
  38. package/dist/clean.d.ts +1194 -0
  39. package/dist/clean.js +9 -0
  40. package/dist/config.cjs +14 -4
  41. package/dist/config.d.cts +8 -13
  42. package/dist/config.d.ts +8 -13
  43. package/dist/config.js +15 -5
  44. package/dist/esbuild.cjs +1185 -0
  45. package/dist/index.cjs +21 -12
  46. package/dist/index.d.cts +7 -5
  47. package/dist/index.d.ts +7 -5
  48. package/dist/index.js +22 -13
  49. package/dist/types.cjs +1 -2
  50. package/dist/types.d.cts +84 -1177
  51. package/dist/types.d.ts +84 -1177
  52. package/dist/types.js +1 -2
  53. package/package.json +1 -222
  54. package/dist/build.cjs.map +0 -1
  55. package/dist/build.js.map +0 -1
  56. package/dist/chunk-263L44RM.cjs +0 -112
  57. package/dist/chunk-263L44RM.cjs.map +0 -1
  58. package/dist/chunk-437F3SFI.js.map +0 -1
  59. package/dist/chunk-BF5W6GVP.cjs.map +0 -1
  60. package/dist/chunk-CMEDJ4L4.js +0 -352
  61. package/dist/chunk-CMEDJ4L4.js.map +0 -1
  62. package/dist/chunk-CMWXE5MF.js.map +0 -1
  63. package/dist/chunk-D5PRB2E2.cjs +0 -40
  64. package/dist/chunk-D5PRB2E2.cjs.map +0 -1
  65. package/dist/chunk-DFGHPRBD.cjs.map +0 -1
  66. package/dist/chunk-DRRPNILS.js +0 -40
  67. package/dist/chunk-DRRPNILS.js.map +0 -1
  68. package/dist/chunk-J34FQYKV.cjs.map +0 -1
  69. package/dist/chunk-KJ7ZHAFS.js.map +0 -1
  70. package/dist/chunk-KVBDKVBU.cjs.map +0 -1
  71. package/dist/chunk-MUYXFAKB.cjs +0 -1
  72. package/dist/chunk-MUYXFAKB.cjs.map +0 -1
  73. package/dist/chunk-MVLEDP7K.cjs +0 -21
  74. package/dist/chunk-MVLEDP7K.cjs.map +0 -1
  75. package/dist/chunk-PBHOTQGA.cjs +0 -352
  76. package/dist/chunk-PBHOTQGA.cjs.map +0 -1
  77. package/dist/chunk-QNDLJ2W7.js +0 -1
  78. package/dist/chunk-QNDLJ2W7.js.map +0 -1
  79. package/dist/chunk-TTHABTDU.js.map +0 -1
  80. package/dist/chunk-WCQVDF3K.js.map +0 -1
  81. package/dist/chunk-WGEGR3DF.cjs.map +0 -1
  82. package/dist/chunk-X5TLV7MF.js.map +0 -1
  83. package/dist/chunk-YQBU3FSL.js.map +0 -1
  84. package/dist/config.cjs.map +0 -1
  85. package/dist/config.js.map +0 -1
  86. package/dist/index.cjs.map +0 -1
  87. package/dist/index.js.map +0 -1
  88. package/dist/types.cjs.map +0 -1
  89. package/dist/types.js.map +0 -1
@@ -1,10 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
- var _chunkWGEGR3DFcjs = require('./chunk-WGEGR3DF.cjs');
4
+ var _chunkVBINBV4Zcjs = require('./chunk-VBINBV4Z.cjs');
5
+
6
+
7
+
8
+ var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
5
9
 
6
10
  // src/plugins/deps-check.ts
7
- var _configtools = require('@storm-software/config-tools');
8
11
  var _module = require('module');
9
12
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
10
13
  var unusedIgnore = [
@@ -36,11 +39,11 @@ var missingIgnore = [
36
39
  "@prisma/client",
37
40
  "ts-toolbelt"
38
41
  ];
39
- var depsCheckPlugin = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (bundle) => ({
42
+ var depsCheckPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (bundle) => ({
40
43
  name: "storm:deps-check",
41
44
  setup(build) {
42
45
  const pkgJsonPath = _path2.default.join(process.cwd(), "package.json");
43
- const pkgContents = _chunkWGEGR3DFcjs.__require.call(void 0, pkgJsonPath);
46
+ const pkgContents = _chunkBGYQAVKQcjs.__require.call(void 0, pkgJsonPath);
44
47
  const regDependencies = Object.keys(_nullishCoalesce(pkgContents["dependencies"], () => ( {})));
45
48
  const devDependencies = Object.keys(_nullishCoalesce(pkgContents["devDependencies"], () => ( {})));
46
49
  const peerDependencies = Object.keys(_nullishCoalesce(pkgContents["peerDependencies"], () => ( {})));
@@ -83,8 +86,8 @@ var depsCheckPlugin = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (bun
83
86
  const filteredMissingDeps = missingDependencies.filter((dep) => {
84
87
  return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep);
85
88
  });
86
- _configtools.writeWarning.call(void 0, `Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`);
87
- _configtools.writeError.call(void 0, `Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`);
89
+ _chunkVBINBV4Zcjs.writeWarning.call(void 0, `Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`);
90
+ _chunkVBINBV4Zcjs.writeError.call(void 0, `Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`);
88
91
  if (filteredMissingDeps.length > 0) {
89
92
  throw new Error(`Missing dependencies detected - please install them:
90
93
  ${JSON.stringify(filteredMissingDeps)}
@@ -97,4 +100,3 @@ ${JSON.stringify(filteredMissingDeps)}
97
100
 
98
101
 
99
102
  exports.depsCheckPlugin = depsCheckPlugin;
100
- //# sourceMappingURL=chunk-KVBDKVBU.cjs.map
@@ -0,0 +1,23 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
4
+
5
+ // src/plugins/node-protocol.ts
6
+ var nodeProtocolPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options, resolvedOptions) => {
7
+ const nodeProtocol = "node:";
8
+ return {
9
+ name: "node-protocol-plugin",
10
+ setup({ onResolve }) {
11
+ onResolve({
12
+ filter: /^node:/
13
+ }, ({ path }) => ({
14
+ path: path.slice(nodeProtocol.length),
15
+ external: true
16
+ }));
17
+ }
18
+ };
19
+ }, "nodeProtocolPlugin");
20
+
21
+
22
+
23
+ exports.nodeProtocolPlugin = nodeProtocolPlugin;
@@ -0,0 +1,582 @@
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
+
3
+ var _chunkTP5EOMRDcjs = require('./chunk-TP5EOMRD.cjs');
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _chunk5I2MGPRNcjs = require('./chunk-5I2MGPRN.cjs');
18
+
19
+
20
+ var _chunkVZBOWHCMcjs = require('./chunk-VZBOWHCM.cjs');
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ var _chunkVBINBV4Zcjs = require('./chunk-VBINBV4Z.cjs');
31
+
32
+
33
+ var _chunkLVWQSCJMcjs = require('./chunk-LVWQSCJM.cjs');
34
+
35
+
36
+ var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
37
+
38
+ // src/build.ts
39
+ var _node = require('@humanfs/node');
40
+ var _devkit = require('@nx/devkit');
41
+ var _chokidar = require('chokidar');
42
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
43
+ var _estoolkit = require('es-toolkit');
44
+ var _compat = require('es-toolkit/compat');
45
+ var _esbuild = require('esbuild'); var esbuild = _interopRequireWildcard(_esbuild);
46
+ var _globby = require('globby');
47
+ var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
48
+
49
+ // src/base/renderer-engine.ts
50
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
51
+ var _sourcemap = require('source-map');
52
+
53
+ // src/utilities/output-file.ts
54
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
55
+
56
+ var outputFile = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (filepath, data, options) => {
57
+ await _fs2.default.promises.mkdir(_path2.default.dirname(filepath), {
58
+ recursive: true
59
+ });
60
+ await _fs2.default.promises.writeFile(filepath, data, options);
61
+ }, "outputFile");
62
+
63
+ // src/base/renderer-engine.ts
64
+ var parseSourceMap = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (map2) => {
65
+ return typeof map2 === "string" ? JSON.parse(map2) : map2;
66
+ }, "parseSourceMap");
67
+ var isJS = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (path3) => /\.(js|mjs|cjs)$/.test(path3), "isJS");
68
+ var isCSS = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (path3) => /\.css$/.test(path3), "isCSS");
69
+ var getSourcemapComment = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (inline, map2, filepath, isCssFile) => {
70
+ if (!map2) return "";
71
+ const prefix = isCssFile ? "/*" : "//";
72
+ const suffix = isCssFile ? " */" : "";
73
+ const url = inline ? `data:application/json;base64,${Buffer.from(typeof map2 === "string" ? map2 : JSON.stringify(map2)).toString("base64")}` : `${_path2.default.basename(filepath)}.map`;
74
+ return `${prefix}# sourceMappingURL=${url}${suffix}`;
75
+ }, "getSourcemapComment");
76
+ var RendererEngine = class {
77
+ static {
78
+ _chunkBGYQAVKQcjs.__name.call(void 0, this, "RendererEngine");
79
+ }
80
+ #renderers;
81
+ #options;
82
+ constructor(renderers) {
83
+ this.#renderers = renderers;
84
+ }
85
+ setOptions(options) {
86
+ this.#options = options;
87
+ }
88
+ getOptions() {
89
+ if (!this.#options) {
90
+ throw new Error(`Renderer options is not set`);
91
+ }
92
+ return this.#options;
93
+ }
94
+ modifyEsbuildOptions(options) {
95
+ for (const renderer of this.#renderers) {
96
+ if (renderer.esbuildOptions) {
97
+ renderer.esbuildOptions.call(this.getOptions(), options);
98
+ }
99
+ }
100
+ }
101
+ async buildStarted() {
102
+ for (const renderer of this.#renderers) {
103
+ if (renderer.buildStart) {
104
+ await renderer.buildStart.call(this.getOptions());
105
+ }
106
+ }
107
+ }
108
+ async buildFinished({ outputFiles, metafile }) {
109
+ const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
110
+ if (isJS(file.path) || isCSS(file.path)) {
111
+ let relativePath = _path2.default.relative(this.getOptions().config.workspaceRoot, file.path);
112
+ if (!relativePath.startsWith("\\\\?\\")) {
113
+ relativePath = relativePath.replace(/\\/g, "/");
114
+ }
115
+ const meta = _optionalChain([metafile, 'optionalAccess', _2 => _2.outputs, 'access', _3 => _3[relativePath]]);
116
+ return {
117
+ type: "chunk",
118
+ path: file.path,
119
+ code: file.text,
120
+ map: _optionalChain([outputFiles, 'access', _4 => _4.find, 'call', _5 => _5((f) => f.path === `${file.path}.map`), 'optionalAccess', _6 => _6.text]),
121
+ entryPoint: _optionalChain([meta, 'optionalAccess', _7 => _7.entryPoint]),
122
+ exports: _optionalChain([meta, 'optionalAccess', _8 => _8.exports]),
123
+ imports: _optionalChain([meta, 'optionalAccess', _9 => _9.imports])
124
+ };
125
+ } else {
126
+ return {
127
+ type: "asset",
128
+ path: file.path,
129
+ contents: file.contents
130
+ };
131
+ }
132
+ });
133
+ const writtenFiles = [];
134
+ await Promise.all(files.map(async (info) => {
135
+ for (const renderer of this.#renderers) {
136
+ if (info.type === "chunk" && renderer.renderChunk) {
137
+ const result = await renderer.renderChunk.call(this.getOptions(), info.code, info);
138
+ if (result) {
139
+ info.code = result.code;
140
+ if (result.map) {
141
+ const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(info.map));
142
+ const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(result.map));
143
+ const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer);
144
+ generator.applySourceMap(originalConsumer, info.path);
145
+ info.map = generator.toJSON();
146
+ originalConsumer.destroy();
147
+ newConsumer.destroy();
148
+ }
149
+ }
150
+ }
151
+ }
152
+ const inlineSourceMap = this.#options.sourcemap === "inline";
153
+ const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents;
154
+ await outputFile(info.path, contents, {
155
+ mode: info.type === "chunk" ? info.mode : void 0
156
+ });
157
+ writtenFiles.push({
158
+ get name() {
159
+ return _path2.default.relative(process.cwd(), info.path);
160
+ },
161
+ get size() {
162
+ return contents.length;
163
+ }
164
+ });
165
+ if (info.type === "chunk" && info.map && !inlineSourceMap) {
166
+ const map2 = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
167
+ const outPath = `${info.path}.map`;
168
+ const contents2 = JSON.stringify(map2);
169
+ await outputFile(outPath, contents2);
170
+ writtenFiles.push({
171
+ get name() {
172
+ return _path2.default.relative(process.cwd(), outPath);
173
+ },
174
+ get size() {
175
+ return contents2.length;
176
+ }
177
+ });
178
+ }
179
+ }));
180
+ for (const renderer of this.#renderers) {
181
+ if (renderer.buildEnd) {
182
+ await renderer.buildEnd.call(this.getOptions(), {
183
+ writtenFiles
184
+ });
185
+ }
186
+ }
187
+ }
188
+ };
189
+
190
+ // src/renderers/shebang.ts
191
+ var shebangRenderer = {
192
+ name: "shebang",
193
+ renderChunk(_, __, info) {
194
+ if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) {
195
+ info.mode = 493;
196
+ }
197
+ }
198
+ };
199
+
200
+ // src/utilities/helpers.ts
201
+ function handleSync(fn) {
202
+ try {
203
+ return fn();
204
+ } catch (error_) {
205
+ return error_;
206
+ }
207
+ }
208
+ _chunkBGYQAVKQcjs.__name.call(void 0, handleSync, "handleSync");
209
+ async function handleAsync(fn) {
210
+ try {
211
+ return await fn();
212
+ } catch (error_) {
213
+ return error_;
214
+ }
215
+ }
216
+ _chunkBGYQAVKQcjs.__name.call(void 0, handleAsync, "handleAsync");
217
+ var handle = handleSync;
218
+ handle.async = handleAsync;
219
+ var skip = Symbol("skip");
220
+ function transduceSync(list, transformer) {
221
+ const transduced = [];
222
+ for (const [i, element_] of list.entries()) {
223
+ const transformed = transformer(element_, i);
224
+ if (transformed !== skip) {
225
+ transduced[transduced.length] = transformed;
226
+ }
227
+ }
228
+ return transduced;
229
+ }
230
+ _chunkBGYQAVKQcjs.__name.call(void 0, transduceSync, "transduceSync");
231
+ async function transduceAsync(list, transformer) {
232
+ const transduced = [];
233
+ await Promise.all(list.entries().map(async ([i, element_]) => {
234
+ const transformed = await transformer(element_, i);
235
+ if (transformed !== skip) {
236
+ transduced[transduced.length] = transformed;
237
+ }
238
+ }));
239
+ return transduced;
240
+ }
241
+ _chunkBGYQAVKQcjs.__name.call(void 0, transduceAsync, "transduceAsync");
242
+ var Filter = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (filter) => (item) => {
243
+ return filter(item) ? item : skip;
244
+ }, "Filter");
245
+ var Mapper = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (mapper) => (item) => {
246
+ return mapper(item);
247
+ }, "Mapper");
248
+ var transduce = transduceSync;
249
+ transduce.async = transduceAsync;
250
+ function pipeSync(fn, ...fns) {
251
+ return (...args) => {
252
+ let result = fn(...args);
253
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
254
+ result = _optionalChain([fns, 'access', _10 => _10[i], 'optionalCall', _11 => _11(result)]);
255
+ }
256
+ return result;
257
+ };
258
+ }
259
+ _chunkBGYQAVKQcjs.__name.call(void 0, pipeSync, "pipeSync");
260
+ function pipeAsync(fn, ...fns) {
261
+ return async (...args) => {
262
+ let result = await fn(...args);
263
+ for (let i = 0; result !== skip && i < fns.length; ++i) {
264
+ result = await _optionalChain([fns, 'access', _12 => _12[i], 'optionalCall', _13 => _13(result)]);
265
+ }
266
+ return result;
267
+ };
268
+ }
269
+ _chunkBGYQAVKQcjs.__name.call(void 0, pipeAsync, "pipeAsync");
270
+ var pipe = pipeSync;
271
+ pipe.async = pipeAsync;
272
+
273
+ // src/build.ts
274
+ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (userOptions) => {
275
+ const projectRoot = userOptions.projectRoot;
276
+ const workspaceRoot = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot);
277
+ if (!workspaceRoot) {
278
+ throw new Error("Cannot find Nx workspace root");
279
+ }
280
+ const config = await _chunk5I2MGPRNcjs.loadStormConfig.call(void 0, workspaceRoot.dir);
281
+ _chunkVBINBV4Zcjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config);
282
+ const stopwatch = _chunkVBINBV4Zcjs.getStopwatch.call(void 0, "Build options resolution");
283
+ const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, {
284
+ exitOnError: true
285
+ });
286
+ const projectJsonPath = _chunkLVWQSCJMcjs.joinPaths.call(void 0, workspaceRoot.dir, projectRoot, "project.json");
287
+ if (!await _node.hfs.isFile(projectJsonPath)) {
288
+ throw new Error("Cannot find project.json configuration");
289
+ }
290
+ const projectJson = await _node.hfs.json(projectJsonPath);
291
+ const projectName = projectJson.name;
292
+ const projectConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph);
293
+ if (!_optionalChain([projectConfigurations, 'optionalAccess', _14 => _14.projects, 'optionalAccess', _15 => _15[projectName]])) {
294
+ 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.");
295
+ }
296
+ const options = _defu2.default.call(void 0, userOptions, _chunk5I2MGPRNcjs.DEFAULT_BUILD_OPTIONS);
297
+ options.name ??= `${projectName}-${options.format}`;
298
+ options.target ??= _chunk5I2MGPRNcjs.DEFAULT_TARGET;
299
+ const packageJsonPath = _chunkLVWQSCJMcjs.joinPaths.call(void 0, workspaceRoot.dir, options.projectRoot, "package.json");
300
+ if (!await _node.hfs.isFile(packageJsonPath)) {
301
+ throw new Error("Cannot find package.json configuration");
302
+ }
303
+ const packageJson = await _node.hfs.json(packageJsonPath);
304
+ const outExtension = _chunk5I2MGPRNcjs.getOutputExtensionMap.call(void 0, options, packageJson.type);
305
+ const env = _chunk5I2MGPRNcjs.getEnv.call(void 0, "esbuild", options);
306
+ const result = {
307
+ ...options,
308
+ config,
309
+ mainFields: options.platform === "node" ? [
310
+ "module",
311
+ "main"
312
+ ] : [
313
+ "browser",
314
+ "module",
315
+ "main"
316
+ ],
317
+ resolveExtensions: [
318
+ ".ts",
319
+ ".js",
320
+ ".node"
321
+ ],
322
+ ...userOptions,
323
+ tsconfig: _chunkLVWQSCJMcjs.joinPaths.call(void 0, projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
324
+ format: options.format || "cjs",
325
+ entryPoints: await _chunk5I2MGPRNcjs.getEntryPoints.call(void 0, config, projectRoot, projectJson.sourceRoot, userOptions.entry || [
326
+ "./src/index.ts"
327
+ ], userOptions.emitOnAll),
328
+ outdir: userOptions.outputPath || _chunkLVWQSCJMcjs.joinPaths.call(void 0, "dist", projectRoot),
329
+ plugins: [],
330
+ name: userOptions.name || projectName,
331
+ projectConfigurations,
332
+ projectName,
333
+ projectGraph,
334
+ sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || _chunkLVWQSCJMcjs.joinPaths.call(void 0, projectRoot, "src"),
335
+ minify: userOptions.minify || !userOptions.debug,
336
+ verbose: userOptions.verbose || _chunkVBINBV4Zcjs.isVerbose.call(void 0, ) || userOptions.debug === true,
337
+ includeSrc: userOptions.includeSrc === true,
338
+ metafile: userOptions.metafile !== false,
339
+ generatePackageJson: userOptions.generatePackageJson !== false,
340
+ clean: userOptions.clean !== false,
341
+ emitOnAll: userOptions.emitOnAll === true,
342
+ assets: _nullishCoalesce(userOptions.assets, () => ( [])),
343
+ injectShims: userOptions.injectShims !== true,
344
+ bundle: userOptions.bundle !== false,
345
+ keepNames: true,
346
+ watch: userOptions.watch === true,
347
+ outExtension,
348
+ footer: userOptions.footer,
349
+ banner: {
350
+ js: options.banner || _chunk5I2MGPRNcjs.DEFAULT_COMPILED_BANNER,
351
+ css: options.banner || _chunk5I2MGPRNcjs.DEFAULT_COMPILED_BANNER
352
+ },
353
+ splitting: options.format === "iife" ? false : typeof options.splitting === "boolean" ? options.splitting : options.format === "esm",
354
+ treeShaking: options.format === "esm",
355
+ env,
356
+ define: {
357
+ STORM_FORMAT: JSON.stringify(options.format || "cjs"),
358
+ ...options.format === "cjs" && options.injectShims ? {
359
+ "import.meta.url": "importMetaUrl"
360
+ } : {},
361
+ ...options.define,
362
+ ...Object.keys(env || {}).reduce((res, key) => {
363
+ const value = JSON.stringify(env[key]);
364
+ return {
365
+ ...res,
366
+ [`process.env.${key}`]: value,
367
+ [`import.meta.env.${key}`]: value
368
+ };
369
+ }, {})
370
+ },
371
+ inject: [
372
+ options.format === "cjs" && options.injectShims ? _chunkLVWQSCJMcjs.joinPaths.call(void 0, __dirname, "../assets/cjs_shims.js") : "",
373
+ options.format === "esm" && options.injectShims && options.platform === "node" ? _chunkLVWQSCJMcjs.joinPaths.call(void 0, __dirname, "../assets/esm_shims.js") : "",
374
+ ..._nullishCoalesce(options.inject, () => ( []))
375
+ ].filter(Boolean)
376
+ };
377
+ result.plugins = _nullishCoalesce(userOptions.plugins, () => ( _chunk5I2MGPRNcjs.getDefaultBuildPlugins.call(void 0, userOptions, result)));
378
+ stopwatch();
379
+ return result;
380
+ }, "resolveOptions");
381
+ async function generatePackageJson(context2) {
382
+ if (context2.options.generatePackageJson !== false && await _node.hfs.isFile(_chunkLVWQSCJMcjs.joinPaths.call(void 0, context2.options.projectRoot, "package.json"))) {
383
+ _chunkVBINBV4Zcjs.writeDebug.call(void 0, " \u270D\uFE0F Writing package.json file", context2.options.config);
384
+ const stopwatch = _chunkVBINBV4Zcjs.getStopwatch.call(void 0, "Write package.json file");
385
+ const packageJsonPath = _chunkLVWQSCJMcjs.joinPaths.call(void 0, context2.options.projectRoot, "project.json");
386
+ if (!await _node.hfs.isFile(packageJsonPath)) {
387
+ throw new Error("Cannot find package.json configuration");
388
+ }
389
+ let packageJson = await _node.hfs.json(_chunkLVWQSCJMcjs.joinPaths.call(void 0, context2.options.config.workspaceRoot, context2.options.projectRoot, "package.json"));
390
+ if (!packageJson) {
391
+ throw new Error("Cannot find package.json configuration file");
392
+ }
393
+ packageJson = await _chunk5I2MGPRNcjs.addPackageDependencies.call(void 0, context2.options.config.workspaceRoot, context2.options.projectRoot, context2.options.projectName, packageJson);
394
+ packageJson = await _chunk5I2MGPRNcjs.addWorkspacePackageJsonFields.call(void 0, context2.options.config, context2.options.projectRoot, context2.options.sourceRoot, context2.options.projectName, false, packageJson);
395
+ packageJson.exports ??= {};
396
+ packageJson.exports["./package.json"] ??= "./package.json";
397
+ packageJson.exports["."] ??= _chunk5I2MGPRNcjs.addPackageJsonExport.call(void 0, "index", packageJson.type, context2.options.sourceRoot);
398
+ let entryPoints = [
399
+ {
400
+ in: "./src/index.ts",
401
+ out: "./src/index.ts"
402
+ }
403
+ ];
404
+ if (context2.options.entryPoints) {
405
+ if (Array.isArray(context2.options.entryPoints)) {
406
+ entryPoints = context2.options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
407
+ in: entryPoint,
408
+ out: entryPoint
409
+ } : entryPoint);
410
+ }
411
+ for (const entryPoint of entryPoints) {
412
+ const split = entryPoint.out.split(".");
413
+ split.pop();
414
+ const entry = split.join(".").replaceAll("\\", "/");
415
+ packageJson.exports[`./${entry}`] ??= _chunk5I2MGPRNcjs.addPackageJsonExport.call(void 0, entry, packageJson.type, context2.options.sourceRoot);
416
+ }
417
+ }
418
+ packageJson.main = packageJson.type === "commonjs" ? "./dist/index.js" : "./dist/index.cjs";
419
+ packageJson.module = packageJson.type === "module" ? "./dist/index.js" : "./dist/index.mjs";
420
+ packageJson.types = "./dist/index.d.ts";
421
+ packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
422
+ if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
423
+ ret[key.replace("/index", "")] = packageJson.exports[key];
424
+ }
425
+ return ret;
426
+ }, packageJson.exports);
427
+ await _devkit.writeJsonFile.call(void 0, _chunkLVWQSCJMcjs.joinPaths.call(void 0, context2.options.outdir, "package.json"), packageJson);
428
+ stopwatch();
429
+ }
430
+ return context2;
431
+ }
432
+ _chunkBGYQAVKQcjs.__name.call(void 0, generatePackageJson, "generatePackageJson");
433
+ async function createOptions(options) {
434
+ return _estoolkit.flatten.call(void 0, await Promise.all(_compat.map.call(void 0, options, (opt) => [
435
+ // we defer it so that we don't trigger glob immediately
436
+ () => resolveOptions(opt)
437
+ ])));
438
+ }
439
+ _chunkBGYQAVKQcjs.__name.call(void 0, createOptions, "createOptions");
440
+ async function generateContext(getOptions) {
441
+ const options = await getOptions();
442
+ const rendererEngine = new RendererEngine([
443
+ shebangRenderer,
444
+ ...options.renderers || []
445
+ ]);
446
+ return {
447
+ options,
448
+ rendererEngine
449
+ };
450
+ }
451
+ _chunkBGYQAVKQcjs.__name.call(void 0, generateContext, "generateContext");
452
+ async function executeEsBuild(context2) {
453
+ _chunkVBINBV4Zcjs.writeDebug.call(void 0, ` \u{1F680} Running ${context2.options.name} build`, context2.options.config);
454
+ const stopwatch = _chunkVBINBV4Zcjs.getStopwatch.call(void 0, `${context2.options.name} build`);
455
+ if (process.env.WATCH === "true") {
456
+ const ctx = await esbuild.context(context2.options);
457
+ watch(ctx, context2.options);
458
+ }
459
+ const result = await esbuild.build(context2.options);
460
+ if (result.metafile) {
461
+ const metafilePath = `${context2.options.outdir}/${context2.options.name}.meta.json`;
462
+ await _node.hfs.write(metafilePath, JSON.stringify(result.metafile));
463
+ }
464
+ stopwatch();
465
+ return context2;
466
+ }
467
+ _chunkBGYQAVKQcjs.__name.call(void 0, executeEsBuild, "executeEsBuild");
468
+ async function copyBuildAssets(context2) {
469
+ if (_optionalChain([context2, 'access', _16 => _16.result, 'optionalAccess', _17 => _17.errors, 'access', _18 => _18.length]) === 0) {
470
+ _chunkVBINBV4Zcjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context2.options.outdir}`, context2.options.config);
471
+ const stopwatch = _chunkVBINBV4Zcjs.getStopwatch.call(void 0, `${context2.options.name} asset copy`);
472
+ await _chunk5I2MGPRNcjs.copyAssets.call(void 0, context2.options.config, _nullishCoalesce(context2.options.assets, () => ( [])), context2.options.outdir, context2.options.projectRoot, context2.options.projectName, context2.options.sourceRoot, true, false);
473
+ stopwatch();
474
+ }
475
+ return context2;
476
+ }
477
+ _chunkBGYQAVKQcjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
478
+ async function reportResults(context2) {
479
+ if (_optionalChain([context2, 'access', _19 => _19.result, 'optionalAccess', _20 => _20.errors, 'access', _21 => _21.length]) === 0) {
480
+ if (context2.result.warnings.length > 0) {
481
+ _chunkVBINBV4Zcjs.writeWarning.call(void 0, ` \u{1F6A7} The following warnings occurred during the build: ${context2.result.warnings.map((warning) => warning.text).join("\n")}`, context2.options.config);
482
+ }
483
+ _chunkVBINBV4Zcjs.writeSuccess.call(void 0, ` \u{1F4E6} The ${context2.options.name} build completed successfully`, context2.options.config);
484
+ }
485
+ }
486
+ _chunkBGYQAVKQcjs.__name.call(void 0, reportResults, "reportResults");
487
+ async function dependencyCheck(options) {
488
+ if (process.env.DEV === "true") {
489
+ return void 0;
490
+ }
491
+ if (process.env.CI && !process.env.BUILDKITE) {
492
+ return void 0;
493
+ }
494
+ const buildPromise = esbuild.build({
495
+ entryPoints: _globby.globbySync.call(void 0, "**/*.{j,t}s", {
496
+ // We don't check dependencies in ecosystem tests because tests are isolated from the build.
497
+ ignore: [
498
+ "./src/__tests__/**/*",
499
+ "./tests/e2e/**/*",
500
+ "./dist/**/*"
501
+ ],
502
+ gitignore: true
503
+ }),
504
+ logLevel: "silent",
505
+ bundle: true,
506
+ write: false,
507
+ outdir: "out",
508
+ plugins: [
509
+ _chunkVZBOWHCMcjs.depsCheckPlugin.call(void 0, options.bundle)
510
+ ]
511
+ });
512
+ await buildPromise.catch(() => {
513
+ });
514
+ return void 0;
515
+ }
516
+ _chunkBGYQAVKQcjs.__name.call(void 0, dependencyCheck, "dependencyCheck");
517
+ async function cleanOutputPath(context2) {
518
+ if (context2.options.clean !== false && context2.options.outdir) {
519
+ await _chunkTP5EOMRDcjs.clean.call(void 0, context2.options.name, context2.options.outdir, context2.options.config);
520
+ }
521
+ return context2;
522
+ }
523
+ _chunkBGYQAVKQcjs.__name.call(void 0, cleanOutputPath, "cleanOutputPath");
524
+ async function build2(options) {
525
+ _chunkVBINBV4Zcjs.writeDebug.call(void 0, ` \u26A1 Executing Storm ESBuild pipeline`);
526
+ const stopwatch = _chunkVBINBV4Zcjs.getStopwatch.call(void 0, "ESBuild pipeline");
527
+ try {
528
+ const opts = Array.isArray(options) ? options : [
529
+ options
530
+ ];
531
+ if (opts.length === 0) {
532
+ throw new Error("No build options were provided");
533
+ }
534
+ void transduce.async(opts, dependencyCheck);
535
+ await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
536
+ _chunkVBINBV4Zcjs.writeSuccess.call(void 0, " \u{1F3C1} ESBuild pipeline build completed successfully");
537
+ } catch (error) {
538
+ _chunkVBINBV4Zcjs.writeFatal.call(void 0, " \u274C Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
539
+ throw error;
540
+ } finally {
541
+ stopwatch();
542
+ }
543
+ }
544
+ _chunkBGYQAVKQcjs.__name.call(void 0, build2, "build");
545
+ var watch = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (context2, options) => {
546
+ if (!options.watch) {
547
+ return context2;
548
+ }
549
+ const config = {
550
+ ignoreInitial: true,
551
+ useFsEvents: true,
552
+ ignored: [
553
+ "./src/__tests__/**/*",
554
+ "./package.json"
555
+ ]
556
+ };
557
+ const changeWatcher = _chokidar.watch.call(void 0, [
558
+ "./src/**/*"
559
+ ], config);
560
+ const fastRebuild = _estoolkit.debounce.call(void 0, async () => {
561
+ const timeBefore = Date.now();
562
+ const rebuildResult = await handle.async(() => {
563
+ return context2.rebuild();
564
+ });
565
+ if (rebuildResult instanceof Error) {
566
+ _chunkVBINBV4Zcjs.writeError.call(void 0, rebuildResult.message);
567
+ }
568
+ _chunkVBINBV4Zcjs.writeTrace.call(void 0, `${Date.now() - timeBefore}ms [${_nullishCoalesce(options.name, () => ( ""))}]`);
569
+ }, 10);
570
+ changeWatcher.on("change", fastRebuild);
571
+ return void 0;
572
+ }, "watch");
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+ exports.handle = handle; exports.skip = skip; exports.Filter = Filter; exports.Mapper = Mapper; exports.transduce = transduce; exports.pipe = pipe; exports.build = build2;
@@ -1,13 +1,17 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-3GQAWCBQ.js";
4
+
1
5
  // src/plugins/esm-split-code-to-cjs.ts
2
6
  import * as esbuild from "esbuild";
3
- var esmSplitCodeToCjsPlugin = {
7
+ var esmSplitCodeToCjsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
4
8
  name: "storm:esm-split-code-to-cjs",
5
9
  setup(build2) {
6
10
  build2.onEnd(async (result) => {
7
11
  const outFiles = Object.keys(result.metafile?.outputs ?? {});
8
12
  const jsFiles = outFiles.filter((f) => f.endsWith("js"));
9
13
  await esbuild.build({
10
- outdir: build2.initialOptions.outdir,
14
+ outdir: resolvedOptions.outdir,
11
15
  entryPoints: jsFiles,
12
16
  allowOverwrite: true,
13
17
  format: "cjs",
@@ -16,9 +20,8 @@ var esmSplitCodeToCjsPlugin = {
16
20
  });
17
21
  });
18
22
  }
19
- };
23
+ }), "esmSplitCodeToCjsPlugin");
20
24
 
21
25
  export {
22
26
  esmSplitCodeToCjsPlugin
23
27
  };
24
- //# sourceMappingURL=chunk-437F3SFI.js.map