@storm-software/esbuild 0.34.0 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/esbuild.cjs +5 -5
- package/dist/build.cjs +15 -15
- package/dist/build.d.cts +1 -1
- package/dist/build.d.ts +1 -1
- package/dist/build.js +14 -14
- package/dist/{chunk-WRBUO7H6.cjs → chunk-27VOV3G4.cjs} +2 -2
- package/dist/{chunk-GWG4HOQ6.js → chunk-2TG2H4XL.js} +1 -1
- package/dist/{chunk-XEGYFRBF.js → chunk-2X5ZMEAN.js} +2 -2
- package/dist/{chunk-35YNFZCF.js → chunk-3PF5YMWK.js} +2 -2
- package/dist/{chunk-S2P6KHZV.js → chunk-3QHFCKSI.js} +3 -3
- package/dist/{chunk-RGWII6NP.js → chunk-5RVOO3YF.js} +2 -2
- package/dist/{chunk-LYDEMC26.js → chunk-AZON722Q.js} +1 -1
- package/dist/chunk-B4CUDMY2.cjs +39 -0
- package/dist/{chunk-MWGFCZF4.cjs → chunk-BNPCRQK4.cjs} +6 -6
- package/dist/{chunk-K6QIYIIY.cjs → chunk-BOFHC4OE.cjs} +4 -4
- package/dist/{chunk-IO2TXOKO.js → chunk-BWSIRV3D.js} +2 -2
- package/dist/chunk-CCEWV2BR.js +39 -0
- package/dist/{chunk-ETTFFUNG.cjs → chunk-CGMLIVTB.cjs} +12 -12
- package/dist/chunk-DPRINYB6.js +2939 -0
- package/dist/{chunk-Y3LXNK5C.cjs → chunk-GJHRTQAS.cjs} +36 -36
- package/dist/{chunk-EZGTDCYM.cjs → chunk-ILJQ4NCE.cjs} +4 -4
- package/dist/chunk-M3AOQRGN.cjs +2939 -0
- package/dist/{chunk-IMVMVEQS.cjs → chunk-N62ZR7UV.cjs} +17 -17
- package/dist/{chunk-4TQE46SC.cjs → chunk-QKJ7KLDL.cjs} +6 -6
- package/dist/{chunk-GQCYZOAM.cjs → chunk-RLQJRD62.cjs} +2 -2
- package/dist/{chunk-KGKL7VDG.js → chunk-SKJRUPDP.js} +11 -10
- package/dist/{chunk-IX6DNVUR.js → chunk-STCE44IS.js} +2 -2
- package/dist/{chunk-AXEZCHZS.cjs → chunk-TDBBRZTC.cjs} +99 -98
- package/dist/{chunk-Y4XWI6JJ.cjs → chunk-TH2QFJHI.cjs} +6 -6
- package/dist/{chunk-T5272PC2.js → chunk-UYE6LM4C.js} +1 -1
- package/dist/{chunk-XITTOHOG.cjs → chunk-VPTKC3UK.cjs} +6 -6
- package/dist/{chunk-2IGRKQGI.js → chunk-VQHKIS7J.js} +2 -2
- package/dist/{chunk-HXMVEX3P.js → chunk-XLUZXKDY.js} +1 -1
- package/dist/{chunk-S6M44SSZ.cjs → chunk-Y5SBBYX3.cjs} +3 -3
- package/dist/{chunk-YMTDVMD6.js → chunk-Y7JBB452.js} +1 -1
- package/dist/clean.cjs +5 -5
- package/dist/clean.d.cts +1 -1
- package/dist/clean.d.ts +1 -1
- package/dist/clean.js +4 -4
- package/dist/config.cjs +12 -12
- package/dist/config.d.cts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +11 -11
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -15
- package/dist/plugins/deps-check.cjs +5 -5
- package/dist/plugins/deps-check.js +4 -4
- package/dist/plugins/esm-split-code-to-cjs.cjs +3 -3
- package/dist/plugins/esm-split-code-to-cjs.d.cts +1 -1
- package/dist/plugins/esm-split-code-to-cjs.d.ts +1 -1
- package/dist/plugins/esm-split-code-to-cjs.js +2 -2
- package/dist/plugins/fix-imports.cjs +3 -3
- package/dist/plugins/fix-imports.d.cts +1 -1
- package/dist/plugins/fix-imports.d.ts +1 -1
- package/dist/plugins/fix-imports.js +2 -2
- package/dist/plugins/native-node-module.cjs +3 -3
- package/dist/plugins/native-node-module.d.cts +1 -1
- package/dist/plugins/native-node-module.d.ts +1 -1
- package/dist/plugins/native-node-module.js +2 -2
- package/dist/plugins/node-protocol.cjs +3 -3
- package/dist/plugins/node-protocol.d.cts +1 -1
- package/dist/plugins/node-protocol.d.ts +1 -1
- package/dist/plugins/node-protocol.js +2 -2
- package/dist/plugins/on-error.cjs +5 -5
- package/dist/plugins/on-error.d.cts +1 -1
- package/dist/plugins/on-error.d.ts +1 -1
- package/dist/plugins/on-error.js +4 -4
- package/dist/plugins/resolve-paths.cjs +4 -4
- package/dist/plugins/resolve-paths.d.cts +1 -1
- package/dist/plugins/resolve-paths.d.ts +1 -1
- package/dist/plugins/resolve-paths.js +3 -3
- package/dist/plugins/tsc.cjs +5 -5
- package/dist/plugins/tsc.d.cts +1 -1
- package/dist/plugins/tsc.d.ts +1 -1
- package/dist/plugins/tsc.js +4 -4
- package/dist/tsc.cjs +5 -5
- package/dist/tsc.d.cts +1 -1
- package/dist/tsc.d.ts +1 -1
- package/dist/tsc.js +4 -4
- package/dist/{types-DwxFThZu.d.ts → types-B4jbZA4j.d.cts} +14 -14
- package/dist/{types-DwxFThZu.d.cts → types-B4jbZA4j.d.ts} +14 -14
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-3GQAWCBQ.js +0 -13
- package/dist/chunk-BGYQAVKQ.cjs +0 -13
- package/dist/chunk-E5AAO2PH.cjs +0 -422
- package/dist/chunk-X6OXFNDR.js +0 -422
package/dist/chunk-X6OXFNDR.js
DELETED
|
@@ -1,422 +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-KGKL7VDG.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 resolvedOptions = {
|
|
149
|
-
name: projectName,
|
|
150
|
-
...options,
|
|
151
|
-
tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
|
|
152
|
-
metafile: userOptions.mode === "development",
|
|
153
|
-
clean: false,
|
|
154
|
-
splitting: options.format === "iife" ? false : options.treeshake === void 0 ? options.splitting : true,
|
|
155
|
-
env,
|
|
156
|
-
define: {
|
|
157
|
-
STORM_FORMAT: JSON.stringify(options.format),
|
|
158
|
-
...options.define,
|
|
159
|
-
...Object.keys(env || {}).reduce((res, key) => {
|
|
160
|
-
const value = JSON.stringify(env[key]);
|
|
161
|
-
const safeKey = key.replaceAll("(", "").replaceAll(")", "");
|
|
162
|
-
return {
|
|
163
|
-
...res,
|
|
164
|
-
[`process.env.${safeKey}`]: value,
|
|
165
|
-
[`import.meta.env.${safeKey}`]: value
|
|
166
|
-
};
|
|
167
|
-
}, {})
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
stopwatch();
|
|
171
|
-
return {
|
|
172
|
-
options: resolvedOptions,
|
|
173
|
-
clean: userOptions.clean !== false,
|
|
174
|
-
workspaceConfig,
|
|
175
|
-
projectConfigurations,
|
|
176
|
-
projectName,
|
|
177
|
-
projectGraph,
|
|
178
|
-
sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || joinPaths(resolvedOptions.projectRoot, "src"),
|
|
179
|
-
outputPath: resolvedOptions.outputPath || joinPaths(workspaceConfig.workspaceRoot, "dist", resolvedOptions.projectRoot),
|
|
180
|
-
minify: resolvedOptions.minify || resolvedOptions.mode === "production"
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
__name(resolveContext, "resolveContext");
|
|
184
|
-
async function generatePackageJson(context) {
|
|
185
|
-
if (context.options.generatePackageJson !== false && existsSync(joinPaths(context.options.projectRoot, "package.json"))) {
|
|
186
|
-
writeDebug(" \u270D\uFE0F Writing package.json file", context.workspaceConfig);
|
|
187
|
-
const stopwatch = getStopwatch("Write package.json file");
|
|
188
|
-
const packageJsonPath = joinPaths(context.options.projectRoot, "project.json");
|
|
189
|
-
if (!existsSync(packageJsonPath)) {
|
|
190
|
-
throw new Error("Cannot find package.json configuration");
|
|
191
|
-
}
|
|
192
|
-
const packageJsonFile = await hf.readFile(joinPaths(context.workspaceConfig.workspaceRoot, context.options.projectRoot, "package.json"), "utf8");
|
|
193
|
-
let packageJson = JSON.parse(packageJsonFile);
|
|
194
|
-
if (!packageJson) {
|
|
195
|
-
throw new Error("Cannot find package.json configuration file");
|
|
196
|
-
}
|
|
197
|
-
packageJson = await addPackageDependencies(context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
|
|
198
|
-
packageJson = await addWorkspacePackageJsonFields(context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
|
|
199
|
-
if (context.options.entry) {
|
|
200
|
-
packageJson.exports ??= {};
|
|
201
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
202
|
-
const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
|
|
203
|
-
if (entryPoints.length > 0) {
|
|
204
|
-
const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
|
|
205
|
-
const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
|
|
206
|
-
const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
|
|
207
|
-
const isDts = context.options.dts || context.options.experimentalDts;
|
|
208
|
-
packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
|
|
209
|
-
for (const entryPoint of entryPoints) {
|
|
210
|
-
packageJson.exports[`./${entryPoint}`] ??= {};
|
|
211
|
-
if (isEsm) {
|
|
212
|
-
if (isDts) {
|
|
213
|
-
packageJson.exports[`./${entryPoint}`].import = {
|
|
214
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
215
|
-
default: `./dist/${entryPoint}.mjs`
|
|
216
|
-
};
|
|
217
|
-
} else {
|
|
218
|
-
packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
|
|
219
|
-
}
|
|
220
|
-
if (isDts) {
|
|
221
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
222
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
223
|
-
default: `./dist/${entryPoint}.mjs`
|
|
224
|
-
};
|
|
225
|
-
} else {
|
|
226
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (isCjs) {
|
|
230
|
-
if (isDts) {
|
|
231
|
-
packageJson.exports[`./${entryPoint}`].require = {
|
|
232
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
233
|
-
default: `./dist/${entryPoint}.cjs`
|
|
234
|
-
};
|
|
235
|
-
} else {
|
|
236
|
-
packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
|
|
237
|
-
}
|
|
238
|
-
if (!isEsm) {
|
|
239
|
-
if (isDts) {
|
|
240
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
241
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
242
|
-
default: `./dist/${entryPoint}.cjs`
|
|
243
|
-
};
|
|
244
|
-
} else {
|
|
245
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (!isEsm && !isCjs) {
|
|
250
|
-
if (isDts) {
|
|
251
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
252
|
-
types: `./dist/${entryPoint}.d.ts`,
|
|
253
|
-
default: `./dist/${entryPoint}.js`
|
|
254
|
-
};
|
|
255
|
-
} else {
|
|
256
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (isEsm) {
|
|
261
|
-
packageJson.module = `${defaultEntry}.mjs`;
|
|
262
|
-
} else {
|
|
263
|
-
packageJson.main = `${defaultEntry}.cjs`;
|
|
264
|
-
}
|
|
265
|
-
if (isDts) {
|
|
266
|
-
packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
|
|
267
|
-
}
|
|
268
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
269
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
270
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
271
|
-
}
|
|
272
|
-
return ret;
|
|
273
|
-
}, packageJson.exports);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
await writeJsonFile(joinPaths(context.outputPath, "package.json"), packageJson);
|
|
277
|
-
stopwatch();
|
|
278
|
-
}
|
|
279
|
-
return context;
|
|
280
|
-
}
|
|
281
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
282
|
-
async function executeTsup(context) {
|
|
283
|
-
writeDebug(` \u{1F680} Running ${context.options.name} build`, context.workspaceConfig);
|
|
284
|
-
const stopwatch = getStopwatch(`${context.options.name} build`);
|
|
285
|
-
await tsup({
|
|
286
|
-
...context.options,
|
|
287
|
-
outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
|
|
288
|
-
workspaceConfig: context.workspaceConfig
|
|
289
|
-
});
|
|
290
|
-
stopwatch();
|
|
291
|
-
return context;
|
|
292
|
-
}
|
|
293
|
-
__name(executeTsup, "executeTsup");
|
|
294
|
-
async function copyBuildAssets(context) {
|
|
295
|
-
if (context.result?.errors.length === 0) {
|
|
296
|
-
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
|
|
297
|
-
const stopwatch = getStopwatch(`${context.options.name} asset copy`);
|
|
298
|
-
await copyAssets(context.workspaceConfig, context.options.assets ?? [], context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
|
|
299
|
-
stopwatch();
|
|
300
|
-
}
|
|
301
|
-
return context;
|
|
302
|
-
}
|
|
303
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
304
|
-
async function reportResults(context) {
|
|
305
|
-
if (context.result?.errors.length === 0) {
|
|
306
|
-
if (context.result.warnings.length > 0) {
|
|
307
|
-
writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`, context.workspaceConfig);
|
|
308
|
-
}
|
|
309
|
-
writeSuccess(` \u{1F4E6} The ${context.options.name} build completed successfully`, context.workspaceConfig);
|
|
310
|
-
} else if (context.result?.errors && context.result?.errors.length > 0) {
|
|
311
|
-
writeError(` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`, context.workspaceConfig);
|
|
312
|
-
throw new Error(`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
__name(reportResults, "reportResults");
|
|
316
|
-
async function dependencyCheck(options) {
|
|
317
|
-
if (process.env.DEV === "true") {
|
|
318
|
-
return void 0;
|
|
319
|
-
}
|
|
320
|
-
if (process.env.CI && !process.env.BUILDKITE) {
|
|
321
|
-
return void 0;
|
|
322
|
-
}
|
|
323
|
-
const buildPromise = esbuild.build({
|
|
324
|
-
entryPoints: globbySync("**/*.{j,t}s", {
|
|
325
|
-
// We don't check dependencies in ecosystem tests because tests are isolated from the build.
|
|
326
|
-
ignore: [
|
|
327
|
-
"./src/__tests__/**/*",
|
|
328
|
-
"./tests/e2e/**/*",
|
|
329
|
-
"./dist/**/*"
|
|
330
|
-
],
|
|
331
|
-
gitignore: true
|
|
332
|
-
}),
|
|
333
|
-
logLevel: "silent",
|
|
334
|
-
bundle: true,
|
|
335
|
-
write: false,
|
|
336
|
-
outdir: "out",
|
|
337
|
-
plugins: [
|
|
338
|
-
depsCheckPlugin(options.bundle)
|
|
339
|
-
]
|
|
340
|
-
});
|
|
341
|
-
await buildPromise.catch(() => {
|
|
342
|
-
});
|
|
343
|
-
return void 0;
|
|
344
|
-
}
|
|
345
|
-
__name(dependencyCheck, "dependencyCheck");
|
|
346
|
-
async function cleanOutputPath(context) {
|
|
347
|
-
if (context.clean !== false && context.outputPath) {
|
|
348
|
-
writeDebug(` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`, context.workspaceConfig);
|
|
349
|
-
const stopwatch = getStopwatch(`${context.options.name} output clean`);
|
|
350
|
-
await cleanDirectories(context.outputPath);
|
|
351
|
-
stopwatch();
|
|
352
|
-
}
|
|
353
|
-
return context;
|
|
354
|
-
}
|
|
355
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
356
|
-
async function build2(options) {
|
|
357
|
-
writeDebug(` \u26A1 Executing Storm ESBuild pipeline`);
|
|
358
|
-
const stopwatch = getStopwatch("ESBuild pipeline");
|
|
359
|
-
try {
|
|
360
|
-
const opts = Array.isArray(options) ? options : [
|
|
361
|
-
options
|
|
362
|
-
];
|
|
363
|
-
if (opts.length === 0) {
|
|
364
|
-
throw new Error("No build options were provided");
|
|
365
|
-
}
|
|
366
|
-
const context = await resolveContext(options);
|
|
367
|
-
await cleanOutputPath(context);
|
|
368
|
-
await Promise.all([
|
|
369
|
-
dependencyCheck(context.options),
|
|
370
|
-
generatePackageJson(context),
|
|
371
|
-
copyBuildAssets(context),
|
|
372
|
-
executeTsup(context)
|
|
373
|
-
]);
|
|
374
|
-
await reportResults(context);
|
|
375
|
-
writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
|
|
376
|
-
} catch (error) {
|
|
377
|
-
writeFatal("Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
|
|
378
|
-
throw error;
|
|
379
|
-
} finally {
|
|
380
|
-
stopwatch();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
__name(build2, "build");
|
|
384
|
-
var watch = /* @__PURE__ */ __name((context, options) => {
|
|
385
|
-
if (!options.watch) {
|
|
386
|
-
return context;
|
|
387
|
-
}
|
|
388
|
-
const config = {
|
|
389
|
-
ignoreInitial: true,
|
|
390
|
-
useFsEvents: true,
|
|
391
|
-
ignored: [
|
|
392
|
-
"./src/__tests__/**/*",
|
|
393
|
-
"./package.json"
|
|
394
|
-
]
|
|
395
|
-
};
|
|
396
|
-
const changeWatcher = createWatcher([
|
|
397
|
-
"./src/**/*"
|
|
398
|
-
], config);
|
|
399
|
-
const fastRebuild = debounce(async () => {
|
|
400
|
-
const timeBefore = Date.now();
|
|
401
|
-
const rebuildResult = await handle.async(() => {
|
|
402
|
-
return context.rebuild();
|
|
403
|
-
});
|
|
404
|
-
if (rebuildResult instanceof Error) {
|
|
405
|
-
writeError(rebuildResult.message);
|
|
406
|
-
}
|
|
407
|
-
writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
|
|
408
|
-
}, 10);
|
|
409
|
-
changeWatcher.on("change", fastRebuild);
|
|
410
|
-
return void 0;
|
|
411
|
-
}, "watch");
|
|
412
|
-
|
|
413
|
-
export {
|
|
414
|
-
handle,
|
|
415
|
-
skip,
|
|
416
|
-
Filter,
|
|
417
|
-
Mapper,
|
|
418
|
-
transduce,
|
|
419
|
-
pipe,
|
|
420
|
-
build2 as build,
|
|
421
|
-
watch
|
|
422
|
-
};
|