@storm-software/workspace-tools 1.266.9 → 1.267.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 (154) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/dist/{chunk-Z2D5X5KJ.mjs → chunk-2C37GBZ2.mjs} +2 -2
  4. package/dist/{chunk-5AVEZVE5.mjs → chunk-2TEC7IFE.mjs} +4 -4
  5. package/dist/{chunk-WBNGMFYP.js → chunk-4Y6B6JDH.js} +11 -11
  6. package/dist/{chunk-K7B7YVQF.mjs → chunk-5I7ULQZF.mjs} +1 -1
  7. package/dist/{chunk-JL5QGFBX.js → chunk-6CGAYKQL.js} +20 -20
  8. package/dist/{chunk-BJ6UNKNM.js → chunk-6JJB5AYA.js} +9 -9
  9. package/dist/{chunk-TKGD3SNO.mjs → chunk-7FHFHZRB.mjs} +1 -1
  10. package/dist/{chunk-Z255YQZR.js → chunk-7NNHBZC5.js} +2 -2
  11. package/dist/{chunk-HYRQEEMO.js → chunk-7PRHEOCT.js} +2 -2
  12. package/dist/{chunk-UBMOQCNN.js → chunk-B3DVFXXD.js} +2 -2
  13. package/dist/{chunk-5G2XZTUU.mjs → chunk-BFGWJ7BS.mjs} +4 -4
  14. package/dist/{chunk-YWAH4DHJ.mjs → chunk-BJMT4ECA.mjs} +3 -3
  15. package/dist/chunk-BUPROWVS.js +653 -0
  16. package/dist/{chunk-4UPFP6EX.mjs → chunk-CM2FQCBL.mjs} +3 -3
  17. package/dist/{chunk-VUIT3ZAI.mjs → chunk-CNCYVRZ4.mjs} +1 -1
  18. package/dist/{chunk-NCTH2PTP.mjs → chunk-EHFWY65U.mjs} +3 -3
  19. package/dist/{chunk-XGSZL5N7.mjs → chunk-FM2TFXVW.mjs} +4 -4
  20. package/dist/{chunk-7LP6KWJ4.mjs → chunk-FPAOVOZX.mjs} +3 -3
  21. package/dist/{chunk-MP2P2MGP.js → chunk-G4QFSE5B.js} +8 -5
  22. package/dist/{chunk-2RRVYK6E.mjs → chunk-GNFQ5PGW.mjs} +1 -1
  23. package/dist/{chunk-E2GASAYN.js → chunk-HOXPAVCL.js} +2 -2
  24. package/dist/{chunk-TBE7H5P7.js → chunk-ICPUM2HS.js} +5 -5
  25. package/dist/{chunk-36QIKTAL.mjs → chunk-IXHY3ZPO.mjs} +3 -3
  26. package/dist/{chunk-TCZC6XD6.mjs → chunk-IZHZKPHV.mjs} +12 -9
  27. package/dist/{chunk-SORZ4BJW.mjs → chunk-KP5JD22G.mjs} +4 -4
  28. package/dist/{chunk-A2Z3X5GK.mjs → chunk-LS27TGDZ.mjs} +2 -2
  29. package/dist/chunk-LUR7U35A.mjs +653 -0
  30. package/dist/{chunk-QDLQJ3QS.mjs → chunk-MFSIJSBW.mjs} +3 -3
  31. package/dist/{chunk-L6BH2OLB.mjs → chunk-MIVNJALE.mjs} +1 -1
  32. package/dist/{chunk-XRZPNGM5.mjs → chunk-N4QRXJLZ.mjs} +2 -2
  33. package/dist/{chunk-VGSUCQ2S.mjs → chunk-N7GSKHH2.mjs} +1 -1
  34. package/dist/{chunk-4CLX5NBT.js → chunk-NSCWEC2S.js} +2 -2
  35. package/dist/{chunk-YWHLDLKE.js → chunk-OKW5O5P4.js} +5 -5
  36. package/dist/{chunk-YT3ECNTF.js → chunk-OQPX75CG.js} +2 -2
  37. package/dist/{chunk-5NTNN2XK.mjs → chunk-OW6VGYDT.mjs} +1 -1
  38. package/dist/{chunk-TPWVZZWY.js → chunk-P4OVFIT6.js} +2 -2
  39. package/dist/{chunk-YMFIVYHZ.mjs → chunk-PGEZGCU2.mjs} +2 -2
  40. package/dist/{chunk-GEIXDGFR.mjs → chunk-PZL7IZ7I.mjs} +2 -2
  41. package/dist/{chunk-4FJCOFII.mjs → chunk-Q7WXH4GA.mjs} +3 -3
  42. package/dist/{chunk-LY5IGOQR.mjs → chunk-QXE7GTBY.mjs} +3 -3
  43. package/dist/{chunk-KWARMR7G.mjs → chunk-RMLZO26I.mjs} +4 -4
  44. package/dist/{chunk-USRO6ZCF.mjs → chunk-RPMGDH44.mjs} +2 -2
  45. package/dist/{chunk-G4S2HWXN.js → chunk-RUKOOSWL.js} +2 -2
  46. package/dist/{chunk-474QFQKX.mjs → chunk-SYTBJXTM.mjs} +1 -1
  47. package/dist/{chunk-NYP6AVTV.js → chunk-TET4GF3D.js} +2 -2
  48. package/dist/{chunk-IOUCRBHV.mjs → chunk-TPK3STUY.mjs} +4 -4
  49. package/dist/{chunk-WHITLY6G.mjs → chunk-TRD4W5ZK.mjs} +4 -4
  50. package/dist/{chunk-TMCMTZPP.mjs → chunk-UY3Q5IDT.mjs} +1 -1
  51. package/dist/{chunk-KDQGKQHN.mjs → chunk-V42FQ4FR.mjs} +3 -3
  52. package/dist/{chunk-FJ3HUDJN.mjs → chunk-WAXAZ5PV.mjs} +3 -3
  53. package/dist/{chunk-VFXWLOY7.mjs → chunk-WDFR6LVR.mjs} +2 -2
  54. package/dist/{chunk-D2OJX4DZ.mjs → chunk-XCBLUQPM.mjs} +3 -3
  55. package/dist/{chunk-QIF3QXOA.mjs → chunk-XYRHMXLC.mjs} +3 -3
  56. package/dist/{chunk-Z4WOCHYB.mjs → chunk-YHPRTWSY.mjs} +2 -2
  57. package/dist/{chunk-PKL7UOGQ.js → chunk-YW4UN25U.js} +4 -4
  58. package/dist/{chunk-NCV26VAW.js → chunk-Z4NKRWWJ.js} +15 -15
  59. package/dist/{chunk-3DMOUTDH.mjs → chunk-Z6GV7C5U.mjs} +1 -1
  60. package/dist/{chunk-TIOK7TNA.mjs → chunk-ZJ3QSWTQ.mjs} +4 -4
  61. package/dist/executors.js +14 -14
  62. package/dist/executors.mjs +28 -28
  63. package/dist/generators.js +10 -10
  64. package/dist/generators.mjs +21 -21
  65. package/dist/index.js +22 -22
  66. package/dist/index.mjs +51 -51
  67. package/dist/src/base/base-executor.js +3 -3
  68. package/dist/src/base/base-executor.mjs +6 -6
  69. package/dist/src/base/base-executor.untyped.mjs +1 -1
  70. package/dist/src/base/base-generator.js +3 -3
  71. package/dist/src/base/base-generator.mjs +6 -6
  72. package/dist/src/base/base-generator.untyped.mjs +1 -1
  73. package/dist/src/base/cargo-base-executor.untyped.mjs +1 -1
  74. package/dist/src/base/index.js +4 -4
  75. package/dist/src/base/index.mjs +10 -10
  76. package/dist/src/base/typescript-build-executor.untyped.mjs +2 -2
  77. package/dist/src/base/typescript-library-generator.untyped.mjs +1 -1
  78. package/dist/src/executors/cargo-build/executor.js +4 -4
  79. package/dist/src/executors/cargo-build/executor.mjs +8 -8
  80. package/dist/src/executors/cargo-build/untyped.mjs +1 -1
  81. package/dist/src/executors/cargo-check/executor.js +4 -4
  82. package/dist/src/executors/cargo-check/executor.mjs +8 -8
  83. package/dist/src/executors/cargo-check/untyped.mjs +1 -1
  84. package/dist/src/executors/cargo-clippy/executor.js +4 -4
  85. package/dist/src/executors/cargo-clippy/executor.mjs +8 -8
  86. package/dist/src/executors/cargo-clippy/untyped.mjs +1 -1
  87. package/dist/src/executors/cargo-doc/executor.js +4 -4
  88. package/dist/src/executors/cargo-doc/executor.mjs +8 -8
  89. package/dist/src/executors/cargo-doc/untyped.mjs +1 -1
  90. package/dist/src/executors/cargo-format/executor.js +4 -4
  91. package/dist/src/executors/cargo-format/executor.mjs +8 -8
  92. package/dist/src/executors/cargo-format/untyped.mjs +1 -1
  93. package/dist/src/executors/cargo-publish/executor.mjs +3 -3
  94. package/dist/src/executors/cargo-publish/untyped.mjs +1 -1
  95. package/dist/src/executors/clean-package/executor.js +5 -5
  96. package/dist/src/executors/clean-package/executor.mjs +6 -6
  97. package/dist/src/executors/clean-package/untyped.mjs +1 -1
  98. package/dist/src/executors/esbuild/executor.js +4 -4
  99. package/dist/src/executors/esbuild/executor.mjs +7 -7
  100. package/dist/src/executors/esbuild/untyped.mjs +2 -2
  101. package/dist/src/executors/npm-publish/executor.mjs +4 -4
  102. package/dist/src/executors/npm-publish/untyped.mjs +1 -1
  103. package/dist/src/executors/size-limit/executor.js +4 -4
  104. package/dist/src/executors/size-limit/executor.mjs +7 -7
  105. package/dist/src/executors/size-limit/untyped.mjs +1 -1
  106. package/dist/src/executors/typia/executor.js +4 -4
  107. package/dist/src/executors/typia/executor.mjs +7 -7
  108. package/dist/src/executors/typia/untyped.mjs +1 -1
  109. package/dist/src/executors/unbuild/executor.js +4 -4
  110. package/dist/src/executors/unbuild/executor.mjs +7 -7
  111. package/dist/src/executors/unbuild/untyped.mjs +2 -2
  112. package/dist/src/generators/browser-library/generator.js +4 -4
  113. package/dist/src/generators/browser-library/generator.mjs +9 -9
  114. package/dist/src/generators/browser-library/untyped.mjs +1 -1
  115. package/dist/src/generators/config-schema/generator.js +4 -4
  116. package/dist/src/generators/config-schema/generator.mjs +7 -7
  117. package/dist/src/generators/config-schema/untyped.mjs +1 -1
  118. package/dist/src/generators/init/init.mjs +2 -2
  119. package/dist/src/generators/init/untyped.mjs +1 -1
  120. package/dist/src/generators/neutral-library/generator.js +4 -4
  121. package/dist/src/generators/neutral-library/generator.mjs +9 -9
  122. package/dist/src/generators/neutral-library/untyped.mjs +1 -1
  123. package/dist/src/generators/node-library/generator.js +4 -4
  124. package/dist/src/generators/node-library/generator.mjs +9 -9
  125. package/dist/src/generators/node-library/untyped.mjs +1 -1
  126. package/dist/src/generators/preset/generator.js +4 -4
  127. package/dist/src/generators/preset/generator.mjs +7 -7
  128. package/dist/src/generators/preset/untyped.mjs +1 -1
  129. package/dist/src/generators/release-version/generator.js +3 -3
  130. package/dist/src/generators/release-version/generator.mjs +6 -6
  131. package/dist/src/generators/release-version/untyped.mjs +1 -1
  132. package/dist/src/plugins/rust/cargo-toml.mjs +4 -4
  133. package/dist/src/plugins/rust/index.mjs +4 -4
  134. package/dist/src/plugins/typescript/index.mjs +4 -4
  135. package/dist/src/plugins/typescript/project-config.mjs +4 -4
  136. package/dist/src/plugins/typescript/tsup.mjs +2 -2
  137. package/dist/src/plugins/typescript/untyped-schema.mjs +2 -2
  138. package/dist/src/types.mjs +1 -1
  139. package/dist/src/utils/apply-workspace-tokens.mjs +4 -4
  140. package/dist/src/utils/cargo.mjs +2 -2
  141. package/dist/src/utils/create-cli-options.mjs +2 -2
  142. package/dist/src/utils/get-project-configurations.mjs +4 -4
  143. package/dist/src/utils/index.mjs +14 -14
  144. package/dist/src/utils/lock-file.mjs +2 -2
  145. package/dist/src/utils/package-helpers.mjs +4 -4
  146. package/dist/src/utils/plugin-helpers.mjs +3 -3
  147. package/dist/src/utils/pnpm-deps-update.mjs +3 -3
  148. package/dist/src/utils/project-tags.mjs +2 -2
  149. package/dist/src/utils/toml.mjs +2 -2
  150. package/dist/src/utils/typia-transform.mjs +2 -2
  151. package/dist/src/utils/versions.mjs +1 -1
  152. package/package.json +2 -2
  153. package/dist/chunk-JDFMHRPQ.mjs +0 -1533
  154. package/dist/chunk-OWBD5WVM.js +0 -1532
