@storm-software/esbuild 0.0.1 → 0.1.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.
- package/README.md +9 -8
- package/dist/build.cjs +14 -0
- package/dist/build.d.cts +14 -0
- package/dist/build.d.ts +14 -0
- package/dist/build.js +14 -0
- package/dist/chunk-3C3PXJUM.cjs +28 -0
- package/dist/chunk-3GQAWCBQ.js +13 -0
- package/dist/chunk-4TW4ZA3I.js +52 -0
- package/dist/chunk-5JHKW6MG.js +126 -0
- package/dist/chunk-5S2XTAF2.cjs +337 -0
- package/dist/chunk-A6CGWMV7.cjs +126 -0
- package/dist/chunk-BGYQAVKQ.cjs +13 -0
- package/dist/chunk-DCWECOOS.cjs +22 -0
- package/dist/chunk-ELGZJRET.js +39 -0
- package/dist/chunk-GGNOJ77I.js +0 -0
- package/dist/chunk-LVDPGHWK.js +28 -0
- package/dist/chunk-MTKAAECG.cjs +101 -0
- package/dist/chunk-NVGEXPTG.cjs +39 -0
- package/dist/chunk-PCGRI6Z6.js +101 -0
- package/dist/chunk-RJQ3LCGJ.cjs +14 -0
- package/dist/chunk-RKSGVSXZ.js +22 -0
- package/dist/chunk-SFZRYJZ2.cjs +1 -0
- package/dist/chunk-WLHWKRZB.cjs +52 -0
- package/dist/chunk-YGD5JBOH.js +337 -0
- package/dist/chunk-YIAZ64WG.js +14 -0
- package/dist/config.cjs +9 -0
- package/dist/config.d.cts +15 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +9 -0
- package/dist/index.cjs +38 -0
- package/dist/index.d.cts +230 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +38 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.cts +19 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/package.json +149 -3
- package/index.cjs +0 -19751
- package/index.js +0 -19748
- package/meta.cjs.json +0 -12657
- package/meta.esm.json +0 -12669
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onErrorPlugin
|
|
3
|
+
} from "./chunk-RKSGVSXZ.js";
|
|
4
|
+
import {
|
|
5
|
+
resolvePathsPlugin
|
|
6
|
+
} from "./chunk-4TW4ZA3I.js";
|
|
7
|
+
import {
|
|
8
|
+
tscPlugin
|
|
9
|
+
} from "./chunk-5JHKW6MG.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_BUILD_OPTIONS
|
|
12
|
+
} from "./chunk-ELGZJRET.js";
|
|
13
|
+
import {
|
|
14
|
+
depsCheckPlugin
|
|
15
|
+
} from "./chunk-PCGRI6Z6.js";
|
|
16
|
+
import {
|
|
17
|
+
writeLog
|
|
18
|
+
} from "./chunk-YIAZ64WG.js";
|
|
19
|
+
import {
|
|
20
|
+
fixImportsPlugin
|
|
21
|
+
} from "./chunk-LVDPGHWK.js";
|
|
22
|
+
import {
|
|
23
|
+
__name
|
|
24
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
25
|
+
|
|
26
|
+
// src/build.ts
|
|
27
|
+
import { hfs } from "@humanfs/node";
|
|
28
|
+
import { createProjectGraphAsync, joinPathFragments, readJsonFile, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
|
|
29
|
+
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
30
|
+
import { watch as createWatcher } from "chokidar";
|
|
31
|
+
import { debounce, flatten, omit } from "es-toolkit";
|
|
32
|
+
import { map } from "es-toolkit/compat";
|
|
33
|
+
import * as esbuild from "esbuild";
|
|
34
|
+
import { globbySync } from "globby";
|
|
35
|
+
import { existsSync } from "node:fs";
|
|
36
|
+
import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root";
|
|
37
|
+
|
|
38
|
+
// src/utilities/helpers.ts
|
|
39
|
+
function handleSync(fn) {
|
|
40
|
+
try {
|
|
41
|
+
return fn();
|
|
42
|
+
} catch (error_) {
|
|
43
|
+
return error_;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
__name(handleSync, "handleSync");
|
|
47
|
+
async function handleAsync(fn) {
|
|
48
|
+
try {
|
|
49
|
+
return await fn();
|
|
50
|
+
} catch (error_) {
|
|
51
|
+
return error_;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
__name(handleAsync, "handleAsync");
|
|
55
|
+
var handle = handleSync;
|
|
56
|
+
handle.async = handleAsync;
|
|
57
|
+
var skip = Symbol("skip");
|
|
58
|
+
function transduceSync(list, transformer) {
|
|
59
|
+
const transduced = [];
|
|
60
|
+
for (const [i, element_] of list.entries()) {
|
|
61
|
+
const transformed = transformer(element_, i);
|
|
62
|
+
if (transformed !== skip) {
|
|
63
|
+
transduced[transduced.length] = transformed;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return transduced;
|
|
67
|
+
}
|
|
68
|
+
__name(transduceSync, "transduceSync");
|
|
69
|
+
async function transduceAsync(list, transformer) {
|
|
70
|
+
const transduced = [];
|
|
71
|
+
await Promise.all(list.entries().map(async ([i, element_]) => {
|
|
72
|
+
const transformed = await transformer(element_, i);
|
|
73
|
+
if (transformed !== skip) {
|
|
74
|
+
transduced[transduced.length] = transformed;
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
return transduced;
|
|
78
|
+
}
|
|
79
|
+
__name(transduceAsync, "transduceAsync");
|
|
80
|
+
var Filter = /* @__PURE__ */ __name((filter) => (item) => {
|
|
81
|
+
return filter(item) ? item : skip;
|
|
82
|
+
}, "Filter");
|
|
83
|
+
var Mapper = /* @__PURE__ */ __name((mapper) => (item) => {
|
|
84
|
+
return mapper(item);
|
|
85
|
+
}, "Mapper");
|
|
86
|
+
var transduce = transduceSync;
|
|
87
|
+
transduce.async = transduceAsync;
|
|
88
|
+
function pipeSync(fn, ...fns) {
|
|
89
|
+
return (...args) => {
|
|
90
|
+
let result = fn(...args);
|
|
91
|
+
for (let i = 0; result !== skip && i < fns.length; ++i) {
|
|
92
|
+
result = fns[i]?.(result);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
__name(pipeSync, "pipeSync");
|
|
98
|
+
function pipeAsync(fn, ...fns) {
|
|
99
|
+
return async (...args) => {
|
|
100
|
+
let result = await fn(...args);
|
|
101
|
+
for (let i = 0; result !== skip && i < fns.length; ++i) {
|
|
102
|
+
result = await fns[i]?.(result);
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
__name(pipeAsync, "pipeAsync");
|
|
108
|
+
var pipe = pipeSync;
|
|
109
|
+
pipe.async = pipeAsync;
|
|
110
|
+
|
|
111
|
+
// src/build.ts
|
|
112
|
+
var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
113
|
+
const projectRoot = options.projectRoot;
|
|
114
|
+
const workspaceRoot = findWorkspaceRoot(projectRoot);
|
|
115
|
+
if (!workspaceRoot) {
|
|
116
|
+
throw new Error("Cannot find Nx workspace root");
|
|
117
|
+
}
|
|
118
|
+
const nxJsonPath = joinPathFragments(workspaceRoot.dir, "nx.json");
|
|
119
|
+
if (!await hfs.isFile(nxJsonPath)) {
|
|
120
|
+
throw new Error("Cannot find Nx workspace configuration");
|
|
121
|
+
}
|
|
122
|
+
const projectGraph = await createProjectGraphAsync({
|
|
123
|
+
exitOnError: true
|
|
124
|
+
});
|
|
125
|
+
const projectJsonPath = joinPathFragments(workspaceRoot.dir, projectRoot, "project.json");
|
|
126
|
+
if (!await hfs.isFile(projectJsonPath)) {
|
|
127
|
+
throw new Error("Cannot find project.json configuration");
|
|
128
|
+
}
|
|
129
|
+
const projectJson = await hfs.json(projectJsonPath);
|
|
130
|
+
const projectName = projectJson.name;
|
|
131
|
+
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
132
|
+
if (!projectConfigurations?.projects?.[projectName]) {
|
|
133
|
+
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.");
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
...DEFAULT_BUILD_OPTIONS,
|
|
137
|
+
format: "cjs",
|
|
138
|
+
outExtension: {
|
|
139
|
+
".js": ".js"
|
|
140
|
+
},
|
|
141
|
+
resolveExtensions: [
|
|
142
|
+
".ts",
|
|
143
|
+
".js",
|
|
144
|
+
".node"
|
|
145
|
+
],
|
|
146
|
+
entryPoints: globbySync("./src/**/*.{j,t}s", {
|
|
147
|
+
ignore: [
|
|
148
|
+
"./src/__tests__/**/*"
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
mainFields: [
|
|
152
|
+
"module",
|
|
153
|
+
"main"
|
|
154
|
+
],
|
|
155
|
+
...options,
|
|
156
|
+
outdir: options.outdir || joinPathFragments(workspaceRoot.dir, "dist", projectRoot),
|
|
157
|
+
plugins: [
|
|
158
|
+
...options.plugins ?? [],
|
|
159
|
+
resolvePathsPlugin,
|
|
160
|
+
fixImportsPlugin,
|
|
161
|
+
tscPlugin(options.emitTypes),
|
|
162
|
+
onErrorPlugin
|
|
163
|
+
],
|
|
164
|
+
external: [
|
|
165
|
+
...options.external ?? []
|
|
166
|
+
],
|
|
167
|
+
name: `${options.name || projectName}-${options.format || "cjs"}`,
|
|
168
|
+
projectConfigurations,
|
|
169
|
+
projectName,
|
|
170
|
+
projectGraph,
|
|
171
|
+
workspaceRoot
|
|
172
|
+
};
|
|
173
|
+
}, "resolveOptions");
|
|
174
|
+
var generatePackageJson = /* @__PURE__ */ __name(async (options) => {
|
|
175
|
+
const nxJsonPath = joinPathFragments(options.workspaceRoot.dir, "nx.json");
|
|
176
|
+
if (!await hfs.isFile(nxJsonPath)) {
|
|
177
|
+
throw new Error("Cannot find Nx workspace configuration");
|
|
178
|
+
}
|
|
179
|
+
const projectJsonPath = joinPathFragments(options.workspaceRoot.dir, options.projectRoot, "project.json");
|
|
180
|
+
if (!await hfs.isFile(projectJsonPath)) {
|
|
181
|
+
throw new Error("Cannot find project.json configuration");
|
|
182
|
+
}
|
|
183
|
+
if (!options.projectConfigurations?.projects?.[options.projectName]) {
|
|
184
|
+
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.");
|
|
185
|
+
}
|
|
186
|
+
const packageJsonPath = joinPathFragments(options.projectRoot, "project.json");
|
|
187
|
+
if (!await hfs.isFile(packageJsonPath)) {
|
|
188
|
+
throw new Error("Cannot find package.json configuration");
|
|
189
|
+
}
|
|
190
|
+
const packageJson = await hfs.json(joinPathFragments(options.workspaceRoot.dir, options.projectRoot, "package.json"));
|
|
191
|
+
const projectDependencies = calculateProjectBuildableDependencies(void 0, options.projectGraph, options.workspaceRoot.dir, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
192
|
+
const localPackages = projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== options.projectRoot && dep.node.data.root !== options.workspaceRoot.dir).reduce((ret, project) => {
|
|
193
|
+
const projectNode = project.node;
|
|
194
|
+
if (projectNode.data.root) {
|
|
195
|
+
const projectPackageJsonPath = joinPathFragments(options.workspaceRoot.dir, projectNode.data.root, "package.json");
|
|
196
|
+
if (existsSync(projectPackageJsonPath)) {
|
|
197
|
+
const projectPackageJson = readJsonFile(projectPackageJsonPath);
|
|
198
|
+
if (projectPackageJson.private !== false) {
|
|
199
|
+
ret.push(projectPackageJson);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return ret;
|
|
204
|
+
}, []);
|
|
205
|
+
if (localPackages.length > 0) {
|
|
206
|
+
writeLog("trace", `\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`);
|
|
207
|
+
packageJson.peerDependencies = localPackages.reduce((ret, localPackage) => {
|
|
208
|
+
if (!ret[localPackage.name]) {
|
|
209
|
+
ret[localPackage.name] = `>=${localPackage.version || "0.0.1"}`;
|
|
210
|
+
}
|
|
211
|
+
return ret;
|
|
212
|
+
}, packageJson.peerDependencies ?? {});
|
|
213
|
+
packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
|
|
214
|
+
if (!ret[localPackage.name]) {
|
|
215
|
+
ret[localPackage.name] = {
|
|
216
|
+
optional: false
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
return ret;
|
|
220
|
+
}, packageJson.peerDependenciesMeta ?? {});
|
|
221
|
+
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
222
|
+
if (!ret[localPackage.name]) {
|
|
223
|
+
ret[localPackage.name] = localPackage.version || "0.0.1";
|
|
224
|
+
}
|
|
225
|
+
return ret;
|
|
226
|
+
}, packageJson.peerDependencies ?? {});
|
|
227
|
+
} else {
|
|
228
|
+
writeLog("trace", "\u{1F4E6} No local packages dependencies to add to package.json");
|
|
229
|
+
}
|
|
230
|
+
packageJson.main = "./dist/index.cjs";
|
|
231
|
+
packageJson.module = "./dist/index.mjs";
|
|
232
|
+
packageJson.types = "./dist/index.d.ts";
|
|
233
|
+
await writeJsonFile(joinPathFragments(options.outdir, "package.json"), packageJson);
|
|
234
|
+
return options;
|
|
235
|
+
}, "generatePackageJson");
|
|
236
|
+
async function createOptions(options) {
|
|
237
|
+
return flatten(await Promise.all(map(options, (options2) => [
|
|
238
|
+
// we defer it so that we don't trigger glob immediately
|
|
239
|
+
() => resolveOptions(options2)
|
|
240
|
+
])));
|
|
241
|
+
}
|
|
242
|
+
__name(createOptions, "createOptions");
|
|
243
|
+
async function computeOptions(options) {
|
|
244
|
+
return options();
|
|
245
|
+
}
|
|
246
|
+
__name(computeOptions, "computeOptions");
|
|
247
|
+
async function executeEsBuild(options) {
|
|
248
|
+
if (process.env.WATCH === "true") {
|
|
249
|
+
const context2 = await esbuild.context(omit(options, [
|
|
250
|
+
"name",
|
|
251
|
+
"emitTypes",
|
|
252
|
+
"emitMetafile"
|
|
253
|
+
]));
|
|
254
|
+
watch(context2, options);
|
|
255
|
+
}
|
|
256
|
+
const build3 = await esbuild.build(omit(options, [
|
|
257
|
+
"name",
|
|
258
|
+
"emitTypes",
|
|
259
|
+
"emitMetafile"
|
|
260
|
+
]));
|
|
261
|
+
if (build3.metafile && options.emitMetafile) {
|
|
262
|
+
const metafilePath = `${options.outdir}/${options.name}.meta.json`;
|
|
263
|
+
await hfs.write(metafilePath, JSON.stringify(build3.metafile));
|
|
264
|
+
}
|
|
265
|
+
return [
|
|
266
|
+
options,
|
|
267
|
+
build3
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
__name(executeEsBuild, "executeEsBuild");
|
|
271
|
+
async function dependencyCheck(options) {
|
|
272
|
+
if (process.env.DEV === "true") return void 0;
|
|
273
|
+
if (process.env.CI && !process.env.BUILDKITE) return void 0;
|
|
274
|
+
const buildPromise = esbuild.build({
|
|
275
|
+
entryPoints: globbySync("**/*.{j,t}s", {
|
|
276
|
+
// We don't check dependencies in ecosystem tests because tests are isolated from the build.
|
|
277
|
+
ignore: [
|
|
278
|
+
"./src/__tests__/**/*",
|
|
279
|
+
"./tests/e2e/**/*",
|
|
280
|
+
"./dist/**/*"
|
|
281
|
+
],
|
|
282
|
+
gitignore: true
|
|
283
|
+
}),
|
|
284
|
+
logLevel: "silent",
|
|
285
|
+
bundle: true,
|
|
286
|
+
write: false,
|
|
287
|
+
outdir: "out",
|
|
288
|
+
plugins: [
|
|
289
|
+
depsCheckPlugin(options.bundle)
|
|
290
|
+
]
|
|
291
|
+
});
|
|
292
|
+
await buildPromise.catch(() => {
|
|
293
|
+
});
|
|
294
|
+
return void 0;
|
|
295
|
+
}
|
|
296
|
+
__name(dependencyCheck, "dependencyCheck");
|
|
297
|
+
async function build2(options) {
|
|
298
|
+
void transduce.async(options, dependencyCheck);
|
|
299
|
+
return transduce.async(await createOptions(options), pipe.async(computeOptions, generatePackageJson, executeEsBuild));
|
|
300
|
+
}
|
|
301
|
+
__name(build2, "build");
|
|
302
|
+
var watch = /* @__PURE__ */ __name((context2, options) => {
|
|
303
|
+
if (process.env.WATCH !== "true") return context2;
|
|
304
|
+
const config = {
|
|
305
|
+
ignoreInitial: true,
|
|
306
|
+
useFsEvents: true,
|
|
307
|
+
ignored: [
|
|
308
|
+
"./src/__tests__/**/*",
|
|
309
|
+
"./package.json"
|
|
310
|
+
]
|
|
311
|
+
};
|
|
312
|
+
const changeWatcher = createWatcher([
|
|
313
|
+
"./src/**/*"
|
|
314
|
+
], config);
|
|
315
|
+
const fastRebuild = debounce(async () => {
|
|
316
|
+
const timeBefore = Date.now();
|
|
317
|
+
const rebuildResult = await handle.async(() => {
|
|
318
|
+
return context2.rebuild();
|
|
319
|
+
});
|
|
320
|
+
if (rebuildResult instanceof Error) {
|
|
321
|
+
writeLog("error", rebuildResult.message);
|
|
322
|
+
}
|
|
323
|
+
writeLog("log", `${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
|
|
324
|
+
}, 10);
|
|
325
|
+
changeWatcher.on("change", fastRebuild);
|
|
326
|
+
return void 0;
|
|
327
|
+
}, "watch");
|
|
328
|
+
|
|
329
|
+
export {
|
|
330
|
+
handle,
|
|
331
|
+
skip,
|
|
332
|
+
Filter,
|
|
333
|
+
Mapper,
|
|
334
|
+
transduce,
|
|
335
|
+
pipe,
|
|
336
|
+
build2 as build
|
|
337
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
4
|
+
|
|
5
|
+
// src/utilities/log.ts
|
|
6
|
+
import { consola } from "consola";
|
|
7
|
+
function writeLog(type, ...args) {
|
|
8
|
+
consola[type]("[Storm]", ...args);
|
|
9
|
+
}
|
|
10
|
+
__name(writeLog, "writeLog");
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
writeLog
|
|
14
|
+
};
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkNVGEXPTGcjs = require('./chunk-NVGEXPTG.cjs');
|
|
5
|
+
require('./chunk-BGYQAVKQ.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.DEFAULT_BUILD_OPTIONS = _chunkNVGEXPTGcjs.DEFAULT_BUILD_OPTIONS; exports.adapterConfig = _chunkNVGEXPTGcjs.adapterConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ESBuildOptions } from './types.cjs';
|
|
2
|
+
import '@nx/devkit';
|
|
3
|
+
import 'esbuild';
|
|
4
|
+
import 'nx/src/utils/find-workspace-root';
|
|
5
|
+
|
|
6
|
+
declare const DEFAULT_BUILD_OPTIONS: {
|
|
7
|
+
readonly platform: "node";
|
|
8
|
+
readonly target: "ES2021";
|
|
9
|
+
readonly logLevel: "error";
|
|
10
|
+
readonly tsconfig: "tsconfig.json";
|
|
11
|
+
readonly metafile: true;
|
|
12
|
+
};
|
|
13
|
+
declare const adapterConfig: Omit<ESBuildOptions, "projectRoot">[];
|
|
14
|
+
|
|
15
|
+
export { DEFAULT_BUILD_OPTIONS, adapterConfig };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ESBuildOptions } from './types.js';
|
|
2
|
+
import '@nx/devkit';
|
|
3
|
+
import 'esbuild';
|
|
4
|
+
import 'nx/src/utils/find-workspace-root';
|
|
5
|
+
|
|
6
|
+
declare const DEFAULT_BUILD_OPTIONS: {
|
|
7
|
+
readonly platform: "node";
|
|
8
|
+
readonly target: "ES2021";
|
|
9
|
+
readonly logLevel: "error";
|
|
10
|
+
readonly tsconfig: "tsconfig.json";
|
|
11
|
+
readonly metafile: true;
|
|
12
|
+
};
|
|
13
|
+
declare const adapterConfig: Omit<ESBuildOptions, "projectRoot">[];
|
|
14
|
+
|
|
15
|
+
export { DEFAULT_BUILD_OPTIONS, adapterConfig };
|
package/dist/config.js
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5S2XTAF2cjs = require('./chunk-5S2XTAF2.cjs');
|
|
10
|
+
require('./chunk-DCWECOOS.cjs');
|
|
11
|
+
require('./chunk-WLHWKRZB.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkA6CGWMV7cjs = require('./chunk-A6CGWMV7.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkNVGEXPTGcjs = require('./chunk-NVGEXPTG.cjs');
|
|
19
|
+
require('./chunk-SFZRYJZ2.cjs');
|
|
20
|
+
require('./chunk-MTKAAECG.cjs');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkRJQ3LCGJcjs = require('./chunk-RJQ3LCGJ.cjs');
|
|
24
|
+
require('./chunk-3C3PXJUM.cjs');
|
|
25
|
+
require('./chunk-BGYQAVKQ.cjs');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
exports.DEFAULT_BUILD_OPTIONS = _chunkNVGEXPTGcjs.DEFAULT_BUILD_OPTIONS; exports.Filter = _chunk5S2XTAF2cjs.Filter; exports.Mapper = _chunk5S2XTAF2cjs.Mapper; exports.adapterConfig = _chunkNVGEXPTGcjs.adapterConfig; exports.build = _chunk5S2XTAF2cjs.build; exports.handle = _chunk5S2XTAF2cjs.handle; exports.pipe = _chunk5S2XTAF2cjs.pipe; exports.run = _chunkA6CGWMV7cjs.run; exports.skip = _chunk5S2XTAF2cjs.skip; exports.transduce = _chunk5S2XTAF2cjs.transduce; exports.writeLog = _chunkRJQ3LCGJcjs.writeLog;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
export { build } from './build.cjs';
|
|
2
|
+
export { DEFAULT_BUILD_OPTIONS, adapterConfig } from './config.cjs';
|
|
3
|
+
export { ESBuildOptions, ESBuildResolvedOptions, ESBuildResult } from './types.cjs';
|
|
4
|
+
import { LogType } from 'consola';
|
|
5
|
+
import * as execa from 'execa';
|
|
6
|
+
import 'esbuild';
|
|
7
|
+
import '@nx/devkit';
|
|
8
|
+
import 'nx/src/utils/find-workspace-root';
|
|
9
|
+
|
|
10
|
+
declare function handleSync<R, E = Error>(fn: () => R): R | E;
|
|
11
|
+
declare function handleAsync<R, E = Error>(fn: () => Promise<R> | R): Promise<R | E>;
|
|
12
|
+
/**
|
|
13
|
+
* Executes a function, catches exceptions, and returns any outcome.
|
|
14
|
+
* @param fn - to be executed
|
|
15
|
+
*/
|
|
16
|
+
declare const handle: typeof handleSync & {
|
|
17
|
+
async: typeof handleAsync;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare const skip: unique symbol;
|
|
21
|
+
type SyncTransformer<I, R> = (item: I, key: number) => R | typeof skip;
|
|
22
|
+
type ASyncTransformer<I, R> = (item: I, key: number) => Promise<R | typeof skip>;
|
|
23
|
+
declare function transduceSync<I, R>(list: Array<I>, transformer: SyncTransformer<I, R>): R[];
|
|
24
|
+
declare function transduceAsync<I, R>(list: Array<I>, transformer: ASyncTransformer<I, R>): Promise<R[]>;
|
|
25
|
+
declare const Filter: <I>(filter: (item: I) => boolean) => (item: I) => I;
|
|
26
|
+
declare const Mapper: <I, R>(mapper: (item: I) => R) => (item: I) => R;
|
|
27
|
+
/**
|
|
28
|
+
* Transducers enable efficient data processing. They allow the composition of
|
|
29
|
+
* mappers and filters to be applied on a list. And this is applied in a single
|
|
30
|
+
* pass, that's the efficient pipeline processing.
|
|
31
|
+
*
|
|
32
|
+
* (does not reduce at the same time)
|
|
33
|
+
*
|
|
34
|
+
* @see https://medium.com/javascript-scene/7985330fe73d
|
|
35
|
+
*
|
|
36
|
+
* @param list - to transform
|
|
37
|
+
* @param transformer - to apply
|
|
38
|
+
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const filterEven = Filter(<U>(unit: U) =>
|
|
42
|
+
* typeof unit === 'number' ? !(unit % 2) : true,
|
|
43
|
+
* )
|
|
44
|
+
* const mapTimes2 = Mapper(<U>(unit: U) =>
|
|
45
|
+
* typeof unit === 'number' ? unit * 2 : unit,
|
|
46
|
+
* )
|
|
47
|
+
* const mapString = Mapper(<U>(unit: U) => `${unit}`)
|
|
48
|
+
*
|
|
49
|
+
* const test0 = transduce(
|
|
50
|
+
* [1, 2, 3, 4, 5, 6, 7, 'a'],
|
|
51
|
+
* pipe(filterEven, mapTimes2, mapTimes2, mapString, filterEven),
|
|
52
|
+
* )
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare const transduce: typeof transduceSync & {
|
|
56
|
+
async: typeof transduceAsync;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type FunctionLike<P extends Array<any> = any, R = any> = (...args: P) => R;
|
|
60
|
+
type Await<P> = P extends Promise<infer A> ? A : P;
|
|
61
|
+
/**
|
|
62
|
+
* Pipe the input and output of functions.
|
|
63
|
+
*
|
|
64
|
+
* @param fn - parameter-taking function
|
|
65
|
+
* @param fns - subsequent piped functions
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
declare const pipe: PipeMultiSync & {
|
|
69
|
+
async: PipeMultiAsync;
|
|
70
|
+
};
|
|
71
|
+
declare type PipeMultiSync = {
|
|
72
|
+
<R0, P extends any[]>(...fns: [FunctionLike<P, R0>]): FunctionLike<P, R0>;
|
|
73
|
+
<R0, R1, P extends any[]>(...fns: [FunctionLike<P, R0>, FunctionLike<[R0], R1>]): FunctionLike<P, R1>;
|
|
74
|
+
<R0, R1, R2, P extends any[]>(...fns: [
|
|
75
|
+
FunctionLike<P, R0>,
|
|
76
|
+
FunctionLike<[R0], R1>,
|
|
77
|
+
FunctionLike<[R1], R2>
|
|
78
|
+
]): FunctionLike<P, R2>;
|
|
79
|
+
<R0, R1, R2, R3, P extends any[]>(...fns: [
|
|
80
|
+
FunctionLike<P, R0>,
|
|
81
|
+
FunctionLike<[R0], R1>,
|
|
82
|
+
FunctionLike<[R1], R2>,
|
|
83
|
+
FunctionLike<[R2], R3>
|
|
84
|
+
]): FunctionLike<P, R3>;
|
|
85
|
+
<R0, R1, R2, R3, R4, P extends any[]>(...fns: [
|
|
86
|
+
FunctionLike<P, R0>,
|
|
87
|
+
FunctionLike<[R0], R1>,
|
|
88
|
+
FunctionLike<[R1], R2>,
|
|
89
|
+
FunctionLike<[R2], R3>,
|
|
90
|
+
FunctionLike<[R3], R4>
|
|
91
|
+
]): FunctionLike<P, R4>;
|
|
92
|
+
<R0, R1, R2, R3, R4, R5, P extends any[]>(...fns: [
|
|
93
|
+
FunctionLike<P, R0>,
|
|
94
|
+
FunctionLike<[R0], R1>,
|
|
95
|
+
FunctionLike<[R1], R2>,
|
|
96
|
+
FunctionLike<[R2], R3>,
|
|
97
|
+
FunctionLike<[R3], R4>,
|
|
98
|
+
FunctionLike<[R4], R5>
|
|
99
|
+
]): FunctionLike<P, R5>;
|
|
100
|
+
<R0, R1, R2, R3, R4, R5, R6, P extends any[]>(...fns: [
|
|
101
|
+
FunctionLike<P, R0>,
|
|
102
|
+
FunctionLike<[R0], R1>,
|
|
103
|
+
FunctionLike<[R1], R2>,
|
|
104
|
+
FunctionLike<[R2], R3>,
|
|
105
|
+
FunctionLike<[R3], R4>,
|
|
106
|
+
FunctionLike<[R4], R5>,
|
|
107
|
+
FunctionLike<[R5], R6>
|
|
108
|
+
]): FunctionLike<P, R6>;
|
|
109
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(...fns: [
|
|
110
|
+
FunctionLike<P, R0>,
|
|
111
|
+
FunctionLike<[R0], R1>,
|
|
112
|
+
FunctionLike<[R1], R2>,
|
|
113
|
+
FunctionLike<[R2], R3>,
|
|
114
|
+
FunctionLike<[R3], R4>,
|
|
115
|
+
FunctionLike<[R4], R5>,
|
|
116
|
+
FunctionLike<[R5], R6>,
|
|
117
|
+
FunctionLike<[R6], R7>
|
|
118
|
+
]): FunctionLike<P, R7>;
|
|
119
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(...fns: [
|
|
120
|
+
FunctionLike<P, R0>,
|
|
121
|
+
FunctionLike<[R0], R1>,
|
|
122
|
+
FunctionLike<[R1], R2>,
|
|
123
|
+
FunctionLike<[R2], R3>,
|
|
124
|
+
FunctionLike<[R3], R4>,
|
|
125
|
+
FunctionLike<[R4], R5>,
|
|
126
|
+
FunctionLike<[R5], R6>,
|
|
127
|
+
FunctionLike<[R6], R7>,
|
|
128
|
+
FunctionLike<[R7], R8>
|
|
129
|
+
]): FunctionLike<P, R8>;
|
|
130
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(...fns: [
|
|
131
|
+
FunctionLike<P, R0>,
|
|
132
|
+
FunctionLike<[R0], R1>,
|
|
133
|
+
FunctionLike<[R1], R2>,
|
|
134
|
+
FunctionLike<[R2], R3>,
|
|
135
|
+
FunctionLike<[R3], R4>,
|
|
136
|
+
FunctionLike<[R4], R5>,
|
|
137
|
+
FunctionLike<[R5], R6>,
|
|
138
|
+
FunctionLike<[R6], R7>,
|
|
139
|
+
FunctionLike<[R7], R8>,
|
|
140
|
+
FunctionLike<[R8], R9>
|
|
141
|
+
]): FunctionLike<P, R9>;
|
|
142
|
+
};
|
|
143
|
+
declare type PipeMultiAsync = {
|
|
144
|
+
<R0, P extends any[]>(...fns: [FunctionLike<P, R0>]): FunctionLike<P, Promise<Await<R0>>>;
|
|
145
|
+
<R0, R1, P extends any[]>(...fns: [FunctionLike<P, R0>, FunctionLike<[Await<R0>], R1>]): FunctionLike<P, Promise<Await<R1>>>;
|
|
146
|
+
<R0, R1, R2, P extends any[]>(...fns: [
|
|
147
|
+
FunctionLike<P, R0>,
|
|
148
|
+
FunctionLike<[Await<R0>], R1>,
|
|
149
|
+
FunctionLike<[Await<R1>], R2>
|
|
150
|
+
]): FunctionLike<P, Promise<Await<R2>>>;
|
|
151
|
+
<R0, R1, R2, R3, P extends any[]>(...fns: [
|
|
152
|
+
FunctionLike<P, R0>,
|
|
153
|
+
FunctionLike<[Await<R0>], R1>,
|
|
154
|
+
FunctionLike<[Await<R1>], R2>,
|
|
155
|
+
FunctionLike<[Await<R2>], R3>
|
|
156
|
+
]): FunctionLike<P, Promise<Await<R3>>>;
|
|
157
|
+
<R0, R1, R2, R3, R4, P extends any[]>(...fns: [
|
|
158
|
+
FunctionLike<P, R0>,
|
|
159
|
+
FunctionLike<[Await<R0>], R1>,
|
|
160
|
+
FunctionLike<[Await<R1>], R2>,
|
|
161
|
+
FunctionLike<[Await<R2>], R3>,
|
|
162
|
+
FunctionLike<[Await<R3>], R4>
|
|
163
|
+
]): FunctionLike<P, Promise<Await<R4>>>;
|
|
164
|
+
<R0, R1, R2, R3, R4, R5, P extends any[]>(...fns: [
|
|
165
|
+
FunctionLike<P, R0>,
|
|
166
|
+
FunctionLike<[Await<R0>], R1>,
|
|
167
|
+
FunctionLike<[Await<R1>], R2>,
|
|
168
|
+
FunctionLike<[Await<R2>], R3>,
|
|
169
|
+
FunctionLike<[Await<R3>], R4>,
|
|
170
|
+
FunctionLike<[Await<R4>], R5>
|
|
171
|
+
]): FunctionLike<P, Promise<Await<R5>>>;
|
|
172
|
+
<R0, R1, R2, R3, R4, R5, R6, P extends any[]>(...fns: [
|
|
173
|
+
FunctionLike<P, R0>,
|
|
174
|
+
FunctionLike<[Await<R0>], R1>,
|
|
175
|
+
FunctionLike<[Await<R1>], R2>,
|
|
176
|
+
FunctionLike<[Await<R2>], R3>,
|
|
177
|
+
FunctionLike<[Await<R3>], R4>,
|
|
178
|
+
FunctionLike<[Await<R4>], R5>,
|
|
179
|
+
FunctionLike<[Await<R5>], R6>
|
|
180
|
+
]): FunctionLike<P, Promise<Await<R6>>>;
|
|
181
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(...fns: [
|
|
182
|
+
FunctionLike<P, R0>,
|
|
183
|
+
FunctionLike<[Await<R0>], R1>,
|
|
184
|
+
FunctionLike<[Await<R1>], R2>,
|
|
185
|
+
FunctionLike<[Await<R2>], R3>,
|
|
186
|
+
FunctionLike<[Await<R3>], R4>,
|
|
187
|
+
FunctionLike<[Await<R4>], R5>,
|
|
188
|
+
FunctionLike<[Await<R5>], R6>,
|
|
189
|
+
FunctionLike<[Await<R6>], R7>
|
|
190
|
+
]): FunctionLike<P, Promise<Await<R7>>>;
|
|
191
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(...fns: [
|
|
192
|
+
FunctionLike<P, R0>,
|
|
193
|
+
FunctionLike<[Await<R0>], R1>,
|
|
194
|
+
FunctionLike<[Await<R1>], R2>,
|
|
195
|
+
FunctionLike<[Await<R2>], R3>,
|
|
196
|
+
FunctionLike<[Await<R3>], R4>,
|
|
197
|
+
FunctionLike<[Await<R4>], R5>,
|
|
198
|
+
FunctionLike<[Await<R5>], R6>,
|
|
199
|
+
FunctionLike<[Await<R6>], R7>,
|
|
200
|
+
FunctionLike<[Await<R7>], R8>
|
|
201
|
+
]): FunctionLike<P, Promise<Await<R8>>>;
|
|
202
|
+
<R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(...fns: [
|
|
203
|
+
FunctionLike<P, R0>,
|
|
204
|
+
FunctionLike<[Await<R0>], R1>,
|
|
205
|
+
FunctionLike<[Await<R1>], R2>,
|
|
206
|
+
FunctionLike<[Await<R2>], R3>,
|
|
207
|
+
FunctionLike<[Await<R3>], R4>,
|
|
208
|
+
FunctionLike<[Await<R4>], R5>,
|
|
209
|
+
FunctionLike<[Await<R5>], R6>,
|
|
210
|
+
FunctionLike<[Await<R6>], R7>,
|
|
211
|
+
FunctionLike<[Await<R7>], R8>,
|
|
212
|
+
FunctionLike<[Await<R8>], R9>
|
|
213
|
+
]): FunctionLike<P, Promise<Await<R9>>>;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Writes a log message to the console.
|
|
218
|
+
*
|
|
219
|
+
* @param type - The type of log message.
|
|
220
|
+
* @param args - The arguments to log.
|
|
221
|
+
*/
|
|
222
|
+
declare function writeLog(type: LogType, ...args: string[]): void;
|
|
223
|
+
|
|
224
|
+
declare function run(command: string): execa.ResultPromise<{
|
|
225
|
+
preferLocal: true;
|
|
226
|
+
shell: true;
|
|
227
|
+
stdio: "inherit";
|
|
228
|
+
}>;
|
|
229
|
+
|
|
230
|
+
export { Filter, Mapper, type PipeMultiAsync, type PipeMultiSync, handle, pipe, run, skip, transduce, writeLog };
|