@storm-software/esbuild 0.34.2 → 0.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/esbuild.cjs +12143 -158
- package/dist/assets.cjs +9 -0
- package/dist/assets.d.cts +16 -0
- package/dist/assets.d.ts +16 -0
- package/dist/assets.js +9 -0
- package/dist/build.cjs +13 -17
- package/dist/build.d.cts +3 -13
- package/dist/build.d.ts +3 -13
- package/dist/build.js +14 -18
- package/dist/chunk-2CM3VAO5.cjs +119 -0
- package/dist/{chunk-Y7JBB452.js → chunk-4D6ICA75.js} +36 -3
- package/dist/{chunk-5RVOO3YF.js → chunk-ABRK5MYP.js} +3 -5
- package/dist/chunk-CVOQEYHW.cjs +117 -0
- package/dist/{chunk-3PF5YMWK.js → chunk-DNZNN5SK.js} +2 -2
- package/dist/chunk-EBTMX5WL.js +117 -0
- package/dist/chunk-ECCVVXNX.js +100 -0
- package/dist/chunk-EDLA3ZZN.js +26 -0
- package/dist/{chunk-GJHRTQAS.cjs → chunk-EVDNG72R.cjs} +35 -37
- package/dist/{chunk-TDBBRZTC.cjs → chunk-FQQYNAPT.cjs} +111 -189
- package/dist/{chunk-QKJ7KLDL.cjs → chunk-G66JI4BS.cjs} +5 -7
- package/dist/{chunk-SKJRUPDP.js → chunk-NJJBR57W.js} +24 -102
- package/dist/{chunk-STCE44IS.js → chunk-OCDIIBBZ.js} +2 -2
- package/dist/{chunk-M3AOQRGN.cjs → chunk-PTHYT3U2.cjs} +188 -582
- package/dist/chunk-QVMJLFU5.cjs +26 -0
- package/dist/{chunk-DPRINYB6.js → chunk-QWTKBUQW.js} +40 -434
- package/dist/chunk-R2KKGNQL.js +119 -0
- package/dist/{chunk-TH2QFJHI.cjs → chunk-RK34D7S5.cjs} +6 -6
- package/dist/chunk-SLSBBNRF.cjs +52 -0
- package/dist/{chunk-VQHKIS7J.js → chunk-TSQT5MWW.js} +2 -4
- package/dist/{chunk-BNPCRQK4.cjs → chunk-VTBMJYSM.cjs} +6 -6
- package/dist/chunk-WLJT52I3.cjs +100 -0
- package/dist/chunk-WXURMFT7.js +52 -0
- package/dist/{chunk-VPTKC3UK.cjs → chunk-YHMM6RY5.cjs} +42 -9
- package/dist/clean.cjs +4 -5
- package/dist/clean.d.cts +1 -2
- package/dist/clean.d.ts +1 -2
- package/dist/clean.js +3 -4
- package/dist/config.cjs +5 -14
- package/dist/config.d.cts +4 -6
- package/dist/config.d.ts +4 -6
- package/dist/config.js +6 -15
- package/dist/context.cjs +11 -0
- package/dist/context.d.cts +16 -0
- package/dist/context.d.ts +16 -0
- package/dist/context.js +11 -0
- package/dist/index.cjs +14 -52
- package/dist/index.d.cts +3 -216
- package/dist/index.d.ts +3 -216
- package/dist/index.js +15 -53
- package/dist/package-json.cjs +9 -0
- package/dist/package-json.d.cts +16 -0
- package/dist/package-json.d.ts +16 -0
- package/dist/package-json.js +9 -0
- package/dist/plugins/deps-check.cjs +4 -5
- package/dist/plugins/deps-check.js +3 -4
- package/dist/plugins/resolve-paths.cjs +3 -4
- package/dist/plugins/resolve-paths.d.cts +3 -4
- package/dist/plugins/resolve-paths.d.ts +3 -4
- package/dist/plugins/resolve-paths.js +2 -3
- package/dist/tsup.cjs +8 -0
- package/dist/tsup.d.cts +16 -0
- package/dist/tsup.d.ts +16 -0
- package/dist/tsup.js +8 -0
- package/dist/types.d.cts +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/watch.cjs +111 -0
- package/dist/watch.d.cts +18 -0
- package/dist/watch.d.ts +18 -0
- package/dist/watch.js +111 -0
- package/package.json +59 -38
- package/dist/chunk-27VOV3G4.cjs +0 -23
- package/dist/chunk-2TG2H4XL.js +0 -29
- package/dist/chunk-2X5ZMEAN.js +0 -167
- package/dist/chunk-3QHFCKSI.js +0 -140
- package/dist/chunk-AZON722Q.js +0 -23
- package/dist/chunk-B4CUDMY2.cjs +0 -39
- package/dist/chunk-BOFHC4OE.cjs +0 -26
- package/dist/chunk-BWSIRV3D.js +0 -26
- package/dist/chunk-CCEWV2BR.js +0 -39
- package/dist/chunk-CGMLIVTB.cjs +0 -167
- package/dist/chunk-ILJQ4NCE.cjs +0 -29
- package/dist/chunk-N62ZR7UV.cjs +0 -140
- package/dist/chunk-RLQJRD62.cjs +0 -27
- package/dist/chunk-UYE6LM4C.js +0 -60
- package/dist/chunk-XLUZXKDY.js +0 -27
- package/dist/chunk-Y5SBBYX3.cjs +0 -60
- package/dist/plugins/esm-split-code-to-cjs.cjs +0 -7
- package/dist/plugins/esm-split-code-to-cjs.d.cts +0 -15
- package/dist/plugins/esm-split-code-to-cjs.d.ts +0 -15
- package/dist/plugins/esm-split-code-to-cjs.js +0 -7
- package/dist/plugins/fix-imports.cjs +0 -7
- package/dist/plugins/fix-imports.d.cts +0 -14
- package/dist/plugins/fix-imports.d.ts +0 -14
- package/dist/plugins/fix-imports.js +0 -7
- package/dist/plugins/native-node-module.cjs +0 -7
- package/dist/plugins/native-node-module.d.cts +0 -11
- package/dist/plugins/native-node-module.d.ts +0 -11
- package/dist/plugins/native-node-module.js +0 -7
- package/dist/plugins/node-protocol.cjs +0 -7
- package/dist/plugins/node-protocol.d.cts +0 -15
- package/dist/plugins/node-protocol.d.ts +0 -15
- package/dist/plugins/node-protocol.js +0 -7
- package/dist/plugins/on-error.cjs +0 -9
- package/dist/plugins/on-error.d.cts +0 -14
- package/dist/plugins/on-error.d.ts +0 -14
- package/dist/plugins/on-error.js +0 -9
- package/dist/plugins/tsc.cjs +0 -9
- package/dist/plugins/tsc.d.cts +0 -14
- package/dist/plugins/tsc.d.ts +0 -14
- package/dist/plugins/tsc.js +0 -9
- package/dist/tsc.cjs +0 -17
- package/dist/tsc.d.cts +0 -21
- package/dist/tsc.d.ts +0 -21
- package/dist/tsc.js +0 -17
- package/dist/types-B4jbZA4j.d.cts +0 -1286
- package/dist/types-B4jbZA4j.d.ts +0 -1286
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkFQQYNAPTcjs = require('./chunk-FQQYNAPT.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkEVDNG72Rcjs = require('./chunk-EVDNG72R.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkYHMM6RY5cjs = require('./chunk-YHMM6RY5.cjs');
|
|
11
|
+
|
|
12
|
+
// src/assets.ts
|
|
13
|
+
async function copyBuildAssets(context) {
|
|
14
|
+
if (_optionalChain([context, 'access', _ => _.result, 'optionalAccess', _2 => _2.errors, 'access', _3 => _3.length]) === 0) {
|
|
15
|
+
_chunkEVDNG72Rcjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
|
|
16
|
+
const stopwatch = _chunkEVDNG72Rcjs.getStopwatch.call(void 0, `${context.options.name} asset copy`);
|
|
17
|
+
await _chunkFQQYNAPTcjs.copyAssets.call(void 0, context.workspaceConfig, _nullishCoalesce(context.options.assets, () => ( [])), context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
|
|
18
|
+
stopwatch();
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
_chunkYHMM6RY5cjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.copyBuildAssets = copyBuildAssets;
|
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cleanDirectories
|
|
3
|
-
} from "./chunk-3PF5YMWK.js";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_BUILD_OPTIONS,
|
|
6
|
-
addPackageDependencies,
|
|
7
|
-
addWorkspacePackageJsonFields,
|
|
8
|
-
copyAssets,
|
|
9
|
-
getEnv,
|
|
10
|
-
getWorkspaceConfig
|
|
11
|
-
} from "./chunk-SKJRUPDP.js";
|
|
12
|
-
import {
|
|
13
|
-
depsCheckPlugin
|
|
14
|
-
} from "./chunk-STCE44IS.js";
|
|
15
1
|
import {
|
|
16
2
|
getStopwatch,
|
|
17
|
-
writeDebug
|
|
18
|
-
|
|
19
|
-
writeFatal,
|
|
20
|
-
writeSuccess,
|
|
21
|
-
writeTrace,
|
|
22
|
-
writeWarning
|
|
23
|
-
} from "./chunk-VQHKIS7J.js";
|
|
24
|
-
import {
|
|
25
|
-
joinPaths
|
|
26
|
-
} from "./chunk-Y7JBB452.js";
|
|
3
|
+
writeDebug
|
|
4
|
+
} from "./chunk-TSQT5MWW.js";
|
|
27
5
|
import {
|
|
28
6
|
__commonJS,
|
|
29
7
|
__name,
|
|
30
8
|
__require,
|
|
31
|
-
__toESM
|
|
32
|
-
|
|
9
|
+
__toESM,
|
|
10
|
+
joinPaths
|
|
11
|
+
} from "./chunk-4D6ICA75.js";
|
|
33
12
|
|
|
34
13
|
// ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=6f5ec3d4990820b9e30a2e3135e1e171cde70966824e3b0ca9c0d2f02fc93f24__c75bd232a33dcb63ad2eb667808a0247/node_modules/tsup/dist/chunk-BYH4XDRH.js
|
|
35
14
|
var require_chunk_BYH4XDRH = __commonJS({
|
|
@@ -862,10 +841,10 @@ var require_dist = __commonJS({
|
|
|
862
841
|
var externalPlugin = /* @__PURE__ */ __name(({ external, noExternal, skipNodeModulesBundle, tsconfigResolvePaths }) => {
|
|
863
842
|
return {
|
|
864
843
|
name: `external`,
|
|
865
|
-
setup(
|
|
844
|
+
setup(build2) {
|
|
866
845
|
if (skipNodeModulesBundle) {
|
|
867
846
|
const resolvePatterns = _bundlerequire.tsconfigPathsToRegExp.call(void 0, tsconfigResolvePaths || {});
|
|
868
|
-
|
|
847
|
+
build2.onResolve({
|
|
869
848
|
filter: /.*/
|
|
870
849
|
}, (args) => {
|
|
871
850
|
if (_bundlerequire.match.call(void 0, args.path, resolvePatterns)) {
|
|
@@ -887,7 +866,7 @@ var require_dist = __commonJS({
|
|
|
887
866
|
}
|
|
888
867
|
});
|
|
889
868
|
} else {
|
|
890
|
-
|
|
869
|
+
build2.onResolve({
|
|
891
870
|
filter: /.*/
|
|
892
871
|
}, (args) => {
|
|
893
872
|
if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
|
|
@@ -906,7 +885,7 @@ var require_dist = __commonJS({
|
|
|
906
885
|
var postcssPlugin = /* @__PURE__ */ __name(({ options: options1, css, inject, cssLoader }) => {
|
|
907
886
|
return {
|
|
908
887
|
name: "postcss",
|
|
909
|
-
setup(
|
|
888
|
+
setup(build2) {
|
|
910
889
|
let configCache;
|
|
911
890
|
const getPostcssConfig = /* @__PURE__ */ __name(async () => {
|
|
912
891
|
const loadConfig = _chunkTWFEYLU4js.__require.call(void 0, "postcss-load-config");
|
|
@@ -928,7 +907,7 @@ var require_dist = __commonJS({
|
|
|
928
907
|
throw error;
|
|
929
908
|
}
|
|
930
909
|
}, "getPostcssConfig");
|
|
931
|
-
|
|
910
|
+
build2.onResolve({
|
|
932
911
|
filter: /^#style-inject$/
|
|
933
912
|
}, () => {
|
|
934
913
|
return {
|
|
@@ -936,7 +915,7 @@ var require_dist = __commonJS({
|
|
|
936
915
|
namespace: "#style-inject"
|
|
937
916
|
};
|
|
938
917
|
});
|
|
939
|
-
|
|
918
|
+
build2.onLoad({
|
|
940
919
|
filter: /^#style-inject$/,
|
|
941
920
|
namespace: "#style-inject"
|
|
942
921
|
}, () => {
|
|
@@ -970,7 +949,7 @@ var require_dist = __commonJS({
|
|
|
970
949
|
loader: "js"
|
|
971
950
|
};
|
|
972
951
|
});
|
|
973
|
-
|
|
952
|
+
build2.onLoad({
|
|
974
953
|
filter: /\.css$/
|
|
975
954
|
}, async (args) => {
|
|
976
955
|
let contents;
|
|
@@ -1009,11 +988,11 @@ var require_dist = __commonJS({
|
|
|
1009
988
|
}
|
|
1010
989
|
if (inject) {
|
|
1011
990
|
contents = (await _esbuild.transform.call(void 0, contents, {
|
|
1012
|
-
minify:
|
|
1013
|
-
minifyIdentifiers:
|
|
1014
|
-
minifySyntax:
|
|
1015
|
-
minifyWhitespace:
|
|
1016
|
-
logLevel:
|
|
991
|
+
minify: build2.initialOptions.minify,
|
|
992
|
+
minifyIdentifiers: build2.initialOptions.minifyIdentifiers,
|
|
993
|
+
minifySyntax: build2.initialOptions.minifySyntax,
|
|
994
|
+
minifyWhitespace: build2.initialOptions.minifyWhitespace,
|
|
995
|
+
logLevel: build2.initialOptions.logLevel,
|
|
1017
996
|
loader: "css"
|
|
1018
997
|
})).code;
|
|
1019
998
|
contents = typeof inject === "function" ? await inject(JSON.stringify(contents), args.path) : `import styleInject from '#style-inject';styleInject(${JSON.stringify(contents)})`;
|
|
@@ -1034,10 +1013,10 @@ var require_dist = __commonJS({
|
|
|
1034
1013
|
var sveltePlugin = /* @__PURE__ */ __name(({ css, options: options1 }) => {
|
|
1035
1014
|
return {
|
|
1036
1015
|
name: "svelte",
|
|
1037
|
-
setup(
|
|
1016
|
+
setup(build2) {
|
|
1038
1017
|
let svelte;
|
|
1039
1018
|
let sveltePreprocessor;
|
|
1040
|
-
|
|
1019
|
+
build2.onResolve({
|
|
1041
1020
|
filter: /\.svelte\.css$/
|
|
1042
1021
|
}, (args) => {
|
|
1043
1022
|
return {
|
|
@@ -1045,7 +1024,7 @@ var require_dist = __commonJS({
|
|
|
1045
1024
|
namespace: "svelte-css"
|
|
1046
1025
|
};
|
|
1047
1026
|
});
|
|
1048
|
-
|
|
1027
|
+
build2.onLoad({
|
|
1049
1028
|
filter: /\.svelte$/
|
|
1050
1029
|
}, async (args) => {
|
|
1051
1030
|
svelte = svelte || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte/compiler");
|
|
@@ -1101,7 +1080,7 @@ var require_dist = __commonJS({
|
|
|
1101
1080
|
verbatimModuleSyntax: true
|
|
1102
1081
|
}
|
|
1103
1082
|
},
|
|
1104
|
-
logLevel:
|
|
1083
|
+
logLevel: build2.initialOptions.logLevel
|
|
1105
1084
|
});
|
|
1106
1085
|
return {
|
|
1107
1086
|
code,
|
|
@@ -1139,14 +1118,14 @@ var require_dist = __commonJS({
|
|
|
1139
1118
|
var swcPlugin = /* @__PURE__ */ __name(({ logger: logger3 }) => {
|
|
1140
1119
|
return {
|
|
1141
1120
|
name: "swc",
|
|
1142
|
-
setup(
|
|
1121
|
+
setup(build2) {
|
|
1143
1122
|
const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
|
|
1144
1123
|
if (!swc) {
|
|
1145
|
-
logger3.warn(
|
|
1124
|
+
logger3.warn(build2.initialOptions.format, `You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin`);
|
|
1146
1125
|
return;
|
|
1147
1126
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1127
|
+
build2.initialOptions.keepNames = true;
|
|
1128
|
+
build2.onLoad({
|
|
1150
1129
|
filter: /\.[jt]sx?$/
|
|
1151
1130
|
}, async (args) => {
|
|
1152
1131
|
const isTs = /\.tsx?$/.test(args.path);
|
|
@@ -1186,8 +1165,8 @@ var require_dist = __commonJS({
|
|
|
1186
1165
|
var nativeNodeModulesPlugin = /* @__PURE__ */ __name(() => {
|
|
1187
1166
|
return {
|
|
1188
1167
|
name: "native-node-modules",
|
|
1189
|
-
setup(
|
|
1190
|
-
|
|
1168
|
+
setup(build2) {
|
|
1169
|
+
build2.onResolve({
|
|
1191
1170
|
filter: /\.node$/,
|
|
1192
1171
|
namespace: "file"
|
|
1193
1172
|
}, (args) => {
|
|
@@ -1206,7 +1185,7 @@ var require_dist = __commonJS({
|
|
|
1206
1185
|
path: resolvedId
|
|
1207
1186
|
};
|
|
1208
1187
|
});
|
|
1209
|
-
|
|
1188
|
+
build2.onLoad({
|
|
1210
1189
|
filter: /.*/,
|
|
1211
1190
|
namespace: "node-file"
|
|
1212
1191
|
}, (args) => {
|
|
@@ -1219,14 +1198,14 @@ var require_dist = __commonJS({
|
|
|
1219
1198
|
resolveDir: _path2.default.dirname(args.path)
|
|
1220
1199
|
};
|
|
1221
1200
|
});
|
|
1222
|
-
|
|
1201
|
+
build2.onResolve({
|
|
1223
1202
|
filter: /\.node$/,
|
|
1224
1203
|
namespace: "node-file"
|
|
1225
1204
|
}, (args) => ({
|
|
1226
1205
|
path: args.path,
|
|
1227
1206
|
namespace: "file"
|
|
1228
1207
|
}));
|
|
1229
|
-
const opts =
|
|
1208
|
+
const opts = build2.initialOptions;
|
|
1230
1209
|
opts.loader = opts.loader || {};
|
|
1231
1210
|
opts.loader[".node"] = "file";
|
|
1232
1211
|
}
|
|
@@ -1294,10 +1273,10 @@ var require_dist = __commonJS({
|
|
|
1294
1273
|
format === "cjs" && options1.removeNodeProtocol && nodeProtocolPlugin(),
|
|
1295
1274
|
{
|
|
1296
1275
|
name: "modify-options",
|
|
1297
|
-
setup(
|
|
1298
|
-
pluginContainer.modifyEsbuildOptions(
|
|
1276
|
+
setup(build2) {
|
|
1277
|
+
pluginContainer.modifyEsbuildOptions(build2.initialOptions);
|
|
1299
1278
|
if (options1.esbuildOptions) {
|
|
1300
|
-
options1.esbuildOptions(
|
|
1279
|
+
options1.esbuildOptions(build2.initialOptions, {
|
|
1301
1280
|
format
|
|
1302
1281
|
});
|
|
1303
1282
|
}
|
|
@@ -2302,7 +2281,7 @@ module.exports = exports.default;
|
|
|
2302
2281
|
}
|
|
2303
2282
|
return options1;
|
|
2304
2283
|
}, "normalizeOptions");
|
|
2305
|
-
async function
|
|
2284
|
+
async function build(_options) {
|
|
2306
2285
|
const config = _options.config === false ? {} : await _chunkVGC3FXLUjs.loadTsupConfig.call(void 0, _options.workspaceConfig?.workspaceRoot || process.cwd(), _options.config === true ? void 0 : _options.config);
|
|
2307
2286
|
const configData = typeof config.data === "function" ? await config.data(_options) : config.data;
|
|
2308
2287
|
await Promise.all([
|
|
@@ -2485,7 +2464,7 @@ module.exports = exports.default;
|
|
|
2485
2464
|
}, "buildAll");
|
|
2486
2465
|
const startWatcher = /* @__PURE__ */ __name(async () => {
|
|
2487
2466
|
if (!options1.watch) return;
|
|
2488
|
-
const { watch
|
|
2467
|
+
const { watch } = await Promise.resolve().then(() => _interopRequireWildcard(__require("chokidar")));
|
|
2489
2468
|
const customIgnores = options1.ignoreWatch ? Array.isArray(options1.ignoreWatch) ? options1.ignoreWatch : [
|
|
2490
2469
|
options1.ignoreWatch
|
|
2491
2470
|
] : [];
|
|
@@ -2497,7 +2476,7 @@ module.exports = exports.default;
|
|
|
2497
2476
|
const watchPaths = typeof options1.watch === "boolean" ? "." : Array.isArray(options1.watch) ? options1.watch.filter((path12) => typeof path12 === "string") : options1.watch;
|
|
2498
2477
|
logger3.info("CLI", `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => `"${v}"`).join(" | ") : `"${watchPaths}"`}`);
|
|
2499
2478
|
logger3.info("CLI", `Ignoring changes in ${ignored.map((v) => `"${v}"`).join(" | ")}`);
|
|
2500
|
-
const watcher =
|
|
2479
|
+
const watcher = watch(await _tinyglobby.glob.call(void 0, watchPaths), {
|
|
2501
2480
|
ignoreInitial: true,
|
|
2502
2481
|
ignorePermissionErrors: true,
|
|
2503
2482
|
ignored: /* @__PURE__ */ __name((p) => _tinyglobby.globSync.call(void 0, p, {
|
|
@@ -2540,262 +2519,14 @@ module.exports = exports.default;
|
|
|
2540
2519
|
]);
|
|
2541
2520
|
}));
|
|
2542
2521
|
}
|
|
2543
|
-
__name(
|
|
2544
|
-
exports.build =
|
|
2522
|
+
__name(build, "build");
|
|
2523
|
+
exports.build = build;
|
|
2545
2524
|
exports.defineConfig = defineConfig;
|
|
2546
2525
|
}
|
|
2547
2526
|
});
|
|
2548
2527
|
|
|
2549
|
-
// src/
|
|
2550
|
-
import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
|
|
2528
|
+
// src/tsup.ts
|
|
2551
2529
|
var import_tsup = __toESM(require_dist(), 1);
|
|
2552
|
-
import { watch as createWatcher } from "chokidar";
|
|
2553
|
-
import defu from "defu";
|
|
2554
|
-
import { debounce } from "es-toolkit";
|
|
2555
|
-
import * as esbuild from "esbuild";
|
|
2556
|
-
import { globbySync } from "globby";
|
|
2557
|
-
import { existsSync } from "node:fs";
|
|
2558
|
-
import hf from "node:fs/promises";
|
|
2559
|
-
import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root";
|
|
2560
|
-
|
|
2561
|
-
// src/utilities/helpers.ts
|
|
2562
|
-
function handleSync(fn) {
|
|
2563
|
-
try {
|
|
2564
|
-
return fn();
|
|
2565
|
-
} catch (error_) {
|
|
2566
|
-
return error_;
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
__name(handleSync, "handleSync");
|
|
2570
|
-
async function handleAsync(fn) {
|
|
2571
|
-
try {
|
|
2572
|
-
return await fn();
|
|
2573
|
-
} catch (error_) {
|
|
2574
|
-
return error_;
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
__name(handleAsync, "handleAsync");
|
|
2578
|
-
var handle = handleSync;
|
|
2579
|
-
handle.async = handleAsync;
|
|
2580
|
-
var skip = Symbol("skip");
|
|
2581
|
-
function transduceSync(list, transformer) {
|
|
2582
|
-
const transduced = [];
|
|
2583
|
-
for (const [i, element_] of list.entries()) {
|
|
2584
|
-
const transformed = transformer(element_, i);
|
|
2585
|
-
if (transformed !== skip) {
|
|
2586
|
-
transduced[transduced.length] = transformed;
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
return transduced;
|
|
2590
|
-
}
|
|
2591
|
-
__name(transduceSync, "transduceSync");
|
|
2592
|
-
async function transduceAsync(list, transformer) {
|
|
2593
|
-
const transduced = [];
|
|
2594
|
-
await Promise.all(list.entries().map(async ([i, element_]) => {
|
|
2595
|
-
const transformed = await transformer(element_, i);
|
|
2596
|
-
if (transformed !== skip) {
|
|
2597
|
-
transduced[transduced.length] = transformed;
|
|
2598
|
-
}
|
|
2599
|
-
}));
|
|
2600
|
-
return transduced;
|
|
2601
|
-
}
|
|
2602
|
-
__name(transduceAsync, "transduceAsync");
|
|
2603
|
-
var Filter = /* @__PURE__ */ __name((filter) => (item) => {
|
|
2604
|
-
return filter(item) ? item : skip;
|
|
2605
|
-
}, "Filter");
|
|
2606
|
-
var Mapper = /* @__PURE__ */ __name((mapper) => (item) => {
|
|
2607
|
-
return mapper(item);
|
|
2608
|
-
}, "Mapper");
|
|
2609
|
-
var transduce = transduceSync;
|
|
2610
|
-
transduce.async = transduceAsync;
|
|
2611
|
-
function pipeSync(fn, ...fns) {
|
|
2612
|
-
return (...args) => {
|
|
2613
|
-
let result = fn(...args);
|
|
2614
|
-
for (let i = 0; result !== skip && i < fns.length; ++i) {
|
|
2615
|
-
result = fns[i]?.(result);
|
|
2616
|
-
}
|
|
2617
|
-
return result;
|
|
2618
|
-
};
|
|
2619
|
-
}
|
|
2620
|
-
__name(pipeSync, "pipeSync");
|
|
2621
|
-
function pipeAsync(fn, ...fns) {
|
|
2622
|
-
return async (...args) => {
|
|
2623
|
-
let result = await fn(...args);
|
|
2624
|
-
for (let i = 0; result !== skip && i < fns.length; ++i) {
|
|
2625
|
-
result = await fns[i]?.(result);
|
|
2626
|
-
}
|
|
2627
|
-
return result;
|
|
2628
|
-
};
|
|
2629
|
-
}
|
|
2630
|
-
__name(pipeAsync, "pipeAsync");
|
|
2631
|
-
var pipe = pipeSync;
|
|
2632
|
-
pipe.async = pipeAsync;
|
|
2633
|
-
|
|
2634
|
-
// src/build.ts
|
|
2635
|
-
async function resolveContext(userOptions) {
|
|
2636
|
-
const projectRoot = userOptions.projectRoot;
|
|
2637
|
-
const workspaceRoot = findWorkspaceRoot(projectRoot);
|
|
2638
|
-
if (!workspaceRoot) {
|
|
2639
|
-
throw new Error("Cannot find Nx workspace root");
|
|
2640
|
-
}
|
|
2641
|
-
const workspaceConfig = await getWorkspaceConfig(true, {
|
|
2642
|
-
workspaceRoot: workspaceRoot.dir
|
|
2643
|
-
});
|
|
2644
|
-
writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
|
|
2645
|
-
const stopwatch = getStopwatch("Build options resolution");
|
|
2646
|
-
const projectGraph = await createProjectGraphAsync({
|
|
2647
|
-
exitOnError: true
|
|
2648
|
-
});
|
|
2649
|
-
const projectJsonPath = joinPaths(workspaceRoot.dir, projectRoot, "project.json");
|
|
2650
|
-
if (!existsSync(projectJsonPath)) {
|
|
2651
|
-
throw new Error("Cannot find project.json configuration");
|
|
2652
|
-
}
|
|
2653
|
-
const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
|
|
2654
|
-
const projectJson = JSON.parse(projectJsonFile);
|
|
2655
|
-
const projectName = projectJson.name || userOptions.name;
|
|
2656
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
2657
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
2658
|
-
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.");
|
|
2659
|
-
}
|
|
2660
|
-
const options2 = defu(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
2661
|
-
options2.name ??= projectName;
|
|
2662
|
-
const packageJsonPath = joinPaths(workspaceRoot.dir, options2.projectRoot, "package.json");
|
|
2663
|
-
if (!existsSync(packageJsonPath)) {
|
|
2664
|
-
throw new Error("Cannot find package.json configuration");
|
|
2665
|
-
}
|
|
2666
|
-
const env = getEnv("esbuild", options2);
|
|
2667
|
-
const define = defu(options2.define ?? {}, env ?? {});
|
|
2668
|
-
const resolvedOptions = {
|
|
2669
|
-
...options2,
|
|
2670
|
-
tsconfig: joinPaths(projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"),
|
|
2671
|
-
metafile: userOptions.mode === "development",
|
|
2672
|
-
clean: false,
|
|
2673
|
-
env,
|
|
2674
|
-
define: {
|
|
2675
|
-
STORM_FORMAT: JSON.stringify(options2.format),
|
|
2676
|
-
...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
|
|
2677
|
-
const value = JSON.stringify(define[key]);
|
|
2678
|
-
const safeKey = key.replaceAll("(", "").replaceAll(")", "");
|
|
2679
|
-
return {
|
|
2680
|
-
...res,
|
|
2681
|
-
[`process.env.${safeKey}`]: value,
|
|
2682
|
-
[`import.meta.env.${safeKey}`]: value
|
|
2683
|
-
};
|
|
2684
|
-
}, {})
|
|
2685
|
-
}
|
|
2686
|
-
};
|
|
2687
|
-
stopwatch();
|
|
2688
|
-
return {
|
|
2689
|
-
options: resolvedOptions,
|
|
2690
|
-
clean: userOptions.clean !== false,
|
|
2691
|
-
workspaceConfig,
|
|
2692
|
-
projectConfigurations,
|
|
2693
|
-
projectName,
|
|
2694
|
-
projectGraph,
|
|
2695
|
-
sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || joinPaths(resolvedOptions.projectRoot, "src"),
|
|
2696
|
-
outputPath: resolvedOptions.outputPath || joinPaths(workspaceConfig.workspaceRoot, "dist", resolvedOptions.projectRoot),
|
|
2697
|
-
minify: resolvedOptions.minify || resolvedOptions.mode === "production"
|
|
2698
|
-
};
|
|
2699
|
-
}
|
|
2700
|
-
__name(resolveContext, "resolveContext");
|
|
2701
|
-
async function generatePackageJson(context) {
|
|
2702
|
-
if (context.options.generatePackageJson !== false && existsSync(joinPaths(context.options.projectRoot, "package.json"))) {
|
|
2703
|
-
writeDebug(" \u270D\uFE0F Writing package.json file", context.workspaceConfig);
|
|
2704
|
-
const stopwatch = getStopwatch("Write package.json file");
|
|
2705
|
-
const packageJsonPath = joinPaths(context.options.projectRoot, "project.json");
|
|
2706
|
-
if (!existsSync(packageJsonPath)) {
|
|
2707
|
-
throw new Error("Cannot find package.json configuration");
|
|
2708
|
-
}
|
|
2709
|
-
const packageJsonFile = await hf.readFile(joinPaths(context.workspaceConfig.workspaceRoot, context.options.projectRoot, "package.json"), "utf8");
|
|
2710
|
-
let packageJson = JSON.parse(packageJsonFile);
|
|
2711
|
-
if (!packageJson) {
|
|
2712
|
-
throw new Error("Cannot find package.json configuration file");
|
|
2713
|
-
}
|
|
2714
|
-
packageJson = await addPackageDependencies(context.workspaceConfig.workspaceRoot, context.options.projectRoot, context.projectName, packageJson);
|
|
2715
|
-
packageJson = await addWorkspacePackageJsonFields(context.workspaceConfig, context.options.projectRoot, context.sourceRoot, context.projectName, false, packageJson);
|
|
2716
|
-
if (context.options.entry) {
|
|
2717
|
-
packageJson.exports ??= {};
|
|
2718
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
2719
|
-
const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
|
|
2720
|
-
if (entryPoints.length > 0) {
|
|
2721
|
-
const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
|
|
2722
|
-
const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
|
|
2723
|
-
const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
|
|
2724
|
-
const isDts = context.options.dts || context.options.experimentalDts;
|
|
2725
|
-
packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
|
|
2726
|
-
for (const entryPoint of entryPoints) {
|
|
2727
|
-
packageJson.exports[`./${entryPoint}`] ??= {};
|
|
2728
|
-
if (isEsm) {
|
|
2729
|
-
if (isDts) {
|
|
2730
|
-
packageJson.exports[`./${entryPoint}`].import = {
|
|
2731
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
2732
|
-
default: `./dist/${entryPoint}.mjs`
|
|
2733
|
-
};
|
|
2734
|
-
} else {
|
|
2735
|
-
packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
|
|
2736
|
-
}
|
|
2737
|
-
if (isDts) {
|
|
2738
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
2739
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
2740
|
-
default: `./dist/${entryPoint}.mjs`
|
|
2741
|
-
};
|
|
2742
|
-
} else {
|
|
2743
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
if (isCjs) {
|
|
2747
|
-
if (isDts) {
|
|
2748
|
-
packageJson.exports[`./${entryPoint}`].require = {
|
|
2749
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
2750
|
-
default: `./dist/${entryPoint}.cjs`
|
|
2751
|
-
};
|
|
2752
|
-
} else {
|
|
2753
|
-
packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
|
|
2754
|
-
}
|
|
2755
|
-
if (!isEsm) {
|
|
2756
|
-
if (isDts) {
|
|
2757
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
2758
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
2759
|
-
default: `./dist/${entryPoint}.cjs`
|
|
2760
|
-
};
|
|
2761
|
-
} else {
|
|
2762
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
}
|
|
2766
|
-
if (!isEsm && !isCjs) {
|
|
2767
|
-
if (isDts) {
|
|
2768
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
2769
|
-
types: `./dist/${entryPoint}.d.ts`,
|
|
2770
|
-
default: `./dist/${entryPoint}.js`
|
|
2771
|
-
};
|
|
2772
|
-
} else {
|
|
2773
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
}
|
|
2777
|
-
if (isEsm) {
|
|
2778
|
-
packageJson.module = `${defaultEntry}.mjs`;
|
|
2779
|
-
} else {
|
|
2780
|
-
packageJson.main = `${defaultEntry}.cjs`;
|
|
2781
|
-
}
|
|
2782
|
-
if (isDts) {
|
|
2783
|
-
packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
|
|
2784
|
-
}
|
|
2785
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce((ret, key) => {
|
|
2786
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
2787
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
2788
|
-
}
|
|
2789
|
-
return ret;
|
|
2790
|
-
}, packageJson.exports);
|
|
2791
|
-
}
|
|
2792
|
-
}
|
|
2793
|
-
await writeJsonFile(joinPaths(context.outputPath, "package.json"), packageJson);
|
|
2794
|
-
stopwatch();
|
|
2795
|
-
}
|
|
2796
|
-
return context;
|
|
2797
|
-
}
|
|
2798
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
2799
2530
|
async function executeTsup(context) {
|
|
2800
2531
|
writeDebug(` \u{1F680} Running ${context.options.name} build`, context.workspaceConfig);
|
|
2801
2532
|
const stopwatch = getStopwatch(`${context.options.name} build`);
|
|
@@ -2808,132 +2539,7 @@ async function executeTsup(context) {
|
|
|
2808
2539
|
return context;
|
|
2809
2540
|
}
|
|
2810
2541
|
__name(executeTsup, "executeTsup");
|
|
2811
|
-
async function copyBuildAssets(context) {
|
|
2812
|
-
if (context.result?.errors.length === 0) {
|
|
2813
|
-
writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context.outputPath}`, context.workspaceConfig);
|
|
2814
|
-
const stopwatch = getStopwatch(`${context.options.name} asset copy`);
|
|
2815
|
-
await copyAssets(context.workspaceConfig, context.options.assets ?? [], context.outputPath, context.options.projectRoot, context.sourceRoot, true, false);
|
|
2816
|
-
stopwatch();
|
|
2817
|
-
}
|
|
2818
|
-
return context;
|
|
2819
|
-
}
|
|
2820
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
2821
|
-
async function reportResults(context) {
|
|
2822
|
-
if (context.result?.errors.length === 0) {
|
|
2823
|
-
if (context.result.warnings.length > 0) {
|
|
2824
|
-
writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`, context.workspaceConfig);
|
|
2825
|
-
}
|
|
2826
|
-
writeSuccess(` \u{1F4E6} The ${context.options.name} build completed successfully`, context.workspaceConfig);
|
|
2827
|
-
} else if (context.result?.errors && context.result?.errors.length > 0) {
|
|
2828
|
-
writeError(` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`, context.workspaceConfig);
|
|
2829
|
-
throw new Error(`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`);
|
|
2830
|
-
}
|
|
2831
|
-
}
|
|
2832
|
-
__name(reportResults, "reportResults");
|
|
2833
|
-
async function dependencyCheck(options2) {
|
|
2834
|
-
if (process.env.DEV === "true") {
|
|
2835
|
-
return void 0;
|
|
2836
|
-
}
|
|
2837
|
-
if (process.env.CI && !process.env.BUILDKITE) {
|
|
2838
|
-
return void 0;
|
|
2839
|
-
}
|
|
2840
|
-
const buildPromise = esbuild.build({
|
|
2841
|
-
entryPoints: globbySync("**/*.{j,t}s", {
|
|
2842
|
-
// We don't check dependencies in ecosystem tests because tests are isolated from the build.
|
|
2843
|
-
ignore: [
|
|
2844
|
-
"./src/__tests__/**/*",
|
|
2845
|
-
"./tests/e2e/**/*",
|
|
2846
|
-
"./dist/**/*"
|
|
2847
|
-
],
|
|
2848
|
-
gitignore: true
|
|
2849
|
-
}),
|
|
2850
|
-
logLevel: "silent",
|
|
2851
|
-
bundle: true,
|
|
2852
|
-
write: false,
|
|
2853
|
-
outdir: "out",
|
|
2854
|
-
plugins: [
|
|
2855
|
-
depsCheckPlugin(options2.bundle)
|
|
2856
|
-
]
|
|
2857
|
-
});
|
|
2858
|
-
await buildPromise.catch(() => {
|
|
2859
|
-
});
|
|
2860
|
-
return void 0;
|
|
2861
|
-
}
|
|
2862
|
-
__name(dependencyCheck, "dependencyCheck");
|
|
2863
|
-
async function cleanOutputPath(context) {
|
|
2864
|
-
if (context.clean !== false && context.outputPath) {
|
|
2865
|
-
writeDebug(` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`, context.workspaceConfig);
|
|
2866
|
-
const stopwatch = getStopwatch(`${context.options.name} output clean`);
|
|
2867
|
-
await cleanDirectories(context.outputPath);
|
|
2868
|
-
stopwatch();
|
|
2869
|
-
}
|
|
2870
|
-
return context;
|
|
2871
|
-
}
|
|
2872
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
2873
|
-
async function build2(options2) {
|
|
2874
|
-
writeDebug(` \u26A1 Executing Storm ESBuild pipeline`);
|
|
2875
|
-
const stopwatch = getStopwatch("ESBuild pipeline");
|
|
2876
|
-
try {
|
|
2877
|
-
const opts = Array.isArray(options2) ? options2 : [
|
|
2878
|
-
options2
|
|
2879
|
-
];
|
|
2880
|
-
if (opts.length === 0) {
|
|
2881
|
-
throw new Error("No build options were provided");
|
|
2882
|
-
}
|
|
2883
|
-
const context = await resolveContext(options2);
|
|
2884
|
-
await cleanOutputPath(context);
|
|
2885
|
-
await Promise.all([
|
|
2886
|
-
dependencyCheck(context.options),
|
|
2887
|
-
generatePackageJson(context),
|
|
2888
|
-
copyBuildAssets(context),
|
|
2889
|
-
executeTsup(context)
|
|
2890
|
-
]);
|
|
2891
|
-
await reportResults(context);
|
|
2892
|
-
writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
|
|
2893
|
-
} catch (error) {
|
|
2894
|
-
writeFatal("Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
|
|
2895
|
-
throw error;
|
|
2896
|
-
} finally {
|
|
2897
|
-
stopwatch();
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
__name(build2, "build");
|
|
2901
|
-
var watch = /* @__PURE__ */ __name((context, options2) => {
|
|
2902
|
-
if (!options2.watch) {
|
|
2903
|
-
return context;
|
|
2904
|
-
}
|
|
2905
|
-
const config = {
|
|
2906
|
-
ignoreInitial: true,
|
|
2907
|
-
useFsEvents: true,
|
|
2908
|
-
ignored: [
|
|
2909
|
-
"./src/__tests__/**/*",
|
|
2910
|
-
"./package.json"
|
|
2911
|
-
]
|
|
2912
|
-
};
|
|
2913
|
-
const changeWatcher = createWatcher([
|
|
2914
|
-
"./src/**/*"
|
|
2915
|
-
], config);
|
|
2916
|
-
const fastRebuild = debounce(async () => {
|
|
2917
|
-
const timeBefore = Date.now();
|
|
2918
|
-
const rebuildResult = await handle.async(() => {
|
|
2919
|
-
return context.rebuild();
|
|
2920
|
-
});
|
|
2921
|
-
if (rebuildResult instanceof Error) {
|
|
2922
|
-
writeError(rebuildResult.message);
|
|
2923
|
-
}
|
|
2924
|
-
writeTrace(`${Date.now() - timeBefore}ms [${options2.name ?? ""}]`);
|
|
2925
|
-
}, 10);
|
|
2926
|
-
changeWatcher.on("change", fastRebuild);
|
|
2927
|
-
return void 0;
|
|
2928
|
-
}, "watch");
|
|
2929
2542
|
|
|
2930
2543
|
export {
|
|
2931
|
-
|
|
2932
|
-
skip,
|
|
2933
|
-
Filter,
|
|
2934
|
-
Mapper,
|
|
2935
|
-
transduce,
|
|
2936
|
-
pipe,
|
|
2937
|
-
build2 as build,
|
|
2938
|
-
watch
|
|
2544
|
+
executeTsup
|
|
2939
2545
|
};
|