@@ -1,1533 +0,0 @@
1
- import {
2
- withRunExecutor
3
- } from "./chunk-5AVEZVE5.mjs";
4
- import {
5
- formatLogMessage,
6
- getConfig,
7
- getStopwatch,
8
- isVerbose,
9
- writeDebug,
10
- writeError,
11
- writeFatal,
12
- writeInfo,
13
- writeSuccess,
14
- writeTrace,
15
- writeWarning
16
- } from "./chunk-TCZC6XD6.mjs";
17
- import {
18
- findWorkspaceRoot
19
- } from "./chunk-VFXWLOY7.mjs";
20
- import {
21
- correctPaths,
22
- joinPaths
23
- } from "./chunk-K7B7YVQF.mjs";
24
- import {
25
- __dirname,
26
- __name,
27
- __require
28
- } from "./chunk-VGSUCQ2S.mjs";
29
-
30
- // ../esbuild/src/build.ts
31
- import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2, writeJsonFile } from "@nx/devkit";
32
-
33
- // ../build-tools/src/config.ts
34
- var DEFAULT_COMPILED_BANNER = `/*****************************************
35
- *
36
- * \u26A1 Built by Storm Software
37
- *
38
- *****************************************/
39
- `;
40
- var DEFAULT_ENVIRONMENT = "production";
41
- var DEFAULT_TARGET = "esnext";
42
- var DEFAULT_ORGANIZATION = "storm-software";
43
-
44
- // ../build-tools/src/plugins/swc.ts
45
- import { transform } from "@swc/core";
46
-
47
- // ../build-tools/src/plugins/ts-resolve.ts
48
- import fs from "node:fs";
49
- import { builtinModules } from "node:module";
50
- import path from "node:path";
51
- import _resolve from "resolve";
52
-
53
- // ../build-tools/src/plugins/type-definitions.ts
54
- import { stripIndents } from "@nx/devkit";
55
- import { relative } from "path";
56
-
57
- // ../build-tools/src/utilities/copy-assets.ts
58
- import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
59
- import { glob } from "glob";
60
- import { readFile, writeFile } from "node:fs/promises";
61
- var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
62
- const pendingAssets = Array.from(assets ?? []);
63
- pendingAssets.push({
64
- input: projectRoot,
65
- glob: "*.md",
66
- output: "."
67
- });
68
- pendingAssets.push({
69
- input: ".",
70
- glob: "LICENSE",
71
- output: "."
72
- });
73
- if (generatePackageJson2 === false) {
74
- pendingAssets.push({
75
- input: projectRoot,
76
- glob: "package.json",
77
- output: "."
78
- });
79
- }
80
- if (includeSrc === true) {
81
- pendingAssets.push({
82
- input: sourceRoot,
83
- glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
84
- output: "src/"
85
- });
86
- }
87
- writeTrace(`\u{1F4DD} Copying the following assets to the output directory:
88
- ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`, config);
89
- const assetHandler = new CopyAssetsHandler({
90
- projectDir: projectRoot,
91
- rootDir: config.workspaceRoot,
92
- outputDir: outputPath,
93
- assets: pendingAssets
94
- });
95
- await assetHandler.processAllAssetsOnce();
96
- if (includeSrc === true) {
97
- writeDebug(`\u{1F4DD} Adding banner and writing source files: ${joinPaths(outputPath, "src")}`, config);
98
- const files = await glob([
99
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
100
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
101
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
102
- joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
103
- ]);
104
- await Promise.allSettled(files.map(async (file) => writeFile(file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
105
-
106
- ${await readFile(file, "utf8")}
107
-
108
- ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`)));
109
- }
110
- }, "copyAssets");
111
-
112
- // ../build-tools/src/utilities/generate-package-json.ts
113
- import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
114
- import { Glob } from "glob";
115
- import { existsSync, readFileSync } from "node:fs";
116
- import { readFile as readFile2 } from "node:fs/promises";
117
- import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "nx/src/project-graph/project-graph";
118
- var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projectRoot, projectName, packageJson) => {
119
- const projectGraph = readCachedProjectGraph();
120
- const projectDependencies = calculateProjectBuildableDependencies(void 0, projectGraph, workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
121
- const localPackages = [];
122
- for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data?.root !== projectRoot && dep.node.data?.root !== workspaceRoot)) {
123
- const projectNode = project.node;
124
- if (projectNode.data.root) {
125
- const projectPackageJsonPath = joinPaths(workspaceRoot, projectNode.data.root, "package.json");
126
- if (existsSync(projectPackageJsonPath)) {
127
- const projectPackageJsonContent = await readFile2(projectPackageJsonPath, "utf8");
128
- const projectPackageJson = JSON.parse(projectPackageJsonContent);
129
- if (projectPackageJson.private !== true) {
130
- localPackages.push(projectPackageJson);
131
- }
132
- }
133
- }
134
- }
135
- if (localPackages.length > 0) {
136
- writeTrace(`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
137
- const projectJsonFile = await readFile2(joinPaths(projectRoot, "project.json"), "utf8");
138
- const projectJson = JSON.parse(projectJsonFile);
139
- const projectName2 = projectJson.name;
140
- const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
141
- if (!projectConfigurations?.projects?.[projectName2]) {
142
- 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.");
143
- }
144
- const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
145
- if (projectConfigurations.projects?.[dep]) {
146
- const depPackageJsonPath = joinPaths(workspaceRoot, projectConfigurations.projects[dep].root, "package.json");
147
- if (existsSync(depPackageJsonPath)) {
148
- const depPackageJsonContent = readFileSync(depPackageJsonPath, "utf8");
149
- const depPackageJson = JSON.parse(depPackageJsonContent);
150
- if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
151
- ret.push(depPackageJson.name);
152
- }
153
- }
154
- }
155
- return ret;
156
- }, []);
157
- packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
158
- if (!ret[localPackage.name] && !implicitDependencies?.includes(localPackage.name) && packageJson.devDependencies?.[localPackage.name] === void 0) {
159
- ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
160
- }
161
- return ret;
162
- }, packageJson.dependencies ?? {});
163
- packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
164
- if (!ret[localPackage.name] && implicitDependencies?.includes(localPackage.name) && packageJson.dependencies?.[localPackage.name] === void 0) {
165
- ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
166
- }
167
- return ret;
168
- }, packageJson.devDependencies ?? {});
169
- } else {
170
- writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
171
- }
172
- return packageJson;
173
- }, "addPackageDependencies");
174
- var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
175
- const workspaceRoot = config.workspaceRoot ? config.workspaceRoot : findWorkspaceRoot();
176
- const workspacePackageJsonContent = await readFile2(joinPaths(workspaceRoot, "package.json"), "utf8");
177
- const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
178
- packageJson.type ??= "module";
179
- packageJson.sideEffects ??= false;
180
- if (includeSrc === true) {
181
- let distSrc = sourceRoot.replace(projectRoot, "");
182
- if (distSrc.startsWith("/")) {
183
- distSrc = distSrc.substring(1);
184
- }
185
- packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
186
- }
187
- packageJson.files ??= [
188
- "dist/**/*"
189
- ];
190
- if (includeSrc === true && !packageJson.files.includes("src")) {
191
- packageJson.files.push("src/**/*");
192
- }
193
- packageJson.publishConfig ??= {
194
- access: "public"
195
- };
196
- packageJson.description ??= workspacePackageJson.description;
197
- packageJson.homepage ??= workspacePackageJson.homepage;
198
- packageJson.bugs ??= workspacePackageJson.bugs;
199
- packageJson.license ??= workspacePackageJson.license;
200
- packageJson.keywords ??= workspacePackageJson.keywords;
201
- packageJson.funding ??= workspacePackageJson.funding;
202
- packageJson.author ??= workspacePackageJson.author;
203
- packageJson.maintainers ??= workspacePackageJson.maintainers;
204
- if (!packageJson.maintainers && packageJson.author) {
205
- packageJson.maintainers = [
206
- packageJson.author
207
- ];
208
- }
209
- packageJson.contributors ??= workspacePackageJson.contributors;
210
- if (!packageJson.contributors && packageJson.author) {
211
- packageJson.contributors = [
212
- packageJson.author
213
- ];
214
- }
215
- packageJson.repository ??= workspacePackageJson.repository;
216
- packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
217
- return packageJson;
218
- }, "addWorkspacePackageJsonFields");
219
-
220
- // ../config-tools/src/utilities/run.ts
221
- import { exec, execSync } from "node:child_process";
222
- var LARGE_BUFFER = 1024 * 1e6;
223
- var run = /* @__PURE__ */ __name((config, command, cwd = config.workspaceRoot ?? process.cwd(), stdio = "inherit", env = process.env) => {
224
- return execSync(command, {
225
- cwd,
226
- env: {
227
- ...process.env,
228
- ...env,
229
- CLICOLOR: "true",
230
- FORCE_COLOR: "true"
231
- },
232
- windowsHide: true,
233
- stdio,
234
- maxBuffer: LARGE_BUFFER,
235
- killSignal: "SIGTERM"
236
- });
237
- }, "run");
238
-
239
- // ../build-tools/src/utilities/get-entry-points.ts
240
- import { glob as glob2 } from "glob";
241
-
242
- // ../build-tools/src/utilities/get-env.ts
243
- var getEnv = /* @__PURE__ */ __name((builder, options) => {
244
- return {
245
- STORM_BUILD: builder,
246
- STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
247
- STORM_NAME: options.name,
248
- STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
249
- STORM_PLATFORM: options.platform,
250
- STORM_FORMAT: JSON.stringify(options.format),
251
- STORM_TARGET: JSON.stringify(options.target),
252
- ...options.env
253
- };
254
- }, "getEnv");
255
-
256
- // ../build-tools/src/utilities/read-nx-config.ts
257
- import { existsSync as existsSync2 } from "node:fs";
258
- import { readFile as readFile3 } from "node:fs/promises";
259
-
260
- // ../build-tools/src/utilities/task-graph.ts
261
- import { createTaskGraph, mapTargetDefaultsToDependencies } from "nx/src/tasks-runner/create-task-graph";
262
-
263
- // ../esbuild/src/build.ts
264
- import { watch as createWatcher } from "chokidar";
265
- import defu2 from "defu";
266
- import { debounce, flatten } from "es-toolkit";
267
- import { map } from "es-toolkit/compat";
268
- import * as esbuild2 from "esbuild";
269
- import { globbySync } from "globby";
270
- import { existsSync as existsSync5 } from "node:fs";
271
- import hf from "node:fs/promises";
272
- import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
273
-
274
- // ../esbuild/src/base/renderer-engine.ts
275
- import path3 from "node:path";
276
- import { SourceMapConsumer, SourceMapGenerator } from "source-map";
277
-
278
- // ../esbuild/src/utilities/output-file.ts
279
- import fs2 from "node:fs";
280
- import path2 from "node:path";
281
- var outputFile = /* @__PURE__ */ __name(async (filepath, data, options) => {
282
- await fs2.promises.mkdir(path2.dirname(filepath), {
283
- recursive: true
284
- });
285
- await fs2.promises.writeFile(filepath, data, options);
286
- }, "outputFile");
287
-
288
- // ../esbuild/src/base/renderer-engine.ts
289
- var parseSourceMap = /* @__PURE__ */ __name((map2) => {
290
- return typeof map2 === "string" ? JSON.parse(map2) : map2;
291
- }, "parseSourceMap");
292
- var isJS = /* @__PURE__ */ __name((path6) => /\.(js|mjs|cjs)$/.test(path6), "isJS");
293
- var isCSS = /* @__PURE__ */ __name((path6) => /\.css$/.test(path6), "isCSS");
294
- var getSourcemapComment = /* @__PURE__ */ __name((inline, map2, filepath, isCssFile) => {
295
- if (!map2) return "";
296
- const prefix = isCssFile ? "/*" : "//";
297
- const suffix = isCssFile ? " */" : "";
298
- const url = inline ? `data:application/json;base64,${Buffer.from(typeof map2 === "string" ? map2 : JSON.stringify(map2)).toString("base64")}` : `${path3.basename(filepath)}.map`;
299
- return `${prefix}# sourceMappingURL=${url}${suffix}`;
300
- }, "getSourcemapComment");
301
- var RendererEngine = class {
302
- static {
303
- __name(this, "RendererEngine");
304
- }
305
- #renderers;
306
- #options;
307
- constructor(renderers) {
308
- this.#renderers = renderers;
309
- }
310
- setOptions(options) {
311
- this.#options = options;
312
- }
313
- getOptions() {
314
- if (!this.#options) {
315
- throw new Error(`Renderer options is not set`);
316
- }
317
- return this.#options;
318
- }
319
- modifyEsbuildOptions(options) {
320
- for (const renderer of this.#renderers) {
321
- if (renderer.esbuildOptions) {
322
- renderer.esbuildOptions.call(this.getOptions(), options);
323
- }
324
- }
325
- }
326
- async buildStarted() {
327
- for (const renderer of this.#renderers) {
328
- if (renderer.buildStart) {
329
- await renderer.buildStart.call(this.getOptions());
330
- }
331
- }
332
- }
333
- async buildFinished({ outputFiles, metafile }) {
334
- const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
335
- if (isJS(file.path) || isCSS(file.path)) {
336
- let relativePath = path3.relative(this.getOptions().config.workspaceRoot, file.path);
337
- if (!relativePath.startsWith("\\\\?\\")) {
338
- relativePath = relativePath.replace(/\\/g, "/");
339
- }
340
- const meta = metafile?.outputs[relativePath];
341
- return {
342
- type: "chunk",
343
- path: file.path,
344
- code: file.text,
345
- map: outputFiles.find((f) => f.path === `${file.path}.map`)?.text,
346
- entryPoint: meta?.entryPoint,
347
- exports: meta?.exports,
348
- imports: meta?.imports
349
- };
350
- } else {
351
- return {
352
- type: "asset",
353
- path: file.path,
354
- contents: file.contents
355
- };
356
- }
357
- });
358
- const writtenFiles = [];
359
- await Promise.all(files.map(async (info) => {
360
- for (const renderer of this.#renderers) {
361
- if (info.type === "chunk" && renderer.renderChunk) {
362
- const result = await renderer.renderChunk.call(this.getOptions(), info.code, info);
363
- if (result) {
364
- info.code = result.code;
365
- if (result.map) {
366
- const originalConsumer = await new SourceMapConsumer(parseSourceMap(info.map));
367
- const newConsumer = await new SourceMapConsumer(parseSourceMap(result.map));
368
- const generator = SourceMapGenerator.fromSourceMap(newConsumer);
369
- generator.applySourceMap(originalConsumer, info.path);
370
- info.map = generator.toJSON();
371
- originalConsumer.destroy();
372
- newConsumer.destroy();
373
- }
374
- }
375
- }
376
- }
377
- const inlineSourceMap = this.#options.sourcemap === "inline";
378
- const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents;
379
- await outputFile(info.path, contents, {
380
- mode: info.type === "chunk" ? info.mode : void 0
381
- });
382
- writtenFiles.push({
383
- get name() {
384
- return path3.relative(process.cwd(), info.path);
385
- },
386
- get size() {
387
- return contents.length;
388
- }
389
- });
390
- if (info.type === "chunk" && info.map && !inlineSourceMap) {
391
- const map2 = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
392
- const outPath = `${info.path}.map`;
393
- const contents2 = JSON.stringify(map2);
394
- await outputFile(outPath, contents2);
395
- writtenFiles.push({
396
- get name() {
397
- return path3.relative(process.cwd(), outPath);
398
- },
399
- get size() {
400
- return contents2.length;
401
- }
402
- });
403
- }
404
- }));
405
- for (const renderer of this.#renderers) {
406
- if (renderer.buildEnd) {
407
- await renderer.buildEnd.call(this.getOptions(), {
408
- writtenFiles
409
- });
410
- }
411
- }
412
- }
413
- };
414
-
415
- // ../esbuild/src/clean.ts
416
- import { rm } from "node:fs/promises";
417
- async function cleanDirectories(name = "ESBuild", directory, config) {
418
- await rm(directory, {
419
- recursive: true,
420
- force: true
421
- });
422
- }
423
- __name(cleanDirectories, "cleanDirectories");
424
-
425
- // ../esbuild/src/plugins/esm-split-code-to-cjs.ts
426
- import * as esbuild from "esbuild";
427
- var esmSplitCodeToCjsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
428
- name: "storm:esm-split-code-to-cjs",
429
- setup(build4) {
430
- build4.onEnd(async (result) => {
431
- const outFiles = Object.keys(result.metafile?.outputs ?? {});
432
- const jsFiles = outFiles.filter((f) => f.endsWith("js"));
433
- await esbuild.build({
434
- outdir: resolvedOptions.outdir,
435
- entryPoints: jsFiles,
436
- allowOverwrite: true,
437
- format: "cjs",
438
- logLevel: "error",
439
- packages: "external"
440
- });
441
- });
442
- }
443
- }), "esmSplitCodeToCjsPlugin");
444
-
445
- // ../esbuild/src/plugins/fix-imports.ts
446
- var fixImportsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
447
- name: "storm:fix-imports",
448
- setup(build4) {
449
- build4.onResolve({
450
- filter: /^spdx-exceptions/
451
- }, () => {
452
- return {
453
- path: __require.resolve("spdx-exceptions")
454
- };
455
- });
456
- build4.onResolve({
457
- filter: /^spdx-license-ids/
458
- }, () => {
459
- return {
460
- path: __require.resolve("spdx-license-ids")
461
- };
462
- });
463
- }
464
- }), "fixImportsPlugin");
465
-
466
- // ../esbuild/src/plugins/native-node-module.ts
467
- import { dirname } from "node:path";
468
- var nativeNodeModulesPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
469
- return {
470
- name: "native-node-modules",
471
- setup(build4) {
472
- build4.onResolve({
473
- filter: /\.node$/,
474
- namespace: "file"
475
- }, (args) => {
476
- const resolvedId = __require.resolve(args.path, {
477
- paths: [
478
- args.resolveDir
479
- ]
480
- });
481
- if (resolvedId.endsWith(".node")) {
482
- return {
483
- path: resolvedId,
484
- namespace: "node-file"
485
- };
486
- }
487
- return {
488
- path: resolvedId
489
- };
490
- });
491
- build4.onLoad({
492
- filter: /.*/,
493
- namespace: "node-file"
494
- }, (args) => {
495
- return {
496
- contents: `
497
- import path from ${JSON.stringify(args.path)}
498
- try { module.exports = require(path) }
499
- catch {}
500
- `,
501
- resolveDir: dirname(args.path)
502
- };
503
- });
504
- build4.onResolve({
505
- filter: /\.node$/,
506
- namespace: "node-file"
507
- }, (args) => ({
508
- path: args.path,
509
- namespace: "file"
510
- }));
511
- const opts = build4.initialOptions;
512
- opts.loader = opts.loader || {};
513
- opts.loader[".node"] = "file";
514
- }
515
- };
516
- }, "nativeNodeModulesPlugin");
517
-
518
- // ../esbuild/src/plugins/node-protocol.ts
519
- var nodeProtocolPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => {
520
- const nodeProtocol = "node:";
521
- return {
522
- name: "node-protocol-plugin",
523
- setup({ onResolve }) {
524
- onResolve({
525
- filter: /^node:/
526
- }, ({ path: path6 }) => ({
527
- path: path6.slice(nodeProtocol.length),
528
- external: true
529
- }));
530
- }
531
- };
532
- }, "nodeProtocolPlugin");
533
-
534
- // ../esbuild/src/plugins/on-error.ts
535
- var onErrorPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
536
- name: "storm:on-error",
537
- setup(build4) {
538
- build4.onEnd((result) => {
539
- if (result.errors.length > 0 && process.env.WATCH !== "true") {
540
- writeError(`The following errors occurred during the build:
541
- ${result.errors.map((error) => error.text).join("\n")}
542
-
543
- `, resolvedOptions.config);
544
- throw new Error("Storm esbuild process failed with errors.");
545
- }
546
- });
547
- }
548
- }), "onErrorPlugin");
549
-
550
- // ../esbuild/src/plugins/resolve-paths.ts
551
- import path4 from "node:path";
552
- function resolvePathsConfig(options, cwd) {
553
- if (options?.compilerOptions?.paths) {
554
- const paths = Object.entries(options.compilerOptions.paths);
555
- const resolvedPaths = paths.map(([key, paths2]) => {
556
- return [
557
- key,
558
- paths2.map((v) => path4.resolve(cwd, v))
559
- ];
560
- });
561
- return Object.fromEntries(resolvedPaths);
562
- }
563
- if (options.extends) {
564
- const extendsPath = path4.resolve(cwd, options.extends);
565
- const extendsDir = path4.dirname(extendsPath);
566
- const extendsConfig = __require(extendsPath);
567
- return resolvePathsConfig(extendsConfig, extendsDir);
568
- }
569
- return [];
570
- }
571
- __name(resolvePathsConfig, "resolvePathsConfig");
572
- var resolvePathsPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
573
- name: "storm:resolve-paths",
574
- setup(build4) {
575
- const parentTsConfig = build4.initialOptions.tsconfig ? __require(joinPaths(resolvedOptions.config.workspaceRoot, build4.initialOptions.tsconfig)) : __require(joinPaths(resolvedOptions.config.workspaceRoot, "tsconfig.json"));
576
- const resolvedTsPaths = resolvePathsConfig(parentTsConfig, options.projectRoot);
577
- const packagesRegex = new RegExp(`^(${Object.keys(resolvedTsPaths).join("|")})$`);
578
- build4.onResolve({
579
- filter: packagesRegex
580
- }, (args) => {
581
- if (build4.initialOptions.external?.includes(args.path)) {
582
- return {
583
- path: args.path,
584
- external: true
585
- };
586
- }
587
- return {
588
- path: `${resolvedTsPaths[args.path][0]}/index.ts`
589
- };
590
- });
591
- }
592
- }), "resolvePathsPlugin");
593
-
594
- // ../esbuild/src/plugins/tsc.ts
595
- import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
596
- import { existsSync as existsSync3 } from "node:fs";
597
- import fs3 from "node:fs/promises";
598
- function bundleTypeDefinitions(filename, outfile, externals, options) {
599
- const { dependencies, peerDependencies, devDependencies } = __require(joinPaths(options.projectRoot, "package.json"));
600
- const dependenciesKeys = Object.keys(dependencies ?? {}).flatMap((p) => [
601
- p,
602
- getTypeDependencyPackageName(p)
603
- ]);
604
- const peerDependenciesKeys = Object.keys(peerDependencies ?? {}).flatMap((p) => [
605
- p,
606
- getTypeDependencyPackageName(p)
607
- ]);
608
- const devDependenciesKeys = Object.keys(devDependencies ?? {}).flatMap((p) => [
609
- p,
610
- getTypeDependencyPackageName(p)
611
- ]);
612
- const includeDeps = devDependenciesKeys;
613
- const excludeDeps = /* @__PURE__ */ new Set([
614
- ...dependenciesKeys,
615
- ...peerDependenciesKeys,
616
- ...externals
617
- ]);
618
- const bundledPackages = includeDeps.filter((dep) => !excludeDeps.has(dep));
619
- const extractorConfig = ExtractorConfig.prepare({
620
- configObject: {
621
- projectFolder: options.projectRoot,
622
- mainEntryPointFilePath: filename,
623
- bundledPackages,
624
- compiler: {
625
- tsconfigFilePath: options.tsconfig,
626
- overrideTsconfig: {
627
- compilerOptions: {
628
- paths: {}
629
- // bug with api extract + paths
630
- }
631
- }
632
- },
633
- dtsRollup: {
634
- enabled: true,
635
- untrimmedFilePath: joinPaths(options.outdir, `${outfile}.d.ts`)
636
- },
637
- tsdocMetadata: {
638
- enabled: false
639
- }
640
- },
641
- packageJsonFullPath: joinPaths(options.projectRoot, "package.json"),
642
- configObjectFullPath: void 0
643
- });
644
- const extractorResult = Extractor.invoke(extractorConfig, {
645
- showVerboseMessages: true,
646
- localBuild: true
647
- });
648
- if (extractorResult.succeeded === false) {
649
- writeError(`API Extractor completed with ${extractorResult.errorCount} ${extractorResult.errorCount === 1 ? "error" : "errors"}`);
650
- throw new Error("API Extractor completed with errors");
651
- }
652
- }
653
- __name(bundleTypeDefinitions, "bundleTypeDefinitions");
654
- var tscPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
655
- name: "storm:tsc",
656
- setup(build4) {
657
- if (options.dts === false) {
658
- return;
659
- }
660
- build4.onStart(async () => {
661
- if (process.env.WATCH !== "true" && process.env.DEV !== "true") {
662
- await run(resolvedOptions.config, `pnpm exec tsc --project ${resolvedOptions.tsconfig}`, resolvedOptions.config.workspaceRoot);
663
- }
664
- if (resolvedOptions.bundle && resolvedOptions.entryPoints && resolvedOptions.entryPoints.length > 0 && resolvedOptions.entryPoints[0]?.in && resolvedOptions.entryPoints[0].in.endsWith(".ts")) {
665
- const sourceRoot = resolvedOptions.sourceRoot.replaceAll(resolvedOptions.projectRoot, "");
666
- const typeOutDir = resolvedOptions.outdir;
667
- const entryPoint = resolvedOptions.entryPoints[0].in.replace(sourceRoot, "").replace(/\.ts$/, "");
668
- const bundlePath = joinPaths(resolvedOptions.outdir, entryPoint);
669
- let dtsPath;
670
- if (existsSync3(joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`))) {
671
- dtsPath = joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`);
672
- } else if (existsSync3(joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`))) {
673
- dtsPath = joinPaths(resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`);
674
- }
675
- const ext = resolvedOptions.format === "esm" ? "d.mts" : "d.ts";
676
- if (process.env.WATCH !== "true" && process.env.DEV !== "true") {
677
- bundleTypeDefinitions(dtsPath, bundlePath, resolvedOptions.external ?? [], resolvedOptions);
678
- const dtsContents = await fs3.readFile(`${bundlePath}.d.ts`, "utf8");
679
- await fs3.writeFile(`${bundlePath}.${ext}`, dtsContents);
680
- } else {
681
- await fs3.writeFile(`${bundlePath}.${ext}`, `export * from './${entryPoint}'`);
682
- }
683
- }
684
- });
685
- }
686
- }), "tscPlugin");
687
- function getTypeDependencyPackageName(npmPackage) {
688
- if (npmPackage.startsWith("@")) {
689
- const [scope, name] = npmPackage.split("/");
690
- return `@types/${scope?.slice(1)}__${name}`;
691
- }
692
- return `@types/${npmPackage}`;
693
- }
694
- __name(getTypeDependencyPackageName, "getTypeDependencyPackageName");
695
-
696
- // ../esbuild/src/config.ts
697
- var getDefaultBuildPlugins = /* @__PURE__ */ __name((options, resolvedOptions) => [
698
- nodeProtocolPlugin(options, resolvedOptions),
699
- resolvePathsPlugin(options, resolvedOptions),
700
- fixImportsPlugin(options, resolvedOptions),
701
- nativeNodeModulesPlugin(options, resolvedOptions),
702
- esmSplitCodeToCjsPlugin(options, resolvedOptions),
703
- tscPlugin(options, resolvedOptions),
704
- onErrorPlugin(options, resolvedOptions)
705
- ], "getDefaultBuildPlugins");
706
- var DEFAULT_BUILD_OPTIONS = {
707
- platform: "node",
708
- target: "node22",
709
- format: "esm",
710
- external: [],
711
- logLevel: "error",
712
- tsconfig: "tsconfig.json",
713
- mode: "production",
714
- keepNames: true,
715
- metafile: true,
716
- injectShims: true,
717
- color: true,
718
- watch: false,
719
- bundle: true,
720
- clean: true,
721
- debug: false,
722
- resolveExtensions: [
723
- ".tsx",
724
- ".ts",
725
- ".cts",
726
- ".mts",
727
- ".jsx",
728
- ".js",
729
- ".cjs",
730
- ".mjs",
731
- ".css",
732
- ".json"
733
- ],
734
- loader: {
735
- ".aac": "file",
736
- ".css": "file",
737
- ".eot": "file",
738
- ".flac": "file",
739
- ".gif": "file",
740
- ".jpeg": "file",
741
- ".jpg": "file",
742
- ".mp3": "file",
743
- ".mp4": "file",
744
- ".ogg": "file",
745
- ".otf": "file",
746
- ".png": "file",
747
- ".svg": "file",
748
- ".ttf": "file",
749
- ".wav": "file",
750
- ".webm": "file",
751
- ".webp": "file",
752
- ".woff": "file",
753
- ".woff2": "file"
754
- },
755
- banner: DEFAULT_COMPILED_BANNER
756
- };
757
-
758
- // ../esbuild/src/plugins/deps-check.ts
759
- import { builtinModules as builtinModules2 } from "node:module";
760
- import path5 from "node:path";
761
- var unusedIgnore = [
762
- // these are our dev dependencies
763
- /@types\/.*?/,
764
- /@typescript-eslint.*?/,
765
- /eslint.*?/,
766
- "esbuild",
767
- "husky",
768
- "is-ci",
769
- "lint-staged",
770
- "prettier",
771
- "typescript",
772
- "ts-node",
773
- "ts-jest",
774
- "@swc/core",
775
- "@swc/jest",
776
- "jest",
777
- // these are missing 3rd party deps
778
- "spdx-exceptions",
779
- "spdx-license-ids",
780
- // type-only, so it is not detected
781
- "ts-toolbelt",
782
- // these are indirectly used by build
783
- "buffer"
784
- ];
785
- var missingIgnore = [
786
- ".prisma",
787
- "@prisma/client",
788
- "ts-toolbelt"
789
- ];
790
- var depsCheckPlugin = /* @__PURE__ */ __name((bundle) => ({
791
- name: "storm:deps-check",
792
- setup(build4) {
793
- const pkgJsonPath = path5.join(process.cwd(), "package.json");
794
- const pkgContents = __require(pkgJsonPath);
795
- const regDependencies = Object.keys(pkgContents["dependencies"] ?? {});
796
- const devDependencies = Object.keys(pkgContents["devDependencies"] ?? {});
797
- const peerDependencies = Object.keys(pkgContents["peerDependencies"] ?? {});
798
- const dependencies = [
799
- ...regDependencies,
800
- ...bundle ? devDependencies : []
801
- ];
802
- const collectedDependencies = /* @__PURE__ */ new Set();
803
- const onlyPackages = /^[^./](?!:)|^\.[^./]|^\.\.[^/]/;
804
- build4.onResolve({
805
- filter: onlyPackages
806
- }, (args) => {
807
- if (args.importer.includes(process.cwd())) {
808
- if (args.path[0] === "@") {
809
- const [org, pkg] = args.path.split("/");
810
- collectedDependencies.add(`${org}/${pkg}`);
811
- } else {
812
- const [pkg] = args.path.split("/");
813
- collectedDependencies.add(pkg);
814
- }
815
- }
816
- return {
817
- external: true
818
- };
819
- });
820
- build4.onEnd(() => {
821
- const unusedDependencies = [
822
- ...dependencies
823
- ].filter((dep) => {
824
- return !collectedDependencies.has(dep) || builtinModules2.includes(dep);
825
- });
826
- const missingDependencies = [
827
- ...collectedDependencies
828
- ].filter((dep) => {
829
- return !dependencies.includes(dep) && !builtinModules2.includes(dep);
830
- });
831
- const filteredUnusedDeps = unusedDependencies.filter((dep) => {
832
- return !unusedIgnore.some((pattern) => dep.match(pattern));
833
- });
834
- const filteredMissingDeps = missingDependencies.filter((dep) => {
835
- return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep);
836
- });
837
- writeWarning(`Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`);
838
- writeError(`Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`);
839
- if (filteredMissingDeps.length > 0) {
840
- throw new Error(`Missing dependencies detected - please install them:
841
- ${JSON.stringify(filteredMissingDeps)}
842
- `);
843
- }
844
- });
845
- }
846
- }), "depsCheckPlugin");
847
-
848
- // ../esbuild/src/renderers/shebang.ts
849
- var shebangRenderer = {
850
- name: "shebang",
851
- renderChunk(_, __, info) {
852
- if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) {
853
- info.mode = 493;
854
- }
855
- }
856
- };
857
-
858
- // ../esbuild/src/tsc.ts
859
- import { loadTsConfig } from "bundle-require";
860
- import defu from "defu";
861
- import { existsSync as existsSync4, mkdirSync, writeFileSync } from "node:fs";
862
- import { dirname as dirname2, isAbsolute, join, normalize } from "node:path";
863
- import ts from "typescript";
864
- function ensureTempDeclarationDir(workspaceConfig) {
865
- const root = workspaceConfig.directories.temp || join(workspaceConfig.workspaceRoot, "tmp");
866
- const dirPath = join(root, ".tsc", "declaration");
867
- if (existsSync4(dirPath)) {
868
- return dirPath;
869
- }
870
- mkdirSync(dirPath, {
871
- recursive: true
872
- });
873
- const gitIgnorePath = join(root, ".tsc", ".gitignore");
874
- writeFileSync(gitIgnorePath, "**/*\n");
875
- return dirPath;
876
- }
877
- __name(ensureTempDeclarationDir, "ensureTempDeclarationDir");
878
- function slash(path6) {
879
- const isExtendedLengthPath = path6.startsWith("\\\\?\\");
880
- if (isExtendedLengthPath) {
881
- return path6;
882
- }
883
- return path6.replace(/\\/g, "/");
884
- }
885
- __name(slash, "slash");
886
- function toAbsolutePath(workspaceConfig, p, cwd) {
887
- if (isAbsolute(p)) {
888
- return p;
889
- }
890
- return slash(normalize(join(cwd || workspaceConfig.workspaceRoot, p)));
891
- }
892
- __name(toAbsolutePath, "toAbsolutePath");
893
- var AliasPool = class AliasPool2 {
894
- static {
895
- __name(this, "AliasPool");
896
- }
897
- seen = /* @__PURE__ */ new Set();
898
- assign(name) {
899
- let suffix = 0;
900
- let alias = name === "default" ? "default_alias" : name;
901
- while (this.seen.has(alias)) {
902
- alias = `${name}_alias_${++suffix}`;
903
- if (suffix >= 1e3) {
904
- throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
905
- }
906
- }
907
- this.seen.add(alias);
908
- return alias;
909
- }
910
- };
911
- function getExports(workspaceConfig, program, fileMapping) {
912
- const checker = program.getTypeChecker();
913
- const aliasPool = new AliasPool();
914
- const assignAlias = aliasPool.assign.bind(aliasPool);
915
- function extractExports(sourceFileName) {
916
- const cwd = program.getCurrentDirectory();
917
- sourceFileName = toAbsolutePath(workspaceConfig, sourceFileName, cwd);
918
- const sourceFile = program.getSourceFile(sourceFileName);
919
- if (!sourceFile) {
920
- return [];
921
- }
922
- const destFileName = fileMapping.get(sourceFileName);
923
- if (!destFileName) {
924
- return [];
925
- }
926
- const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
927
- if (!moduleSymbol) {
928
- return [];
929
- }
930
- const exports = [];
931
- const exportSymbols = checker.getExportsOfModule(moduleSymbol);
932
- exportSymbols.forEach((symbol) => {
933
- const name = symbol.getName();
934
- exports.push({
935
- kind: "named",
936
- sourceFileName,
937
- destFileName,
938
- name,
939
- alias: assignAlias(name),
940
- isTypeOnly: false
941
- });
942
- });
943
- return exports;
944
- }
945
- __name(extractExports, "extractExports");
946
- return program.getRootFileNames().flatMap(extractExports);
947
- }
948
- __name(getExports, "getExports");
949
- function emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles = true, customTransformers) {
950
- const fileMapping = /* @__PURE__ */ new Map();
951
- const writeFile2 = /* @__PURE__ */ __name((fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
952
- const sourceFile = sourceFiles?.[0];
953
- const sourceFileName = sourceFile?.fileName;
954
- if (sourceFileName && !fileName.endsWith(".map")) {
955
- const cwd = program.getCurrentDirectory();
956
- fileMapping.set(toAbsolutePath(workspaceConfig, sourceFileName, cwd), toAbsolutePath(workspaceConfig, fileName, cwd));
957
- }
958
- return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
959
- }, "writeFile");
960
- const emitResult = program.emit(void 0, writeFile2, void 0, emitOnlyDtsFiles, customTransformers);
961
- const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
962
- const diagnosticMessages = [];
963
- diagnostics.forEach((diagnostic) => {
964
- if (diagnostic.file) {
965
- const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
966
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
967
- diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
968
- } else {
969
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
970
- diagnosticMessages.push(message);
971
- }
972
- });
973
- const diagnosticMessage = diagnosticMessages.join("\n");
974
- if (diagnosticMessage) {
975
- writeError(`Failed to emit declaration files.
976
-
977
- ${diagnosticMessage}`, workspaceConfig);
978
- throw new Error("TypeScript compilation failed");
979
- }
980
- return fileMapping;
981
- }
982
- __name(emitDtsFiles, "emitDtsFiles");
983
- function emitDts(workspaceConfig, tsconfig, tsconfigRaw, emitOnlyDtsFiles = true, customTransformers) {
984
- const rawTsconfig = loadTsConfig(workspaceConfig.workspaceRoot, tsconfig);
985
- if (!rawTsconfig) {
986
- throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${workspaceConfig.workspaceRoot}`);
987
- }
988
- const declarationDir = ensureTempDeclarationDir(workspaceConfig);
989
- const parsedTsconfig = ts.parseJsonConfigFileContent(defu({
990
- compilerOptions: {
991
- // Enable declaration emit and disable javascript emit
992
- noEmit: false,
993
- declaration: true,
994
- declarationMap: true,
995
- declarationDir,
996
- emitDeclarationOnly: true
997
- }
998
- }, tsconfigRaw?.compilerOptions ?? {}, rawTsconfig.data ?? {}), ts.sys, tsconfig ? dirname2(tsconfig) : "./");
999
- const options = parsedTsconfig.options;
1000
- const host = ts.createCompilerHost(options);
1001
- const program = ts.createProgram(parsedTsconfig.fileNames, options, host);
1002
- const fileMapping = emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles, customTransformers);
1003
- return getExports(workspaceConfig, program, fileMapping);
1004
- }
1005
- __name(emitDts, "emitDts");
1006
-
1007
- // ../esbuild/src/utilities/get-entry-points.ts
1008
- import { glob as glob3 } from "glob";
1009
- var getEntryPoints = /* @__PURE__ */ __name(async (config, projectRoot, sourceRoot, entry, emitOnAll = false) => {
1010
- const workspaceRoot = config.workspaceRoot || findWorkspaceRoot();
1011
- const entryPoints = [];
1012
- if (entry) {
1013
- if (typeof entry === "string") {
1014
- entryPoints.push({
1015
- in: entry,
1016
- out: entry
1017
- });
1018
- } else if (Array.isArray(entry)) {
1019
- entryPoints.push(...entry.map((entry2) => ({
1020
- in: entry2,
1021
- out: entry2
1022
- })));
1023
- } else {
1024
- entryPoints.push(...Object.entries(entry).map(([key, value]) => {
1025
- if (typeof value === "string") {
1026
- return {
1027
- in: value,
1028
- out: key
1029
- };
1030
- } else {
1031
- return {
1032
- in: key,
1033
- out: key
1034
- };
1035
- }
1036
- }));
1037
- }
1038
- }
1039
- if (emitOnAll) {
1040
- entryPoints.push({
1041
- in: joinPaths(workspaceRoot, sourceRoot || projectRoot, "**/*.{ts,tsx}"),
1042
- out: joinPaths(workspaceRoot, sourceRoot || projectRoot, "**/*.{ts,tsx}")
1043
- });
1044
- }
1045
- const results = await Promise.all(entryPoints.map(async (entryPoint) => {
1046
- const paths = [];
1047
- if (entryPoint.in.includes("*")) {
1048
- const files = await glob3(entryPoint.in, {
1049
- withFileTypes: true,
1050
- ignore: [
1051
- "**/node_modules/**"
1052
- ]
1053
- });
1054
- paths.push(...files.reduce((ret, filePath) => {
1055
- const result = correctPaths(joinPaths(filePath.path, filePath.name).replaceAll(correctPaths(workspaceRoot), "").replaceAll(correctPaths(projectRoot), ""));
1056
- if (result) {
1057
- writeDebug(`Trying to add entry point ${result} at "${joinPaths(filePath.path, filePath.name)}"`, config);
1058
- if (!paths.some((p) => p.in === result)) {
1059
- paths.push({
1060
- in: result,
1061
- out: entryPoint.out.replace(entryPoint.in, result)
1062
- });
1063
- }
1064
- }
1065
- return ret;
1066
- }, []));
1067
- } else {
1068
- writeDebug(`Adding ESBuild entry point
1069
- - Input: ${entryPoint.in}
1070
- - Output: ${entryPoint.out}`, config);
1071
- if (!paths.some((p) => p.out === entryPoint.out)) {
1072
- paths.push(entryPoint);
1073
- }
1074
- }
1075
- return paths;
1076
- }));
1077
- return results.filter(Boolean).reduce((ret, result) => {
1078
- result.forEach((res) => {
1079
- if (res && !ret.some((p) => p.in === res.in)) {
1080
- ret.push(res);
1081
- }
1082
- });
1083
- return ret;
1084
- }, []);
1085
- }, "getEntryPoints");
1086
-
1087
- // ../esbuild/src/utilities/helpers.ts
1088
- function handleSync(fn) {
1089
- try {
1090
- return fn();
1091
- } catch (error_) {
1092
- return error_;
1093
- }
1094
- }
1095
- __name(handleSync, "handleSync");
1096
- async function handleAsync(fn) {
1097
- try {
1098
- return await fn();
1099
- } catch (error_) {
1100
- return error_;
1101
- }
1102
- }
1103
- __name(handleAsync, "handleAsync");
1104
- var handle = handleSync;
1105
- handle.async = handleAsync;
1106
- var skip = Symbol("skip");
1107
- function transduceSync(list, transformer) {
1108
- const transduced = [];
1109
- for (const [i, element_] of list.entries()) {
1110
- const transformed = transformer(element_, i);
1111
- if (transformed !== skip) {
1112
- transduced[transduced.length] = transformed;
1113
- }
1114
- }
1115
- return transduced;
1116
- }
1117
- __name(transduceSync, "transduceSync");
1118
- async function transduceAsync(list, transformer) {
1119
- const transduced = [];
1120
- await Promise.all(list.entries().map(async ([i, element_]) => {
1121
- const transformed = await transformer(element_, i);
1122
- if (transformed !== skip) {
1123
- transduced[transduced.length] = transformed;
1124
- }
1125
- }));
1126
- return transduced;
1127
- }
1128
- __name(transduceAsync, "transduceAsync");
1129
- var transduce = transduceSync;
1130
- transduce.async = transduceAsync;
1131
- function pipeSync(fn, ...fns) {
1132
- return (...args) => {
1133
- let result = fn(...args);
1134
- for (let i = 0; result !== skip && i < fns.length; ++i) {
1135
- result = fns[i]?.(result);
1136
- }
1137
- return result;
1138
- };
1139
- }
1140
- __name(pipeSync, "pipeSync");
1141
- function pipeAsync(fn, ...fns) {
1142
- return async (...args) => {
1143
- let result = await fn(...args);
1144
- for (let i = 0; result !== skip && i < fns.length; ++i) {
1145
- result = await fns[i]?.(result);
1146
- }
1147
- return result;
1148
- };
1149
- }
1150
- __name(pipeAsync, "pipeAsync");
1151
- var pipe = pipeSync;
1152
- pipe.async = pipeAsync;
1153
-
1154
- // ../esbuild/src/build.ts
1155
- var resolveOptions = /* @__PURE__ */ __name(async (userOptions) => {
1156
- const projectRoot = userOptions.projectRoot;
1157
- const workspaceRoot = findWorkspaceRoot2(projectRoot);
1158
- if (!workspaceRoot) {
1159
- throw new Error("Cannot find Nx workspace root");
1160
- }
1161
- const config = await getConfig(workspaceRoot.dir);
1162
- writeDebug(" \u2699\uFE0F Resolving build options", config);
1163
- const stopwatch = getStopwatch("Build options resolution");
1164
- const projectGraph = await createProjectGraphAsync({
1165
- exitOnError: true
1166
- });
1167
- const projectJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "project.json");
1168
- if (!existsSync5(projectJsonPath)) {
1169
- throw new Error("Cannot find project.json configuration");
1170
- }
1171
- const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
1172
- const projectJson = JSON.parse(projectJsonFile);
1173
- const projectName = projectJson.name;
1174
- const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
1175
- if (!projectConfigurations?.projects?.[projectName]) {
1176
- 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.");
1177
- }
1178
- const options = defu2(userOptions, DEFAULT_BUILD_OPTIONS);
1179
- options.name ??= `${projectName}-${options.format}`;
1180
- options.target ??= DEFAULT_TARGET;
1181
- const packageJsonPath = joinPaths(workspaceRoot.dir, options.projectRoot, "package.json");
1182
- if (!existsSync5(packageJsonPath)) {
1183
- throw new Error("Cannot find package.json configuration");
1184
- }
1185
- const env = getEnv("esbuild", options);
1186
- const result = {
1187
- ...options,
1188
- config,
1189
- mainFields: options.platform === "node" ? [
1190
- "module",
1191
- "main"
1192
- ] : [
1193
- "browser",
1194
- "module",
1195
- "main"
1196
- ],
1197
- ...userOptions,
1198
- tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
1199
- format: options.format || "cjs",
1200
- entryPoints: await getEntryPoints(config, projectRoot, projectJson.sourceRoot, userOptions.entry ?? "./src/index.ts", false),
1201
- outdir: userOptions.outputPath || joinPaths("dist", projectRoot),
1202
- distDir: userOptions.distDir || "dist",
1203
- plugins: [],
1204
- name: userOptions.name || projectName,
1205
- projectConfigurations,
1206
- projectName,
1207
- projectGraph,
1208
- sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || joinPaths(projectRoot, "src"),
1209
- minify: userOptions.minify || !userOptions.debug,
1210
- verbose: userOptions.verbose || isVerbose() || userOptions.debug === true,
1211
- includeSrc: userOptions.includeSrc === true,
1212
- metafile: userOptions.metafile !== false,
1213
- generatePackageJson: userOptions.generatePackageJson !== false,
1214
- clean: userOptions.clean !== false,
1215
- assets: userOptions.assets ?? [],
1216
- injectShims: userOptions.injectShims !== true,
1217
- bundle: userOptions.bundle !== false,
1218
- keepNames: true,
1219
- watch: userOptions.watch === true,
1220
- footer: userOptions.footer,
1221
- banner: {
1222
- js: options.banner || DEFAULT_COMPILED_BANNER,
1223
- css: options.banner || DEFAULT_COMPILED_BANNER
1224
- },
1225
- splitting: options.format === "iife" ? false : typeof options.splitting === "boolean" ? options.splitting : options.format === "esm",
1226
- treeShaking: options.format === "esm",
1227
- env,
1228
- define: {
1229
- STORM_FORMAT: JSON.stringify(options.format || "cjs"),
1230
- ...options.format === "cjs" && options.injectShims ? {
1231
- "import.meta.url": "importMetaUrl"
1232
- } : {},
1233
- ...options.define,
1234
- ...Object.keys(env || {}).reduce((res, key) => {
1235
- const value = JSON.stringify(env[key]);
1236
- const safeKey = key.replaceAll("(", "").replaceAll(")", "");
1237
- return {
1238
- ...res,
1239
- [`process.env.${safeKey}`]: value,
1240
- [`import.meta.env.${safeKey}`]: value
1241
- };
1242
- }, {})
1243
- },
1244
- inject: [
1245
- options.format === "cjs" && options.injectShims ? joinPaths(__dirname, "../assets/cjs_shims.js") : void 0,
1246
- options.format === "esm" && options.injectShims && options.platform === "node" ? joinPaths(__dirname, "../assets/esm_shims.js") : void 0
1247
- ].filter(Boolean)
1248
- };
1249
- result.plugins = userOptions.plugins ?? getDefaultBuildPlugins(userOptions, result);
1250
- if (options.inject && Array.isArray(options.inject) && options.inject.length > 0) {
1251
- result.inject = options.inject.reduce((ret, inj) => {
1252
- if (inj && typeof inj === "string" && ret.includes(inj)) {
1253
- ret.push(inj);
1254
- }
1255
- return ret;
1256
- }, result.inject);
1257
- }
1258
- delete result.entry;
1259
- delete result.outputPath;
1260
- stopwatch();
1261
- return result;
1262
- }, "resolveOptions");
1263
- async function generatePackageJson(context2) {
1264
- if (context2.options.generatePackageJson !== false && existsSync5(joinPaths(context2.options.projectRoot, "package.json"))) {
1265
- writeDebug(" \u270D\uFE0F Writing package.json file", context2.options.config);
1266
- const stopwatch = getStopwatch("Write package.json file");
1267
- const packageJsonPath = joinPaths(context2.options.projectRoot, "project.json");
1268
- if (!existsSync5(packageJsonPath)) {
1269
- throw new Error("Cannot find package.json configuration");
1270
- }
1271
- const packageJsonFile = await hf.readFile(joinPaths(context2.options.config.workspaceRoot, context2.options.projectRoot, "package.json"), "utf8");
1272
- let packageJson = JSON.parse(packageJsonFile);
1273
- if (!packageJson) {
1274
- throw new Error("Cannot find package.json configuration file");
1275
- }
1276
- packageJson = await addPackageDependencies(context2.options.config.workspaceRoot, context2.options.projectRoot, context2.options.projectName, packageJson);
1277
- packageJson = await addWorkspacePackageJsonFields(context2.options.config, context2.options.projectRoot, context2.options.sourceRoot, context2.options.projectName, false, packageJson);
1278
- packageJson.exports ??= {};
1279
- packageJson.exports["./package.json"] ??= "./package.json";
1280
- packageJson.exports["."] ??= `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.js`;
1281
- for (const entryPoint of context2.options.entryPoints) {
1282
- if (entryPoint.out) {
1283
- const entry = entryPoint.out.replaceAll("\\", "/").replaceAll(/^(\.\/)*/g, "").replace(/\.([cm])?[jt]s(x)?$/g, "");
1284
- packageJson.exports[`./${entry}`] ??= `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/${entry}.js`;
1285
- }
1286
- }
1287
- if (context2.options.format === "esm") {
1288
- packageJson.module = packageJson.type === "module" ? `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.js` : `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.mjs`;
1289
- } else {
1290
- packageJson.main = packageJson.type === "commonjs" ? `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.js` : `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.cjs`;
1291
- }
1292
- packageJson.types = `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.d.ts`;
1293
- packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
1294
- if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
1295
- ret[key.replace("/index", "")] = packageJson.exports[key];
1296
- }
1297
- return ret;
1298
- }, packageJson.exports);
1299
- await writeJsonFile(joinPaths(context2.options.outdir, "package.json"), packageJson);
1300
- stopwatch();
1301
- }
1302
- return context2;
1303
- }
1304
- __name(generatePackageJson, "generatePackageJson");
1305
- async function createOptions(options) {
1306
- return flatten(await Promise.all(map(options, (opt) => [
1307
- // we defer it so that we don't trigger glob immediately
1308
- () => resolveOptions(opt)
1309
- ])));
1310
- }
1311
- __name(createOptions, "createOptions");
1312
- async function generateContext(getOptions) {
1313
- const options = await getOptions();
1314
- const rendererEngine = new RendererEngine([
1315
- shebangRenderer,
1316
- ...options.renderers || []
1317
- ]);
1318
- return {
1319
- options,
1320
- rendererEngine
1321
- };
1322
- }
1323
- __name(generateContext, "generateContext");
1324
- async function executeEsBuild(context2) {
1325
- writeDebug(` \u{1F680} Running ${context2.options.name} build`, context2.options.config);
1326
- const stopwatch = getStopwatch(`${context2.options.name} build`);
1327
- if (process.env.STORM_WATCH) {
1328
- const ctx = await esbuild2.context(context2.options);
1329
- watch(ctx, context2.options);
1330
- }
1331
- const options = {
1332
- ...context2.options
1333
- };
1334
- options.outdir = joinPaths(context2.options.outdir, context2.options.distDir);
1335
- if (!options.inject || !Array.isArray(options.inject) || options.inject.length === 0 || // eslint-disable-next-line no-constant-binary-expression, @typescript-eslint/no-explicit-any
1336
- options.inject === {}) {
1337
- delete options.inject;
1338
- }
1339
- delete options.dts;
1340
- delete options.env;
1341
- delete options.name;
1342
- delete options.assets;
1343
- delete options.mode;
1344
- delete options.orgName;
1345
- delete options.watch;
1346
- delete options.clean;
1347
- delete options.debug;
1348
- delete options.generatePackageJson;
1349
- delete options.distDir;
1350
- delete options.includeSrc;
1351
- delete options.verbose;
1352
- delete options.projectRoot;
1353
- delete options.projectName;
1354
- delete options.projectGraph;
1355
- delete options.projectConfigurations;
1356
- delete options.renderers;
1357
- delete options.config;
1358
- delete options.injectShims;
1359
- delete options.external;
1360
- writeTrace(`Run esbuild (${context2.options.name}) with the following options:
1361
- ${formatLogMessage({
1362
- ...options,
1363
- define: "<Hidden>"
1364
- })}`, context2.options.config);
1365
- const result = await esbuild2.build(options);
1366
- await esbuild2.stop();
1367
- if (result.metafile) {
1368
- const metafilePath = `${context2.options.outdir}/${context2.options.name}.meta.json`;
1369
- await hf.writeFile(metafilePath, JSON.stringify(result.metafile));
1370
- }
1371
- stopwatch();
1372
- return context2;
1373
- }
1374
- __name(executeEsBuild, "executeEsBuild");
1375
- async function executeTypescript(context2) {
1376
- if (context2.result?.errors.length === 0 && context2.options.dts) {
1377
- writeDebug(` \u{1F4CB} Running TypeScript Compiler for ${context2.options.name}`, context2.options.config);
1378
- const stopwatch = getStopwatch(`${context2.options.name} asset copy`);
1379
- await emitDts(context2.options.config, context2.options.tsconfig, context2.options.tsconfigRaw, true);
1380
- stopwatch();
1381
- }
1382
- return context2;
1383
- }
1384
- __name(executeTypescript, "executeTypescript");
1385
- async function copyBuildAssets(context2) {
1386
- if (context2.result?.errors.length === 0) {
1387
- writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context2.options.outdir}`, context2.options.config);
1388
- const stopwatch = getStopwatch(`${context2.options.name} asset copy`);
1389
- await copyAssets(context2.options.config, context2.options.assets ?? [], context2.options.outdir, context2.options.projectRoot, context2.options.sourceRoot, true, false);
1390
- stopwatch();
1391
- }
1392
- return context2;
1393
- }
1394
- __name(copyBuildAssets, "copyBuildAssets");
1395
- async function reportResults(context2) {
1396
- if (context2.result?.errors.length === 0) {
1397
- if (context2.result.warnings.length > 0) {
1398
- writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context2.result.warnings.map((warning) => warning.text).join("\n")}`, context2.options.config);
1399
- }
1400
- writeSuccess(` \u{1F4E6} The ${context2.options.name} build completed successfully`, context2.options.config);
1401
- } else if (context2.result?.errors && context2.result?.errors.length > 0) {
1402
- writeError(` \u274C The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`, context2.options.config);
1403
- throw new Error(`The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`);
1404
- }
1405
- }
1406
- __name(reportResults, "reportResults");
1407
- async function dependencyCheck(options) {
1408
- if (process.env.DEV === "true") {
1409
- return void 0;
1410
- }
1411
- if (process.env.CI && !process.env.BUILDKITE) {
1412
- return void 0;
1413
- }
1414
- const buildPromise = esbuild2.build({
1415
- entryPoints: globbySync("**/*.{j,t}s", {
1416
- // We don't check dependencies in ecosystem tests because tests are isolated from the build.
1417
- ignore: [
1418
- "./src/__tests__/**/*",
1419
- "./tests/e2e/**/*",
1420
- "./dist/**/*"
1421
- ],
1422
- gitignore: true
1423
- }),
1424
- logLevel: "silent",
1425
- bundle: true,
1426
- write: false,
1427
- outdir: "out",
1428
- plugins: [
1429
- depsCheckPlugin(options.bundle)
1430
- ]
1431
- });
1432
- await buildPromise.catch(() => {
1433
- });
1434
- return void 0;
1435
- }
1436
- __name(dependencyCheck, "dependencyCheck");
1437
- async function cleanOutputPath(context2) {
1438
- if (context2.options.clean !== false && context2.options.outdir) {
1439
- writeDebug(` \u{1F9F9} Cleaning ${context2.options.name} output path: ${context2.options.outdir}`, context2.options.config);
1440
- const stopwatch = getStopwatch(`${context2.options.name} output clean`);
1441
- await cleanDirectories(context2.options.name, context2.options.outdir, context2.options.config);
1442
- stopwatch();
1443
- }
1444
- return context2;
1445
- }
1446
- __name(cleanOutputPath, "cleanOutputPath");
1447
- async function build3(options) {
1448
- writeDebug(` \u26A1 Executing Storm ESBuild pipeline`);
1449
- const stopwatch = getStopwatch("ESBuild pipeline");
1450
- try {
1451
- const opts = Array.isArray(options) ? options : [
1452
- options
1453
- ];
1454
- if (opts.length === 0) {
1455
- throw new Error("No build options were provided");
1456
- }
1457
- void transduce.async(opts, dependencyCheck);
1458
- await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeTypescript, executeEsBuild, copyBuildAssets, reportResults));
1459
- writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
1460
- } catch (error) {
1461
- writeFatal("Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
1462
- throw error;
1463
- } finally {
1464
- stopwatch();
1465
- }
1466
- }
1467
- __name(build3, "build");
1468
- var watch = /* @__PURE__ */ __name((context2, options) => {
1469
- if (!options.watch) {
1470
- return context2;
1471
- }
1472
- const config = {
1473
- ignoreInitial: true,
1474
- useFsEvents: true,
1475
- ignored: [
1476
- "./src/__tests__/**/*",
1477
- "./package.json"
1478
- ]
1479
- };
1480
- const changeWatcher = createWatcher([
1481
- "./src/**/*"
1482
- ], config);
1483
- const fastRebuild = debounce(async () => {
1484
- const timeBefore = Date.now();
1485
- const rebuildResult = await handle.async(() => {
1486
- return context2.rebuild();
1487
- });
1488
- if (rebuildResult instanceof Error) {
1489
- writeError(rebuildResult.message);
1490
- }
1491
- writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
1492
- }, 10);
1493
- changeWatcher.on("change", fastRebuild);
1494
- return void 0;
1495
- }, "watch");
1496
-
1497
- // src/executors/esbuild/executor.ts
1498
- async function esbuildExecutorFn(options, context2, config) {
1499
- writeInfo("\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
1500
- if (!context2.projectsConfigurations?.projects || !context2.projectName || !context2.projectsConfigurations.projects[context2.projectName] || !context2.projectsConfigurations.projects[context2.projectName]?.root) {
1501
- throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace.");
1502
- }
1503
- await build3({
1504
- ...options,
1505
- projectRoot: context2.projectsConfigurations.projects?.[context2.projectName].root,
1506
- projectName: context2.projectName,
1507
- sourceRoot: context2.projectsConfigurations.projects?.[context2.projectName]?.sourceRoot,
1508
- format: options.format,
1509
- platform: options.format
1510
- });
1511
- return {
1512
- success: true
1513
- };
1514
- }
1515
- __name(esbuildExecutorFn, "esbuildExecutorFn");
1516
- var executor_default = withRunExecutor("Storm ESBuild build", esbuildExecutorFn, {
1517
- skipReadingConfig: false,
1518
- hooks: {
1519
- applyDefaultOptions: /* @__PURE__ */ __name(async (options, config) => {
1520
- options.entry ??= [
1521
- "src/index.ts"
1522
- ];
1523
- options.outputPath ??= "dist/{projectRoot}";
1524
- options.tsconfig ??= "{projectRoot}/tsconfig.json";
1525
- return options;
1526
- }, "applyDefaultOptions")
1527
- }
1528
- });
1529
-
1530
- export {
1531
- esbuildExecutorFn,
1532
- executor_default
1533
- };