@storm-software/esbuild 0.34.1 → 0.34.3

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 (119) hide show
  1. package/README.md +2 -1
  2. package/bin/esbuild.cjs +12144 -159
  3. package/dist/assets.cjs +9 -0
  4. package/dist/assets.d.cts +16 -0
  5. package/dist/assets.d.ts +16 -0
  6. package/dist/assets.js +9 -0
  7. package/dist/build.cjs +13 -17
  8. package/dist/build.d.cts +3 -13
  9. package/dist/build.d.ts +3 -13
  10. package/dist/build.js +14 -18
  11. package/dist/chunk-2CM3VAO5.cjs +119 -0
  12. package/dist/{chunk-YMTDVMD6.js → chunk-4D6ICA75.js} +36 -3
  13. package/dist/{chunk-RGWII6NP.js → chunk-ABRK5MYP.js} +3 -5
  14. package/dist/chunk-CVOQEYHW.cjs +117 -0
  15. package/dist/{chunk-35YNFZCF.js → chunk-DNZNN5SK.js} +2 -2
  16. package/dist/chunk-EBTMX5WL.js +117 -0
  17. package/dist/chunk-ECCVVXNX.js +100 -0
  18. package/dist/chunk-EDLA3ZZN.js +26 -0
  19. package/dist/{chunk-Y3LXNK5C.cjs → chunk-EVDNG72R.cjs} +35 -37
  20. package/dist/{chunk-DZPLKD6O.cjs → chunk-FQQYNAPT.cjs} +111 -189
  21. package/dist/{chunk-4TQE46SC.cjs → chunk-G66JI4BS.cjs} +5 -7
  22. package/dist/{chunk-RTDGFM3J.js → chunk-NJJBR57W.js} +24 -102
  23. package/dist/{chunk-IX6DNVUR.js → chunk-OCDIIBBZ.js} +2 -2
  24. package/dist/chunk-PTHYT3U2.cjs +2545 -0
  25. package/dist/chunk-QVMJLFU5.cjs +26 -0
  26. package/dist/chunk-QWTKBUQW.js +2545 -0
  27. package/dist/chunk-R2KKGNQL.js +119 -0
  28. package/dist/{chunk-Y4XWI6JJ.cjs → chunk-RK34D7S5.cjs} +6 -6
  29. package/dist/chunk-SLSBBNRF.cjs +52 -0
  30. package/dist/{chunk-2IGRKQGI.js → chunk-TSQT5MWW.js} +2 -4
  31. package/dist/{chunk-MWGFCZF4.cjs → chunk-VTBMJYSM.cjs} +6 -6
  32. package/dist/chunk-WLJT52I3.cjs +100 -0
  33. package/dist/chunk-WXURMFT7.js +52 -0
  34. package/dist/{chunk-XITTOHOG.cjs → chunk-YHMM6RY5.cjs} +42 -9
  35. package/dist/clean.cjs +4 -5
  36. package/dist/clean.d.cts +1 -2
  37. package/dist/clean.d.ts +1 -2
  38. package/dist/clean.js +3 -4
  39. package/dist/config.cjs +5 -14
  40. package/dist/config.d.cts +4 -6
  41. package/dist/config.d.ts +4 -6
  42. package/dist/config.js +6 -15
  43. package/dist/context.cjs +11 -0
  44. package/dist/context.d.cts +16 -0
  45. package/dist/context.d.ts +16 -0
  46. package/dist/context.js +11 -0
  47. package/dist/index.cjs +14 -52
  48. package/dist/index.d.cts +3 -216
  49. package/dist/index.d.ts +3 -216
  50. package/dist/index.js +15 -53
  51. package/dist/package-json.cjs +9 -0
  52. package/dist/package-json.d.cts +16 -0
  53. package/dist/package-json.d.ts +16 -0
  54. package/dist/package-json.js +9 -0
  55. package/dist/plugins/deps-check.cjs +4 -5
  56. package/dist/plugins/deps-check.js +3 -4
  57. package/dist/plugins/resolve-paths.cjs +3 -4
  58. package/dist/plugins/resolve-paths.d.cts +3 -4
  59. package/dist/plugins/resolve-paths.d.ts +3 -4
  60. package/dist/plugins/resolve-paths.js +2 -3
  61. package/dist/tsup.cjs +8 -0
  62. package/dist/tsup.d.cts +16 -0
  63. package/dist/tsup.d.ts +16 -0
  64. package/dist/tsup.js +8 -0
  65. package/dist/types.d.cts +1 -2
  66. package/dist/types.d.ts +1 -2
  67. package/dist/watch.cjs +111 -0
  68. package/dist/watch.d.cts +18 -0
  69. package/dist/watch.d.ts +18 -0
  70. package/dist/watch.js +111 -0
  71. package/package.json +59 -38
  72. package/dist/chunk-3GQAWCBQ.js +0 -13
  73. package/dist/chunk-7A6JPBG7.js +0 -421
  74. package/dist/chunk-BGYQAVKQ.cjs +0 -13
  75. package/dist/chunk-ETTFFUNG.cjs +0 -167
  76. package/dist/chunk-EZGTDCYM.cjs +0 -29
  77. package/dist/chunk-GQCYZOAM.cjs +0 -27
  78. package/dist/chunk-GWG4HOQ6.js +0 -29
  79. package/dist/chunk-HXMVEX3P.js +0 -27
  80. package/dist/chunk-IMVMVEQS.cjs +0 -140
  81. package/dist/chunk-IO2TXOKO.js +0 -26
  82. package/dist/chunk-K6QIYIIY.cjs +0 -26
  83. package/dist/chunk-LYDEMC26.js +0 -23
  84. package/dist/chunk-RVMQBDDK.cjs +0 -421
  85. package/dist/chunk-S2P6KHZV.js +0 -140
  86. package/dist/chunk-S6M44SSZ.cjs +0 -60
  87. package/dist/chunk-T5272PC2.js +0 -60
  88. package/dist/chunk-WRBUO7H6.cjs +0 -23
  89. package/dist/chunk-XEGYFRBF.js +0 -167
  90. package/dist/plugins/esm-split-code-to-cjs.cjs +0 -7
  91. package/dist/plugins/esm-split-code-to-cjs.d.cts +0 -15
  92. package/dist/plugins/esm-split-code-to-cjs.d.ts +0 -15
  93. package/dist/plugins/esm-split-code-to-cjs.js +0 -7
  94. package/dist/plugins/fix-imports.cjs +0 -7
  95. package/dist/plugins/fix-imports.d.cts +0 -14
  96. package/dist/plugins/fix-imports.d.ts +0 -14
  97. package/dist/plugins/fix-imports.js +0 -7
  98. package/dist/plugins/native-node-module.cjs +0 -7
  99. package/dist/plugins/native-node-module.d.cts +0 -11
  100. package/dist/plugins/native-node-module.d.ts +0 -11
  101. package/dist/plugins/native-node-module.js +0 -7
  102. package/dist/plugins/node-protocol.cjs +0 -7
  103. package/dist/plugins/node-protocol.d.cts +0 -15
  104. package/dist/plugins/node-protocol.d.ts +0 -15
  105. package/dist/plugins/node-protocol.js +0 -7
  106. package/dist/plugins/on-error.cjs +0 -9
  107. package/dist/plugins/on-error.d.cts +0 -14
  108. package/dist/plugins/on-error.d.ts +0 -14
  109. package/dist/plugins/on-error.js +0 -9
  110. package/dist/plugins/tsc.cjs +0 -9
  111. package/dist/plugins/tsc.d.cts +0 -14
  112. package/dist/plugins/tsc.d.ts +0 -14
  113. package/dist/plugins/tsc.js +0 -9
  114. package/dist/tsc.cjs +0 -17
  115. package/dist/tsc.d.cts +0 -21
  116. package/dist/tsc.d.ts +0 -21
  117. package/dist/tsc.js +0 -17
  118. package/dist/types-DwxFThZu.d.cts +0 -1286
  119. package/dist/types-DwxFThZu.d.ts +0 -1286
@@ -1,421 +0,0 @@
1
- import {
2
- cleanDirectories
3
- } from "./chunk-35YNFZCF.js";
4
- import {
5
- DEFAULT_BUILD_OPTIONS,
6
- addPackageDependencies,
7
- addWorkspacePackageJsonFields,
8
- copyAssets,
9
- getEnv,
10
- getWorkspaceConfig
11
- } from "./chunk-RTDGFM3J.js";
12
- import {
13
- depsCheckPlugin
14
- } from "./chunk-IX6DNVUR.js";
15
- import {
16
- getStopwatch,
17
- writeDebug,
18
- writeError,
19
- writeFatal,
20
- writeSuccess,
21
- writeTrace,
22
- writeWarning
23
- } from "./chunk-2IGRKQGI.js";
24
- import {
25
- joinPaths
26
- } from "./chunk-YMTDVMD6.js";
27
- import {
28
- __name
29
- } from "./chunk-3GQAWCBQ.js";
30
-
31
- // src/build.ts
32
- import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
33
- import { watch as createWatcher } from "chokidar";
34
- import defu from "defu";
35
- import { debounce } from "es-toolkit";
36
- import * as esbuild from "esbuild";
37
- import { globbySync } from "globby";
38
- import { existsSync } from "node:fs";
39
- import hf from "node:fs/promises";
40
- import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root";
41
- import { build as tsup } from "tsup";
42
-
43
- // src/utilities/helpers.ts
44
- function handleSync(fn) {
45
- try {
46
- return fn();
47
- } catch (error_) {
48
- return error_;
49
- }
50
- }
51
- __name(handleSync, "handleSync");
52
- async function handleAsync(fn) {
53
- try {
54
- return await fn();
55
- } catch (error_) {
56
- return error_;
57
- }
58
- }
59
- __name(handleAsync, "handleAsync");
60
- var handle = handleSync;
61
- handle.async = handleAsync;
62
- var skip = Symbol("skip");
63
- function transduceSync(list, transformer) {
64
- const transduced = [];
65
- for (const [i, element_] of list.entries()) {
66
- const transformed = transformer(element_, i);
67
- if (transformed !== skip) {
68
- transduced[transduced.length] = transformed;
69
- }
70
- }
71
- return transduced;
72
- }
73
- __name(transduceSync, "transduceSync");
74
- async function transduceAsync(list, transformer) {
75
- const transduced = [];
76
- await Promise.all(list.entries().map(async ([i, element_]) => {
77
- const transformed = await transformer(element_, i);
78
- if (transformed !== skip) {
79
- transduced[transduced.length] = transformed;
80
- }
81
- }));
82
- return transduced;
83
- }
84
- __name(transduceAsync, "transduceAsync");
85
- var Filter = /* @__PURE__ */ __name((filter) => (item) => {
86
- return filter(item) ? item : skip;
87
- }, "Filter");
88
- var Mapper = /* @__PURE__ */ __name((mapper) => (item) => {
89
- return mapper(item);
90
- }, "Mapper");
91
- var transduce = transduceSync;
92
- transduce.async = transduceAsync;
93
- function pipeSync(fn, ...fns) {
94
- return (...args) => {
95
- let result = fn(...args);
96
- for (let i = 0; result !== skip && i < fns.length; ++i) {
97
- result = fns[i]?.(result);
98
- }
99
- return result;
100
- };
101
- }
102
- __name(pipeSync, "pipeSync");
103
- function pipeAsync(fn, ...fns) {
104
- return async (...args) => {
105
- let result = await fn(...args);
106
- for (let i = 0; result !== skip && i < fns.length; ++i) {
107
- result = await fns[i]?.(result);
108
- }
109
- return result;
110
- };
111
- }
112
- __name(pipeAsync, "pipeAsync");
113
- var pipe = pipeSync;
114
- pipe.async = pipeAsync;
115
-
116
- // src/build.ts
117
- async function resolveContext(userOptions) {
118
- const projectRoot = userOptions.projectRoot;
119
- const workspaceRoot = findWorkspaceRoot(projectRoot);
120
- if (!workspaceRoot) {
121
- throw new Error("Cannot find Nx workspace root");
122
- }
123
- const workspaceConfig = await getWorkspaceConfig(true, {
124
- workspaceRoot: workspaceRoot.dir
125
- });
126
- writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
127
- const stopwatch = getStopwatch("Build options resolution");
128
- const projectGraph = await createProjectGraphAsync({
129
- exitOnError: true
130
- });
131
- const projectJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "project.json");
132
- if (!existsSync(projectJsonPath)) {
133
- throw new Error("Cannot find project.json configuration");
134
- }
135
- const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
136
- const projectJson = JSON.parse(projectJsonFile);
137
- const projectName = projectJson.name || userOptions.name;
138
- const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
139
- if (!projectConfigurations?.projects?.[projectName]) {
140
- throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
141
- }
142
- const options = defu(userOptions, DEFAULT_BUILD_OPTIONS);
143
- const packageJsonPath = joinPaths(workspaceRoot.dir, options.projectRoot, "package.json");
144
- if (!existsSync(packageJsonPath)) {
145
- throw new Error("Cannot find package.json configuration");
146
- }
147
- const env = getEnv("esbuild", options);
148
- const define = defu(options.define ?? {}, env ?? {});
149
- const resolvedOptions = {
150
- name: projectName,
151
- ...options,
152
- tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
153
- metafile: userOptions.mode === "development",
154
- clean: false,
155
- env,
156
- define: {
157
- STORM_FORMAT: JSON.stringify(options.format),
158
- ...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
159
- const value = JSON.stringify(define[key]);
160
- const safeKey = key.replaceAll("(", "").replaceAll(")", "");
161
- return {
162
- ...res,
163
- [`process.env.${safeKey}`]: value,
164
- [`import.meta.env.${safeKey}`]: value
165
- };
166
- }, {})
167
- }
168
- };
169
- stopwatch();
170
- return {
171
- options: resolvedOptions,
172
- clean: userOptions.clean !== false,
173
- workspaceConfig,
174
- projectConfigurations,
175
- projectName,
176
- projectGraph,
177
- sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || joinPaths(resolvedOptions.projectRoot, "src"),
178
- outputPath: resolvedOptions.outputPath || joinPaths(workspaceConfig.workspaceRoot, "dist", resolvedOptions.projectRoot),
179
- minify: resolvedOptions.minify || resolvedOptions.mode === "production"
180
- };
181
- }
182
- __name(resolveContext, "resolveContext");
183
- async function generatePackageJson(context) {
184
- if (context.options.generatePackageJson !== false && existsSync(joinPaths(context.options.projectRoot, "package.json"))) {
185
- writeDebug(" \u270D\uFE0F Writing package.json file", context.workspaceConfig);
186
- const stopwatch = getStopwatch("Write package.json file");
187
- const packageJsonPath = joinPaths(context.options.projectRoot, "project.json");
188
- if (!existsSync(packageJsonPath)) {
189
- throw new Error("Cannot find package.json configuration");
190
- }
191
- const packageJsonFile = await hf.readFile(joinPaths(context.workspaceConfig.workspaceRoot, context.options.projectRoot, "package.json"), "utf8");
192
- let packageJson = JSON.parse(packageJsonFile);
193
- if (!packageJson) {
194
- throw new Error("Cannot find package.json configuration file");
195
- }
196
- packageJson = await addPackageDependencies(context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
197
- packageJson = await addWorkspacePackageJsonFields(context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
198
- if (context.options.entry) {
199
- packageJson.exports ??= {};
200
- packageJson.exports["./package.json"] ??= "./package.json";
201
- const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
202
- if (entryPoints.length > 0) {
203
- const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
204
- const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
205
- const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
206
- const isDts = context.options.dts || context.options.experimentalDts;
207
- packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
208
- for (const entryPoint of entryPoints) {
209
- packageJson.exports[`./${entryPoint}`] ??= {};
210
- if (isEsm) {
211
- if (isDts) {
212
- packageJson.exports[`./${entryPoint}`].import = {
213
- types: `./dist/${entryPoint}.d.mts`,
214
- default: `./dist/${entryPoint}.mjs`
215
- };
216
- } else {
217
- packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
218
- }
219
- if (isDts) {
220
- packageJson.exports[`./${entryPoint}`].default = {
221
- types: `./dist/${entryPoint}.d.mts`,
222
- default: `./dist/${entryPoint}.mjs`
223
- };
224
- } else {
225
- packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
226
- }
227
- }
228
- if (isCjs) {
229
- if (isDts) {
230
- packageJson.exports[`./${entryPoint}`].require = {
231
- types: `./dist/${entryPoint}.d.cts`,
232
- default: `./dist/${entryPoint}.cjs`
233
- };
234
- } else {
235
- packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
236
- }
237
- if (!isEsm) {
238
- if (isDts) {
239
- packageJson.exports[`./${entryPoint}`].default = {
240
- types: `./dist/${entryPoint}.d.cts`,
241
- default: `./dist/${entryPoint}.cjs`
242
- };
243
- } else {
244
- packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
245
- }
246
- }
247
- }
248
- if (!isEsm && !isCjs) {
249
- if (isDts) {
250
- packageJson.exports[`./${entryPoint}`].default = {
251
- types: `./dist/${entryPoint}.d.ts`,
252
- default: `./dist/${entryPoint}.js`
253
- };
254
- } else {
255
- packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
256
- }
257
- }
258
- }
259
- if (isEsm) {
260
- packageJson.module = `${defaultEntry}.mjs`;
261
- } else {
262
- packageJson.main = `${defaultEntry}.cjs`;
263
- }
264
- if (isDts) {
265
- packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
266
- }
267
- packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
268
- if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
269
- ret[key.replace("/index", "")] = packageJson.exports[key];
270
- }
271
- return ret;
272
- }, packageJson.exports);
273
- }
274
- }
275
- await writeJsonFile(joinPaths(context.outputPath, "package.json"), packageJson);
276
- stopwatch();
277
- }
278
- return context;
279
- }
280
- __name(generatePackageJson, "generatePackageJson");
281
- async function executeTsup(context) {
282
- writeDebug(` \u{1F680} Running ${context.options.name} build`, context.workspaceConfig);
283
- const stopwatch = getStopwatch(`${context.options.name} build`);
284
- await tsup({
285
- ...context.options,
286
- outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
287
- workspaceConfig: context.workspaceConfig
288
- });
289
- stopwatch();
290
- return context;
291
- }
292
- __name(executeTsup, "executeTsup");
293
- async function copyBuildAssets(context) {
294
- if (context.result?.errors.length === 0) {
295
- writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
296
- const stopwatch = getStopwatch(`${context.options.name} asset copy`);
297
- await copyAssets(context.workspaceConfig, context.options.assets ?? [], context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
298
- stopwatch();
299
- }
300
- return context;
301
- }
302
- __name(copyBuildAssets, "copyBuildAssets");
303
- async function reportResults(context) {
304
- if (context.result?.errors.length === 0) {
305
- if (context.result.warnings.length > 0) {
306
- writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`, context.workspaceConfig);
307
- }
308
- writeSuccess(` \u{1F4E6} The ${context.options.name} build completed successfully`, context.workspaceConfig);
309
- } else if (context.result?.errors && context.result?.errors.length > 0) {
310
- writeError(` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`, context.workspaceConfig);
311
- throw new Error(`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`);
312
- }
313
- }
314
- __name(reportResults, "reportResults");
315
- async function dependencyCheck(options) {
316
- if (process.env.DEV === "true") {
317
- return void 0;
318
- }
319
- if (process.env.CI && !process.env.BUILDKITE) {
320
- return void 0;
321
- }
322
- const buildPromise = esbuild.build({
323
- entryPoints: globbySync("**/*.{j,t}s", {
324
- // We don't check dependencies in ecosystem tests because tests are isolated from the build.
325
- ignore: [
326
- "./src/__tests__/**/*",
327
- "./tests/e2e/**/*",
328
- "./dist/**/*"
329
- ],
330
- gitignore: true
331
- }),
332
- logLevel: "silent",
333
- bundle: true,
334
- write: false,
335
- outdir: "out",
336
- plugins: [
337
- depsCheckPlugin(options.bundle)
338
- ]
339
- });
340
- await buildPromise.catch(() => {
341
- });
342
- return void 0;
343
- }
344
- __name(dependencyCheck, "dependencyCheck");
345
- async function cleanOutputPath(context) {
346
- if (context.clean !== false && context.outputPath) {
347
- writeDebug(` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`, context.workspaceConfig);
348
- const stopwatch = getStopwatch(`${context.options.name} output clean`);
349
- await cleanDirectories(context.outputPath);
350
- stopwatch();
351
- }
352
- return context;
353
- }
354
- __name(cleanOutputPath, "cleanOutputPath");
355
- async function build2(options) {
356
- writeDebug(` \u26A1 Executing Storm ESBuild pipeline`);
357
- const stopwatch = getStopwatch("ESBuild pipeline");
358
- try {
359
- const opts = Array.isArray(options) ? options : [
360
- options
361
- ];
362
- if (opts.length === 0) {
363
- throw new Error("No build options were provided");
364
- }
365
- const context = await resolveContext(options);
366
- await cleanOutputPath(context);
367
- await Promise.all([
368
- dependencyCheck(context.options),
369
- generatePackageJson(context),
370
- copyBuildAssets(context),
371
- executeTsup(context)
372
- ]);
373
- await reportResults(context);
374
- writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
375
- } catch (error) {
376
- writeFatal("Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
377
- throw error;
378
- } finally {
379
- stopwatch();
380
- }
381
- }
382
- __name(build2, "build");
383
- var watch = /* @__PURE__ */ __name((context, options) => {
384
- if (!options.watch) {
385
- return context;
386
- }
387
- const config = {
388
- ignoreInitial: true,
389
- useFsEvents: true,
390
- ignored: [
391
- "./src/__tests__/**/*",
392
- "./package.json"
393
- ]
394
- };
395
- const changeWatcher = createWatcher([
396
- "./src/**/*"
397
- ], config);
398
- const fastRebuild = debounce(async () => {
399
- const timeBefore = Date.now();
400
- const rebuildResult = await handle.async(() => {
401
- return context.rebuild();
402
- });
403
- if (rebuildResult instanceof Error) {
404
- writeError(rebuildResult.message);
405
- }
406
- writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
407
- }, 10);
408
- changeWatcher.on("change", fastRebuild);
409
- return void 0;
410
- }, "watch");
411
-
412
- export {
413
- handle,
414
- skip,
415
- Filter,
416
- Mapper,
417
- transduce,
418
- pipe,
419
- build2 as build,
420
- watch
421
- };
@@ -1,13 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
- }) : x)(function(x) {
6
- if (typeof require !== "undefined") return require.apply(this, arguments);
7
- throw Error('Dynamic require of "' + x + '" is not supported');
8
- });
9
-
10
-
11
-
12
-
13
- exports.__name = __name; exports.__require = __require;
@@ -1,167 +0,0 @@
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(); } } 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; } var _class;
2
-
3
- var _chunkY3LXNK5Ccjs = require('./chunk-Y3LXNK5C.cjs');
4
-
5
-
6
- var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
7
-
8
- // src/tsc.ts
9
- var _bundlerequire = require('bundle-require');
10
- var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
11
- var _fs = require('fs');
12
- var _path = require('path');
13
- var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
14
- function ensureTempDeclarationDir(workspaceConfig) {
15
- const root = workspaceConfig.directories.temp || _path.join.call(void 0, workspaceConfig.workspaceRoot, "tmp");
16
- const dirPath = _path.join.call(void 0, root, ".tsc", "declaration");
17
- if (_fs.existsSync.call(void 0, dirPath)) {
18
- return dirPath;
19
- }
20
- _fs.mkdirSync.call(void 0, dirPath, {
21
- recursive: true
22
- });
23
- const gitIgnorePath = _path.join.call(void 0, root, ".tsc", ".gitignore");
24
- _fs.writeFileSync.call(void 0, gitIgnorePath, "**/*\n");
25
- return dirPath;
26
- }
27
- _chunkBGYQAVKQcjs.__name.call(void 0, ensureTempDeclarationDir, "ensureTempDeclarationDir");
28
- function slash(path) {
29
- const isExtendedLengthPath = path.startsWith("\\\\?\\");
30
- if (isExtendedLengthPath) {
31
- return path;
32
- }
33
- return path.replace(/\\/g, "/");
34
- }
35
- _chunkBGYQAVKQcjs.__name.call(void 0, slash, "slash");
36
- function toAbsolutePath(workspaceConfig, p, cwd) {
37
- if (_path.isAbsolute.call(void 0, p)) {
38
- return p;
39
- }
40
- return slash(_path.normalize.call(void 0, _path.join.call(void 0, cwd || workspaceConfig.workspaceRoot, p)));
41
- }
42
- _chunkBGYQAVKQcjs.__name.call(void 0, toAbsolutePath, "toAbsolutePath");
43
- var AliasPool = (_class = class AliasPool2 {constructor() { _class.prototype.__init.call(this); }
44
- static {
45
- _chunkBGYQAVKQcjs.__name.call(void 0, this, "AliasPool");
46
- }
47
- __init() {this.seen = /* @__PURE__ */ new Set()}
48
- assign(name) {
49
- let suffix = 0;
50
- let alias = name === "default" ? "default_alias" : name;
51
- while (this.seen.has(alias)) {
52
- alias = `${name}_alias_${++suffix}`;
53
- if (suffix >= 1e3) {
54
- throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
55
- }
56
- }
57
- this.seen.add(alias);
58
- return alias;
59
- }
60
- }, _class);
61
- function getExports(workspaceConfig, program, fileMapping) {
62
- const checker = program.getTypeChecker();
63
- const aliasPool = new AliasPool();
64
- const assignAlias = aliasPool.assign.bind(aliasPool);
65
- function extractExports(sourceFileName) {
66
- const cwd = program.getCurrentDirectory();
67
- sourceFileName = toAbsolutePath(workspaceConfig, sourceFileName, cwd);
68
- const sourceFile = program.getSourceFile(sourceFileName);
69
- if (!sourceFile) {
70
- return [];
71
- }
72
- const destFileName = fileMapping.get(sourceFileName);
73
- if (!destFileName) {
74
- return [];
75
- }
76
- const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
77
- if (!moduleSymbol) {
78
- return [];
79
- }
80
- const exports = [];
81
- const exportSymbols = checker.getExportsOfModule(moduleSymbol);
82
- exportSymbols.forEach((symbol) => {
83
- const name = symbol.getName();
84
- exports.push({
85
- kind: "named",
86
- sourceFileName,
87
- destFileName,
88
- name,
89
- alias: assignAlias(name),
90
- isTypeOnly: false
91
- });
92
- });
93
- return exports;
94
- }
95
- _chunkBGYQAVKQcjs.__name.call(void 0, extractExports, "extractExports");
96
- return program.getRootFileNames().flatMap(extractExports);
97
- }
98
- _chunkBGYQAVKQcjs.__name.call(void 0, getExports, "getExports");
99
- function emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles = true, customTransformers) {
100
- const fileMapping = /* @__PURE__ */ new Map();
101
- const writeFile = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
102
- const sourceFile = _optionalChain([sourceFiles, 'optionalAccess', _ => _[0]]);
103
- const sourceFileName = _optionalChain([sourceFile, 'optionalAccess', _2 => _2.fileName]);
104
- if (sourceFileName && !fileName.endsWith(".map")) {
105
- const cwd = program.getCurrentDirectory();
106
- fileMapping.set(toAbsolutePath(workspaceConfig, sourceFileName, cwd), toAbsolutePath(workspaceConfig, fileName, cwd));
107
- }
108
- return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
109
- }, "writeFile");
110
- const emitResult = program.emit(void 0, writeFile, void 0, emitOnlyDtsFiles, customTransformers);
111
- const diagnostics = _typescript2.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
112
- const diagnosticMessages = [];
113
- diagnostics.forEach((diagnostic) => {
114
- if (diagnostic.file) {
115
- const { line, character } = _typescript2.default.getLineAndCharacterOfPosition(
116
- diagnostic.file,
117
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
118
- diagnostic.start
119
- );
120
- const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
121
- diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
122
- } else {
123
- const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
124
- diagnosticMessages.push(message);
125
- }
126
- });
127
- const diagnosticMessage = diagnosticMessages.join("\n");
128
- if (diagnosticMessage) {
129
- _chunkY3LXNK5Ccjs.writeError.call(void 0, `Failed to emit declaration files.
130
-
131
- ${diagnosticMessage}`, workspaceConfig);
132
- throw new Error("TypeScript compilation failed");
133
- }
134
- return fileMapping;
135
- }
136
- _chunkBGYQAVKQcjs.__name.call(void 0, emitDtsFiles, "emitDtsFiles");
137
- function emitDts(workspaceConfig, tsconfig, tsconfigRaw, emitOnlyDtsFiles = true, customTransformers) {
138
- const rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, workspaceConfig.workspaceRoot, tsconfig);
139
- if (!rawTsconfig) {
140
- throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${workspaceConfig.workspaceRoot}`);
141
- }
142
- const declarationDir = ensureTempDeclarationDir(workspaceConfig);
143
- const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent(_defu2.default.call(void 0, {
144
- compilerOptions: {
145
- // Enable declaration emit and disable javascript emit
146
- noEmit: false,
147
- declaration: true,
148
- declarationMap: true,
149
- declarationDir,
150
- emitDeclarationOnly: true
151
- }
152
- }, _nullishCoalesce(_optionalChain([tsconfigRaw, 'optionalAccess', _3 => _3.compilerOptions]), () => ( {})), _nullishCoalesce(rawTsconfig.data, () => ( {}))), _typescript2.default.sys, tsconfig ? _path.dirname.call(void 0, tsconfig) : "./");
153
- const options = parsedTsconfig.options;
154
- const host = _typescript2.default.createCompilerHost(options);
155
- const program = _typescript2.default.createProgram(parsedTsconfig.fileNames, options, host);
156
- const fileMapping = emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles, customTransformers);
157
- return getExports(workspaceConfig, program, fileMapping);
158
- }
159
- _chunkBGYQAVKQcjs.__name.call(void 0, emitDts, "emitDts");
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- exports.ensureTempDeclarationDir = ensureTempDeclarationDir; exports.slash = slash; exports.toAbsolutePath = toAbsolutePath; exports.emitDtsFiles = emitDtsFiles; exports.emitDts = emitDts;
@@ -1,29 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
5
-
6
- // src/plugins/fix-imports.ts
7
- var fixImportsPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options, resolvedOptions) => ({
8
- name: "storm:fix-imports",
9
- setup(build) {
10
- build.onResolve({
11
- filter: /^spdx-exceptions/
12
- }, () => {
13
- return {
14
- path: _chunkBGYQAVKQcjs.__require.resolve("spdx-exceptions")
15
- };
16
- });
17
- build.onResolve({
18
- filter: /^spdx-license-ids/
19
- }, () => {
20
- return {
21
- path: _chunkBGYQAVKQcjs.__require.resolve("spdx-license-ids")
22
- };
23
- });
24
- }
25
- }), "fixImportsPlugin");
26
-
27
-
28
-
29
- exports.fixImportsPlugin = fixImportsPlugin;
@@ -1,27 +0,0 @@
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
-
3
- var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
4
-
5
- // src/plugins/esm-split-code-to-cjs.ts
6
- var _esbuild = require('esbuild'); var esbuild = _interopRequireWildcard(_esbuild);
7
- var esmSplitCodeToCjsPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options, resolvedOptions) => ({
8
- name: "storm:esm-split-code-to-cjs",
9
- setup(build2) {
10
- build2.onEnd(async (result) => {
11
- const outFiles = Object.keys(_nullishCoalesce(_optionalChain([result, 'access', _ => _.metafile, 'optionalAccess', _2 => _2.outputs]), () => ( {})));
12
- const jsFiles = outFiles.filter((f) => f.endsWith("js"));
13
- await esbuild.build({
14
- outdir: resolvedOptions.outputPath,
15
- entryPoints: jsFiles,
16
- allowOverwrite: true,
17
- format: "cjs",
18
- logLevel: "error",
19
- packages: "external"
20
- });
21
- });
22
- }
23
- }), "esmSplitCodeToCjsPlugin");
24
-
25
-
26
-
27
- exports.esmSplitCodeToCjsPlugin = esmSplitCodeToCjsPlugin;
@@ -1,29 +0,0 @@
1
- import {
2
- __name,
3
- __require
4
- } from "./chunk-3GQAWCBQ.js";
5
-
6
- // src/plugins/fix-imports.ts
7
- var fixImportsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
8
- name: "storm:fix-imports",
9
- setup(build) {
10
- build.onResolve({
11
- filter: /^spdx-exceptions/
12
- }, () => {
13
- return {
14
- path: __require.resolve("spdx-exceptions")
15
- };
16
- });
17
- build.onResolve({
18
- filter: /^spdx-license-ids/
19
- }, () => {
20
- return {
21
- path: __require.resolve("spdx-license-ids")
22
- };
23
- });
24
- }
25
- }), "fixImportsPlugin");
26
-
27
- export {
28
- fixImportsPlugin
29
- };