@aziontech/bundler 1.0.0 → 1.1.1
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 +42 -42
- package/dist/{index-D5_BuqHI.js → index-B5d6nLzb.js} +100 -97
- package/dist/index.js +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -360,49 +360,49 @@ E2E tests run daily in the [Bundler Examples](https://github.com/aziontech/bundl
|
|
|
360
360
|
Table:
|
|
361
361
|
| Test | Status |
|
|
362
362
|
| ------------------------------------ | ------ |
|
|
363
|
-
| Next 14 2 15 Middleware |
|
|
364
|
-
| Next 13 5 6 I18n |
|
|
365
|
-
| Next 12 3 4 I18n |
|
|
366
|
-
| Hexo Static |
|
|
367
|
-
| Next 13 5 6 Middleware |
|
|
368
|
-
| Next 12 3 4 Middleware |
|
|
369
|
-
| Next Node Pages 12 3 1 |
|
|
370
|
-
| Next 13 5 6 Config |
|
|
371
|
-
| Next 12 3 4 Config |
|
|
372
|
-
| Html |
|
|
373
|
-
| Next Static |
|
|
374
|
-
| Gatsby Static |
|
|
375
|
-
| Next Node Pages 12 3 1 Fs |
|
|
376
|
-
| Sveltekit Static |
|
|
377
|
-
| Vue Vite Static |
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
|
|
|
381
|
-
|
|
|
382
|
-
|
|
|
383
|
-
|
|
|
384
|
-
|
|
|
385
|
-
|
|
|
386
|
-
| Simple Js Network List |
|
|
387
|
-
| Angular Static |
|
|
388
|
-
| React Static |
|
|
389
|
-
| Svelte Static |
|
|
363
|
+
| Next 14 2 15 Middleware | ✅ |
|
|
364
|
+
| Next 13 5 6 I18n | ✅ |
|
|
365
|
+
| Next 12 3 4 I18n | ✅ |
|
|
366
|
+
| Hexo Static | ✅ |
|
|
367
|
+
| Next 13 5 6 Middleware | ✅ |
|
|
368
|
+
| Next 12 3 4 Middleware | ✅ |
|
|
369
|
+
| Next Node Pages 12 3 1 | ✅ |
|
|
370
|
+
| Next 13 5 6 Config | ✅ |
|
|
371
|
+
| Next 12 3 4 Config | ✅ |
|
|
372
|
+
| Html | ✅ |
|
|
373
|
+
| Next Static | ✅ |
|
|
374
|
+
| Gatsby Static | ✅ |
|
|
375
|
+
| Next Node Pages 12 3 1 Fs | ✅ |
|
|
376
|
+
| Sveltekit Static | ✅ |
|
|
377
|
+
| Vue Vite Static | ✅ |
|
|
378
|
+
| Qwik Static | ✅ |
|
|
379
|
+
| Opennext Ssr | ✅ |
|
|
380
|
+
| Sveltekit Ssr | ✅ |
|
|
381
|
+
| Next 12 Static | ✅ |
|
|
382
|
+
| Hugo | ✅ |
|
|
383
|
+
| Astro Static | ✅ |
|
|
384
|
+
| Simple Js Env Vars | ✅ |
|
|
385
|
+
| Eleventy Static | ✅ |
|
|
386
|
+
| Simple Js Network List | ✅ |
|
|
387
|
+
| Angular Static | ✅ |
|
|
388
|
+
| React Static | ✅ |
|
|
389
|
+
| Svelte Static | ✅ |
|
|
390
390
|
| Stencil Static | ⚠️ |
|
|
391
|
-
| Vitepress Static |
|
|
392
|
-
| Preact Static |
|
|
393
|
-
| Vuepress Static |
|
|
394
|
-
| Nuxt Static |
|
|
395
|
-
| Docusaurus Static |
|
|
396
|
-
| Simple Js Firewall Event |
|
|
397
|
-
| Nuxt Ssr |
|
|
398
|
-
| Simple Js Network List With Firewall |
|
|
399
|
-
| Jekyll Static |
|
|
400
|
-
| Simple Js Esm Worker |
|
|
401
|
-
| Simple Js Esm Node |
|
|
402
|
-
| Simple
|
|
403
|
-
| Simple
|
|
404
|
-
|
|
405
|
-
Last test run date:
|
|
391
|
+
| Vitepress Static | ✅ |
|
|
392
|
+
| Preact Static | ✅ |
|
|
393
|
+
| Vuepress Static | ✅ |
|
|
394
|
+
| Nuxt Static | ✅ |
|
|
395
|
+
| Docusaurus Static | ✅ |
|
|
396
|
+
| Simple Js Firewall Event | ✅ |
|
|
397
|
+
| Nuxt Ssr | ✅ |
|
|
398
|
+
| Simple Js Network List With Firewall | ✅ |
|
|
399
|
+
| Jekyll Static | ✅ |
|
|
400
|
+
| Simple Js Esm Worker | ✅ |
|
|
401
|
+
| Simple Js Esm Node | ✅ |
|
|
402
|
+
| Simple Js Esm | ✅ |
|
|
403
|
+
| Simple Ts Esm | ✅ |
|
|
404
|
+
|
|
405
|
+
Last test run date: 06/25/26 04:21:48 AM
|
|
406
406
|
|
|
407
407
|
## Contributing
|
|
408
408
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { fetchContext as
|
|
1
|
+
import { fetchContext as Re, FirewallEventContext as Ue, FetchEventContext as Ne, AsyncHooksContext as ue, StorageContext as Ie, EnvVarsContext as Be, NetworkListContext as De, fsContext as We, streamContext as Me, cryptoContext as Le, promisesContext as He, KVContext as Ve } from "@aziontech/builder/polyfills";
|
|
2
2
|
import { load as ze } from "@edge-runtime/primitives/dist/load.js";
|
|
3
|
-
import { d as g, D as
|
|
3
|
+
import { d as g, D as _, S as de, B as k, a as O, m as Ge, e as qe, c as Ke, b as R, T as U, r as se, w as ee, f as Te, g as Je, h as Se } from "./utils-DkUMNTN3.js";
|
|
4
4
|
import * as A from "@aziontech/utils/node";
|
|
5
5
|
import { getPackageManager as Xe, feedback as p } from "@aziontech/utils/node";
|
|
6
6
|
import Ye from "chokidar";
|
|
7
7
|
import { runPhaseWithTelemetry as x, TelemetryCollector as Ze, formatHeader as Qe, formatBuildConfig as et } from "@aziontech/bundler-telemetry";
|
|
8
8
|
import { validateConfig as te, processConfig as tt, convertJsonConfigToObject as rt } from "@aziontech/config";
|
|
9
|
-
import h, { rm as oe, mkdir as
|
|
10
|
-
import S, { resolve as ie, join as C, basename as re, extname as q, dirname as
|
|
9
|
+
import h, { rm as oe, mkdir as $e, readFile as nt, stat as st, writeFile as ot } from "fs/promises";
|
|
10
|
+
import S, { resolve as ie, join as C, basename as re, extname as q, dirname as Pe, relative as it } from "path";
|
|
11
11
|
import J from "os";
|
|
12
12
|
import { executeESBuildBuild as at, executeWebpackBuild as ct, createAzionWebpackConfig as lt, createAzionESBuildConfig as ft } from "@aziontech/builder";
|
|
13
13
|
import ut from "lodash";
|
|
@@ -17,9 +17,9 @@ import I from "node:vm";
|
|
|
17
17
|
import pt from "net";
|
|
18
18
|
import { runServer as mt } from "edge-runtime";
|
|
19
19
|
import * as K from "@aziontech/presets";
|
|
20
|
-
import
|
|
20
|
+
import pe, { promises as H, existsSync as ht } from "fs";
|
|
21
21
|
import { listFrameworks as gt } from "@netlify/framework-info";
|
|
22
|
-
import * as
|
|
22
|
+
import * as xe from "prettier";
|
|
23
23
|
import { cosmiconfig as yt } from "cosmiconfig";
|
|
24
24
|
import { TypeScriptLoader as X } from "cosmiconfig-typescript-loader";
|
|
25
25
|
class wt {
|
|
@@ -65,7 +65,7 @@ class bt extends wt {
|
|
|
65
65
|
constructor(t) {
|
|
66
66
|
super({
|
|
67
67
|
...t,
|
|
68
|
-
extend: (r) => t?.extend ? t.extend(
|
|
68
|
+
extend: (r) => t?.extend ? t.extend(me(r)) : me(r)
|
|
69
69
|
}), Object.defineProperty(this.context, "__onUnhandledRejectionHandlers", {
|
|
70
70
|
set: vt,
|
|
71
71
|
configurable: !1,
|
|
@@ -83,12 +83,12 @@ class bt extends wt {
|
|
|
83
83
|
configurable: !1,
|
|
84
84
|
enumerable: !1
|
|
85
85
|
}), this.evaluate(St()), this.dispatchFetch = this.evaluate($t());
|
|
86
|
-
for (const r of
|
|
86
|
+
for (const r of ke)
|
|
87
87
|
Et(r, this.context);
|
|
88
88
|
t?.initialCode && this.evaluate(t.initialCode);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const ke = [
|
|
92
92
|
"Object",
|
|
93
93
|
"Array",
|
|
94
94
|
"RegExp",
|
|
@@ -214,7 +214,7 @@ function $t() {
|
|
|
214
214
|
.catch(error => getResponse({ error }))
|
|
215
215
|
})`;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function me(e) {
|
|
218
218
|
F(e, "self", { enumerable: !0, value: e }), F(e, "globalThis", { value: e }), F(e, "Symbol", { value: Symbol }), F(e, "clearInterval", { value: clearInterval }), F(e, "clearTimeout", { value: clearTimeout }), F(e, "queueMicrotask", { value: queueMicrotask }), F(e, "EdgeRuntime", { value: "edge-runtime" });
|
|
219
219
|
const t = xt(e);
|
|
220
220
|
return Pt(e, {
|
|
@@ -301,22 +301,25 @@ function Pt(e, t) {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
function xt(e) {
|
|
304
|
-
const r = `({${
|
|
304
|
+
const r = `({${ke.join(",")}})`;
|
|
305
305
|
return ae(r, e);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const r =
|
|
309
|
-
|
|
307
|
+
function Ce(e, t = !1) {
|
|
308
|
+
const r = /switch \((\w+)\) \{\n(\s+)case Object:/g;
|
|
309
|
+
e = e.replace(r, (o, i, c) => `if (${i} != null && ${i} !== Object && ${i}.name === "Object") ${i} = Object;
|
|
310
|
+
${c}` + o);
|
|
311
|
+
const n = (o) => (o.RESERVED_FETCH = o.fetch.bind(o), o.fetch = async (i, c) => Re(
|
|
310
312
|
o,
|
|
311
313
|
i,
|
|
314
|
+
c,
|
|
312
315
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
316
|
globalThis?.AZION_BUCKET_NAME,
|
|
314
317
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
315
318
|
globalThis?.AZION_BUCKET_PREFIX
|
|
316
|
-
),
|
|
317
|
-
return new bt({ extend:
|
|
319
|
+
), o.FetchEvent = t ? Ue : Ne, o.Response = t ? Response : o.Response, o.eval = eval, o.process = { env: process.env }, o.File = void 0, o.WebSocket = void 0, o.ASYNC_LOCAL_STORAGE = ue, o.AsyncLocalStorage = ue.AsyncLocalStorage, o.STORAGE_CONTEXT = Ie, o.ENV_VARS_CONTEXT = Be, o.NETWORK_LIST_CONTEXT = De, o.FS_CONTEXT = We, o.STREAM_CONTEXT = Me, o.CRYPTO_CONTEXT = Le, o.TextDecoderStream = TextDecoderStream, o.TextEncoderStream = TextEncoderStream, o.perfomance = { now: performance.now }, o.CompressionStream = CompressionStream, o.CountQueuingStrategy = CountQueuingStrategy, o.DecompressionStream = DecompressionStream, o.Promise = Promise, o.Promise.withResolvers = He, o.KV_CONTEXT = Ve, o);
|
|
320
|
+
return new bt({ extend: n, initialCode: e, codeGeneration: { strings: !0 } });
|
|
318
321
|
}
|
|
319
|
-
class
|
|
322
|
+
class Fe extends Error {
|
|
320
323
|
constructor(t, r) {
|
|
321
324
|
super(t), this.code = r, this.name = "PackageJsonError";
|
|
322
325
|
}
|
|
@@ -333,7 +336,7 @@ const Ct = async () => {
|
|
|
333
336
|
const t = await nt(e, "utf8");
|
|
334
337
|
return JSON.parse(t);
|
|
335
338
|
} catch (t) {
|
|
336
|
-
throw new
|
|
339
|
+
throw new Fe("Failed to read package.json", t.code);
|
|
337
340
|
}
|
|
338
341
|
}, Ft = async () => {
|
|
339
342
|
const e = C(process.cwd(), "node_modules");
|
|
@@ -347,7 +350,7 @@ const Ct = async () => {
|
|
|
347
350
|
try {
|
|
348
351
|
e = await Ct();
|
|
349
352
|
} catch (t) {
|
|
350
|
-
if (t instanceof
|
|
353
|
+
if (t instanceof Fe && t.code === "ENOENT")
|
|
351
354
|
return;
|
|
352
355
|
throw t;
|
|
353
356
|
}
|
|
@@ -365,7 +368,7 @@ function B({
|
|
|
365
368
|
}) {
|
|
366
369
|
return ((i) => i === "true" ? !0 : i === "false" ? !1 : i)(e ?? t ?? r ?? n);
|
|
367
370
|
}
|
|
368
|
-
const
|
|
371
|
+
const Ot = async (e) => {
|
|
369
372
|
try {
|
|
370
373
|
await Promise.all(
|
|
371
374
|
e.map(async (t) => {
|
|
@@ -375,13 +378,13 @@ const _t = async (e) => {
|
|
|
375
378
|
if (r.code !== "ENOENT")
|
|
376
379
|
throw r;
|
|
377
380
|
}
|
|
378
|
-
await
|
|
381
|
+
await $e(t, { recursive: !0 });
|
|
379
382
|
})
|
|
380
383
|
);
|
|
381
384
|
} catch (t) {
|
|
382
385
|
throw new Error(`Failed to clean directories: ${t}`);
|
|
383
386
|
}
|
|
384
|
-
},
|
|
387
|
+
}, _t = (e) => `//---
|
|
385
388
|
//storages:
|
|
386
389
|
// - name: assets
|
|
387
390
|
// bucket: ${e.bucket}
|
|
@@ -395,7 +398,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, jt = async (e) => {
|
|
|
395
398
|
} catch {
|
|
396
399
|
return !1;
|
|
397
400
|
}
|
|
398
|
-
},
|
|
401
|
+
}, Rt = (e) => S.isAbsolute(e) ? e : S.resolve(process.cwd(), _.OUTPUT_BASE_PATH, e), Ut = (e, t) => t.find((r) => r.name === e), Nt = async (e, t, r) => {
|
|
399
402
|
if (!e.path) {
|
|
400
403
|
g.warn(`Function ${e.name} does not have a defined path`);
|
|
401
404
|
return;
|
|
@@ -405,7 +408,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, jt = async (e) => {
|
|
|
405
408
|
g.info(`Function ${e.name} does not have storage bindings`);
|
|
406
409
|
return;
|
|
407
410
|
}
|
|
408
|
-
const s =
|
|
411
|
+
const s = Rt(
|
|
409
412
|
e.path.replace(/\.js$/, r ? ".js" : ".dev.js")
|
|
410
413
|
);
|
|
411
414
|
if (!await jt(s)) {
|
|
@@ -418,7 +421,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, jt = async (e) => {
|
|
|
418
421
|
g.info(`Function ${e.name} already has injected bindings`);
|
|
419
422
|
return;
|
|
420
423
|
}
|
|
421
|
-
const i = String(n.bucket), c =
|
|
424
|
+
const i = String(n.bucket), c = Ut(i, t);
|
|
422
425
|
if (!c) {
|
|
423
426
|
g.warn(`Storage '${i}' not found for function ${e.name}`);
|
|
424
427
|
return;
|
|
@@ -427,7 +430,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, jt = async (e) => {
|
|
|
427
430
|
a || p.postbuild.info(
|
|
428
431
|
`No prefix provided for binding in function '${e.name}', using storage prefix: ${l}`
|
|
429
432
|
);
|
|
430
|
-
const f =
|
|
433
|
+
const f = _t({
|
|
431
434
|
bucket: i,
|
|
432
435
|
prefix: l
|
|
433
436
|
});
|
|
@@ -463,7 +466,7 @@ ${o}`;
|
|
|
463
466
|
bundler: s
|
|
464
467
|
}) => {
|
|
465
468
|
const o = Bt(), i = (c, a) => {
|
|
466
|
-
const l = re(c, q(c)), f =
|
|
469
|
+
const l = re(c, q(c)), f = Pe(c), u = `azion-${l}-${o}.temp.${t}`, m = ie(f, u), b = s === "webpack" ? ".js" : "", d = n ? "" : ".dev";
|
|
467
470
|
let y;
|
|
468
471
|
if (a) {
|
|
469
472
|
const T = a.replace(/\.[^/.]+$/, "");
|
|
@@ -486,7 +489,7 @@ ${o}`;
|
|
|
486
489
|
entry: i,
|
|
487
490
|
ext: t.metadata.ext ?? k.DEFAULT_OUTPUT_EXTENSION,
|
|
488
491
|
production: r,
|
|
489
|
-
bundler: e.build?.bundler ?? t.config.build?.bundler ??
|
|
492
|
+
bundler: e.build?.bundler ?? t.config.build?.bundler ?? de.DEFAULT
|
|
490
493
|
});
|
|
491
494
|
if (s ? n = await o(s) : t.config.build?.entry ? n = await o(t.config.build.entry) : t.handler && (n = await o(k.DEFAULT_HANDLER_FILENAME)), Object.keys(n).length === 0) {
|
|
492
495
|
const i = t.config.build?.entry ? `(default is "${t.config.build.entry}")` : "";
|
|
@@ -497,7 +500,7 @@ ${o}`;
|
|
|
497
500
|
return {
|
|
498
501
|
...e.build,
|
|
499
502
|
entry: n,
|
|
500
|
-
bundler: e.build?.bundler ?? t.config.build?.bundler ??
|
|
503
|
+
bundler: e.build?.bundler ?? t.config.build?.bundler ?? de.DEFAULT,
|
|
501
504
|
preset: t,
|
|
502
505
|
setup: {
|
|
503
506
|
contentToInject: void 0,
|
|
@@ -633,7 +636,7 @@ ${e}` : e, W = async (e, t, r, n, s, o) => !e || !t ? o() : x(
|
|
|
633
636
|
return s;
|
|
634
637
|
};
|
|
635
638
|
return ut.mergeWith({}, e, t, r);
|
|
636
|
-
}, Xt = { mergeConfigWithUserOverrides: Jt },
|
|
639
|
+
}, Xt = { mergeConfigWithUserOverrides: Jt }, he = async ({
|
|
637
640
|
config: e,
|
|
638
641
|
preset: t
|
|
639
642
|
}) => {
|
|
@@ -650,16 +653,16 @@ ${e}` : e, W = async (e, t, r, n, s, o) => !e || !t ? o() : x(
|
|
|
650
653
|
...!t.handler && e.build?.entry && {
|
|
651
654
|
entry: e.build?.entry
|
|
652
655
|
}
|
|
653
|
-
}), await
|
|
656
|
+
}), await be.readAzionConfig() || await be.writeUserConfig(n), n;
|
|
654
657
|
} catch (r) {
|
|
655
658
|
throw new Error(`Failed to set environment: ${r.message}`);
|
|
656
659
|
}
|
|
657
|
-
},
|
|
660
|
+
}, ge = (e) => e ? typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e) : [], Yt = async ({
|
|
658
661
|
entrypoint: e,
|
|
659
662
|
preset: t
|
|
660
663
|
}) => {
|
|
661
664
|
if (e && !t.handler) {
|
|
662
|
-
const r =
|
|
665
|
+
const r = ge(e), n = r.map((s) => S.resolve(s));
|
|
663
666
|
return await Promise.all(
|
|
664
667
|
n.map(async (s) => {
|
|
665
668
|
try {
|
|
@@ -691,7 +694,7 @@ ${e}` : e, W = async (e, t, r, n, s, o) => !e || !t ? o() : x(
|
|
|
691
694
|
return A.feedback.build.info(`Using built-in handler from "${t.metadata.name}" preset.`), [n];
|
|
692
695
|
}
|
|
693
696
|
if (t.config.build?.entry) {
|
|
694
|
-
const r =
|
|
697
|
+
const r = ge(t.config.build.entry), n = r.map((s) => S.resolve(s));
|
|
695
698
|
return await Promise.all(
|
|
696
699
|
n.map(async (s) => {
|
|
697
700
|
try {
|
|
@@ -787,7 +790,7 @@ ${e}` : e, W = async (e, t, r, n, s, o) => !e || !t ? o() : x(
|
|
|
787
790
|
e.memoryFS && M.copyFilesToLocalEdgeStorage({
|
|
788
791
|
dirs: e.memoryFS?.injectionDirs,
|
|
789
792
|
prefix: e.memoryFS?.removePathPrefix,
|
|
790
|
-
outputPath:
|
|
793
|
+
outputPath: _.OUTPUT_STORAGE_PATH
|
|
791
794
|
});
|
|
792
795
|
const o = await M.injectWorkerPathPrefix({
|
|
793
796
|
namespace: k.NAMESPACE,
|
|
@@ -820,7 +823,7 @@ async function ar() {
|
|
|
820
823
|
))
|
|
821
824
|
return e[0].id;
|
|
822
825
|
const t = C(process.cwd(), "tsconfig.json");
|
|
823
|
-
return
|
|
826
|
+
return pe.existsSync(t) || pe.readdirSync(process.cwd()).some((o) => [".ts", ".tsx"].includes(q(o))) ? "typescript" : "javascript";
|
|
824
827
|
} catch {
|
|
825
828
|
return "javascript";
|
|
826
829
|
}
|
|
@@ -845,7 +848,7 @@ const cr = { inferPreset: ar }, lr = (e) => Object.values(K).find((t) => t.metad
|
|
|
845
848
|
}
|
|
846
849
|
}, pr = async (e, t) => {
|
|
847
850
|
try {
|
|
848
|
-
const r =
|
|
851
|
+
const r = _.OUTPUT_STORAGE_METADATA_PATH;
|
|
849
852
|
let n = [];
|
|
850
853
|
try {
|
|
851
854
|
const o = await h.readFile(r, "utf-8");
|
|
@@ -902,7 +905,7 @@ const cr = { inferPreset: ar }, lr = (e) => Object.values(K).find((t) => t.metad
|
|
|
902
905
|
const t = e.storage || [], r = [];
|
|
903
906
|
if (t.length === 0)
|
|
904
907
|
return g.info("No storages found to setup"), r;
|
|
905
|
-
await h.mkdir(
|
|
908
|
+
await h.mkdir(_.OUTPUT_STORAGE_PATH, { recursive: !0 });
|
|
906
909
|
for (const n of t) {
|
|
907
910
|
if (!hr(n))
|
|
908
911
|
continue;
|
|
@@ -915,7 +918,7 @@ const cr = { inferPreset: ar }, lr = (e) => Object.values(K).find((t) => t.metad
|
|
|
915
918
|
const o = n.prefix, i = o || ur();
|
|
916
919
|
o || p.storage.info(
|
|
917
920
|
`No prefix provided for storage '${n.name}', generating version prefix: ${i}`
|
|
918
|
-
), o && p.storage.info(`Using provided prefix for storage '${n.name}': ${i}`), await mr(n, s,
|
|
921
|
+
), o && p.storage.info(`Using provided prefix for storage '${n.name}': ${i}`), await mr(n, s, _.OUTPUT_STORAGE_PATH, i), r.push({
|
|
919
922
|
...n,
|
|
920
923
|
prefix: i
|
|
921
924
|
});
|
|
@@ -930,7 +933,7 @@ const cr = { inferPreset: ar }, lr = (e) => Object.values(K).find((t) => t.metad
|
|
|
930
933
|
UNSUPPORTED_PATTERN_SUGGESTIONS: "Consider updating your handler to use ES Modules pattern."
|
|
931
934
|
}, L = `
|
|
932
935
|
const request = event.request;
|
|
933
|
-
const env =
|
|
936
|
+
const env = process.env; // or any other environment variables you want to pass
|
|
934
937
|
const ctx = { waitUntil: event.waitUntil?.bind(event) };`, Z = {
|
|
935
938
|
baseImport: (e) => `
|
|
936
939
|
import module from '${e}';
|
|
@@ -972,7 +975,7 @@ if (fetchHandler) {
|
|
|
972
975
|
} else {
|
|
973
976
|
throw new Error("No fetch handler found in default export object.");
|
|
974
977
|
}`
|
|
975
|
-
},
|
|
978
|
+
}, Ae = (e) => {
|
|
976
979
|
const t = e.split(`
|
|
977
980
|
`), r = /addEventListener\s*\(\s*['"`](fetch|firewall)['"`]\s*,/;
|
|
978
981
|
return t.some((n) => {
|
|
@@ -1012,15 +1015,15 @@ addEventListener('fetch', (event) => {
|
|
|
1012
1015
|
return await handler(event);
|
|
1013
1016
|
})());
|
|
1014
1017
|
});
|
|
1015
|
-
`, ce = (e) => /export\s+default\s*\{[\s\S]*fetch[\s\S]*\}/.test(e),
|
|
1018
|
+
`, ce = (e) => /export\s+default\s*\{[\s\S]*fetch[\s\S]*\}/.test(e), Oe = (e) => !(!/export\s+default\s+/.test(e) || ce(e)), Er = async (e) => {
|
|
1016
1019
|
try {
|
|
1017
1020
|
const t = await import(e);
|
|
1018
1021
|
return typeof t.default > "u" && !t.fetch && !t.firewall ? "serviceWorker" : t.default && typeof t.default == "object" && (t.default.fetch || t.default.firewall) ? "ESModules" : t.default ? "legacy" : "unsupported";
|
|
1019
1022
|
} catch {
|
|
1020
1023
|
const r = await (await import("fs/promises")).readFile(e, "utf-8");
|
|
1021
|
-
return
|
|
1024
|
+
return Ae(r) ? "serviceWorker" : ce(r) ? "ESModules" : Oe(r) ? "legacy" : "unsupported";
|
|
1022
1025
|
}
|
|
1023
|
-
}, vr = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e), Tr = (e) =>
|
|
1026
|
+
}, vr = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e), Tr = (e) => Ae(e) ? "serviceWorker" : ce(e) ? "ESModules" : Oe(e) ? "legacy" : "unsupported", Sr = async (e, t, r) => {
|
|
1024
1027
|
let n;
|
|
1025
1028
|
try {
|
|
1026
1029
|
n = await Er(t);
|
|
@@ -1051,10 +1054,10 @@ addEventListener('fetch', (event) => {
|
|
|
1051
1054
|
`Failed to setup worker code: ${r instanceof Error ? r.message : String(r)}`
|
|
1052
1055
|
);
|
|
1053
1056
|
}
|
|
1054
|
-
}, Pr = (e) => e === !0 ? !0 : process.env[
|
|
1055
|
-
const e = process.env[
|
|
1056
|
-
return e === "console" || e === "json" || e === "html" || e === "both" ? e :
|
|
1057
|
-
}, kr = () => process.env[
|
|
1057
|
+
}, Pr = (e) => e === !0 ? !0 : process.env[U.ENV_ENABLED] === "true", xr = () => {
|
|
1058
|
+
const e = process.env[U.ENV_FORMAT];
|
|
1059
|
+
return e === "console" || e === "json" || e === "html" || e === "both" ? e : U.DEFAULT_FORMAT;
|
|
1060
|
+
}, kr = () => process.env[U.ENV_OUTPUT] || U.DEFAULT_OUTPUT_PATH, Cr = () => U.DEFAULT_HTML_OUTPUT_PATH, Fr = async (e) => {
|
|
1058
1061
|
const { config: t, options: r } = e, n = !!r.production, s = Pr(r.telemetry), o = t.build?.bundler || "esbuild", i = {
|
|
1059
1062
|
enabled: s,
|
|
1060
1063
|
outputFormat: xr(),
|
|
@@ -1099,11 +1102,11 @@ addEventListener('fetch', (event) => {
|
|
|
1099
1102
|
async () => Wt(t, f, n)
|
|
1100
1103
|
);
|
|
1101
1104
|
if (r.onlyGenerateConfig) {
|
|
1102
|
-
const E = await
|
|
1105
|
+
const E = await he({
|
|
1103
1106
|
config: t,
|
|
1104
1107
|
preset: f,
|
|
1105
1108
|
ctx: {
|
|
1106
|
-
production: n ??
|
|
1109
|
+
production: n ?? O.PRODUCTION,
|
|
1107
1110
|
skipFrameworkBuild: !!r.skipFrameworkBuild,
|
|
1108
1111
|
handler: ""
|
|
1109
1112
|
}
|
|
@@ -1111,7 +1114,7 @@ addEventListener('fetch', (event) => {
|
|
|
1111
1114
|
return p.build.success("Build completed successfully with only azion.config"), te(E), a.endSpan(l), a.printToConsole(), await a.saveReport(), {
|
|
1112
1115
|
config: E,
|
|
1113
1116
|
ctx: {
|
|
1114
|
-
production: n ??
|
|
1117
|
+
production: n ?? O.PRODUCTION,
|
|
1115
1118
|
skipFrameworkBuild: !!r.skipFrameworkBuild,
|
|
1116
1119
|
handler: ""
|
|
1117
1120
|
},
|
|
@@ -1119,7 +1122,7 @@ addEventListener('fetch', (event) => {
|
|
|
1119
1122
|
};
|
|
1120
1123
|
}
|
|
1121
1124
|
let m = {
|
|
1122
|
-
production: n ??
|
|
1125
|
+
production: n ?? O.PRODUCTION,
|
|
1123
1126
|
skipFrameworkBuild: !!r.skipFrameworkBuild,
|
|
1124
1127
|
handler: ""
|
|
1125
1128
|
};
|
|
@@ -1130,7 +1133,7 @@ addEventListener('fetch', (event) => {
|
|
|
1130
1133
|
"environment-setup",
|
|
1131
1134
|
"Environment Setup",
|
|
1132
1135
|
async () => {
|
|
1133
|
-
const E = await
|
|
1136
|
+
const E = await he({
|
|
1134
1137
|
config: t,
|
|
1135
1138
|
preset: f,
|
|
1136
1139
|
ctx: m
|
|
@@ -1163,7 +1166,7 @@ addEventListener('fetch', (event) => {
|
|
|
1163
1166
|
})
|
|
1164
1167
|
);
|
|
1165
1168
|
m = {
|
|
1166
|
-
production: n ??
|
|
1169
|
+
production: n ?? O.PRODUCTION,
|
|
1167
1170
|
handler: y,
|
|
1168
1171
|
skipFrameworkBuild: !!r.skipFrameworkBuild
|
|
1169
1172
|
}, await x(
|
|
@@ -1176,7 +1179,7 @@ addEventListener('fetch', (event) => {
|
|
|
1176
1179
|
const E = await $r(u, m), w = [];
|
|
1177
1180
|
await Promise.all(
|
|
1178
1181
|
Object.entries(E).map(async ([v, j]) => {
|
|
1179
|
-
await
|
|
1182
|
+
await $e(Pe(v), { recursive: !0 }), await ot(v, j, "utf-8"), w.push(v);
|
|
1180
1183
|
})
|
|
1181
1184
|
);
|
|
1182
1185
|
for (const v of w)
|
|
@@ -1240,7 +1243,7 @@ addEventListener('fetch', (event) => {
|
|
|
1240
1243
|
};
|
|
1241
1244
|
} catch (l) {
|
|
1242
1245
|
g.error("Build process failed:", l), p.build.error(
|
|
1243
|
-
`${l instanceof Error ? l.message : String(l)}${
|
|
1246
|
+
`${l instanceof Error ? l.message : String(l)}${R}`
|
|
1244
1247
|
), a.markFailed(l instanceof Error ? l.message : String(l)), s && (a.printToConsole(), await a.saveReport()), process.exit(1);
|
|
1245
1248
|
}
|
|
1246
1249
|
};
|
|
@@ -1249,22 +1252,22 @@ async function Ar(e) {
|
|
|
1249
1252
|
preset: B({
|
|
1250
1253
|
inputValue: e.preset,
|
|
1251
1254
|
fileValue: r?.preset,
|
|
1252
|
-
defaultValue:
|
|
1255
|
+
defaultValue: O.PRESET
|
|
1253
1256
|
}),
|
|
1254
1257
|
entry: B({
|
|
1255
1258
|
inputValue: e.entry,
|
|
1256
1259
|
fileValue: r?.entry,
|
|
1257
|
-
defaultValue:
|
|
1260
|
+
defaultValue: O.ENTRY
|
|
1258
1261
|
}),
|
|
1259
1262
|
bundler: B({
|
|
1260
1263
|
inputValue: void 0,
|
|
1261
1264
|
fileValue: r?.bundler,
|
|
1262
|
-
defaultValue:
|
|
1265
|
+
defaultValue: O.BUNDLER
|
|
1263
1266
|
}),
|
|
1264
1267
|
polyfills: B({
|
|
1265
1268
|
inputValue: r?.polyfills,
|
|
1266
1269
|
fileValue: e.polyfills,
|
|
1267
|
-
defaultValue:
|
|
1270
|
+
defaultValue: O.POLYFILLS
|
|
1268
1271
|
})
|
|
1269
1272
|
}, s = {
|
|
1270
1273
|
...t,
|
|
@@ -1274,7 +1277,7 @@ async function Ar(e) {
|
|
|
1274
1277
|
extend: t?.build?.extend
|
|
1275
1278
|
}
|
|
1276
1279
|
};
|
|
1277
|
-
return e.production && await
|
|
1280
|
+
return e.production && await Ot([_.OUTPUT_BASE_PATH]), Fr({
|
|
1278
1281
|
config: s,
|
|
1279
1282
|
options: {
|
|
1280
1283
|
production: e.production,
|
|
@@ -1285,12 +1288,12 @@ async function Ar(e) {
|
|
|
1285
1288
|
});
|
|
1286
1289
|
}
|
|
1287
1290
|
let Q, G = !1;
|
|
1288
|
-
const
|
|
1291
|
+
const Or = (e, t, r, n = !0) => {
|
|
1289
1292
|
let s = r;
|
|
1290
1293
|
const o = new RegExp(`addEventListener\\((['"]?)${e}\\1,`, "g"), i = /firewall:\s*\(event\)\s*=>\s*{/g, c = !!r.match(i), a = /eventType\s*=\s*['"]firewall['"];/g, l = !!r.match(o);
|
|
1291
1294
|
return (n && l || c) && (s = r.replace(o, `addEventListener("${t}",`), c && (s = s.replace(a, "eventType = 'fetch';"))), { matchEvent: l || c, codeChanged: s };
|
|
1292
1295
|
};
|
|
1293
|
-
function
|
|
1296
|
+
function _r(e) {
|
|
1294
1297
|
return new Promise((t) => {
|
|
1295
1298
|
const r = new pt.Socket();
|
|
1296
1299
|
r.setTimeout(1e3), r.on("connect", () => {
|
|
@@ -1309,24 +1312,24 @@ async function jr(e) {
|
|
|
1309
1312
|
if (t.message.includes("ENOENT")) {
|
|
1310
1313
|
const r = re(e);
|
|
1311
1314
|
throw new Error(
|
|
1312
|
-
`Server entry file "${r}" not found. Please specify your entry point using "azion dev <path>" or create the default handler file.${
|
|
1315
|
+
`Server entry file "${r}" not found. Please specify your entry point using "azion dev <path>" or create the default handler file.${R}`
|
|
1313
1316
|
);
|
|
1314
1317
|
}
|
|
1315
|
-
throw new Error(`Error reading file ${e}: ${t.message}${
|
|
1318
|
+
throw new Error(`Error reading file ${e}: ${t.message}${R}`);
|
|
1316
1319
|
}
|
|
1317
1320
|
}
|
|
1318
|
-
async function
|
|
1321
|
+
async function Rr(e, t) {
|
|
1319
1322
|
const { matchEvent: r, codeChanged: n } = (
|
|
1320
1323
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1321
|
-
|
|
1322
|
-
), o =
|
|
1324
|
+
Or("firewall", "fetch", t)
|
|
1325
|
+
), o = Ce(r ? n : t, r);
|
|
1323
1326
|
return mt({ port: e, host: "0.0.0.0", runtime: o });
|
|
1324
1327
|
}
|
|
1325
|
-
function
|
|
1328
|
+
function ye(e, t) {
|
|
1326
1329
|
const r = e?.bindings?.storage?.bucket || t?.storage?.[0].name || "", n = e?.bindings?.storage?.prefix || t?.storage?.[0].prefix || "";
|
|
1327
1330
|
return { bucketName: r, prefix: n };
|
|
1328
1331
|
}
|
|
1329
|
-
function
|
|
1332
|
+
function Ur(e, t, r) {
|
|
1330
1333
|
const n = Object.keys(e).find((s) => {
|
|
1331
1334
|
const o = s.replace(/\.dev$/, "").replace(/\.edge\//, "");
|
|
1332
1335
|
return r.replace(/\.js$/, "").endsWith(o);
|
|
@@ -1335,7 +1338,7 @@ function Rr(e, t, r) {
|
|
|
1335
1338
|
throw new Error(`Entry path not found for function "${t}"`);
|
|
1336
1339
|
return n;
|
|
1337
1340
|
}
|
|
1338
|
-
function
|
|
1341
|
+
function we(e) {
|
|
1339
1342
|
return e.endsWith(".js") ? e : `${e}.js`;
|
|
1340
1343
|
}
|
|
1341
1344
|
function Nr(e, t, r) {
|
|
@@ -1345,20 +1348,20 @@ function Nr(e, t, r) {
|
|
|
1345
1348
|
const i = t.functions?.find((l) => l.name === r);
|
|
1346
1349
|
if (!i)
|
|
1347
1350
|
throw new Error(`Function "${r}" not found in edge functions configuration`);
|
|
1348
|
-
const c =
|
|
1351
|
+
const c = Ur(e, r, i.path), a = ye(i, t);
|
|
1349
1352
|
return {
|
|
1350
1353
|
name: i.name,
|
|
1351
1354
|
bucket: a.bucketName,
|
|
1352
1355
|
prefix: a.prefix,
|
|
1353
|
-
path:
|
|
1356
|
+
path: we(c)
|
|
1354
1357
|
};
|
|
1355
1358
|
}
|
|
1356
|
-
const n = Object.keys(e)[0], s = t.functions?.[0], o =
|
|
1359
|
+
const n = Object.keys(e)[0], s = t.functions?.[0], o = ye(s, t);
|
|
1357
1360
|
return {
|
|
1358
1361
|
name: s?.name,
|
|
1359
1362
|
bucket: o.bucketName,
|
|
1360
1363
|
prefix: o.prefix,
|
|
1361
|
-
path:
|
|
1364
|
+
path: we(n)
|
|
1362
1365
|
};
|
|
1363
1366
|
}
|
|
1364
1367
|
async function le(e, t, r = !1, n) {
|
|
@@ -1380,7 +1383,7 @@ async function le(e, t, r = !1, n) {
|
|
|
1380
1383
|
p.server.error(a.message), g.error(`Error reading worker file: ${a}`), process.exit(1);
|
|
1381
1384
|
}
|
|
1382
1385
|
try {
|
|
1383
|
-
Q = await
|
|
1386
|
+
Q = await Rr(t, c), p.server.success(
|
|
1384
1387
|
`Function running on port 0.0.0.0:${t}, url: http://localhost:${t}`
|
|
1385
1388
|
);
|
|
1386
1389
|
} catch (a) {
|
|
@@ -1391,7 +1394,7 @@ async function le(e, t, r = !1, n) {
|
|
|
1391
1394
|
}
|
|
1392
1395
|
} catch (s) {
|
|
1393
1396
|
p.server.error(
|
|
1394
|
-
`${s instanceof Error ? s.message : String(s)}${
|
|
1397
|
+
`${s instanceof Error ? s.message : String(s)}${R}`
|
|
1395
1398
|
), g.error(`Server management error: ${s}`), process.exit(1);
|
|
1396
1399
|
} finally {
|
|
1397
1400
|
G = !1;
|
|
@@ -1410,7 +1413,7 @@ async function Ir(e, t, r) {
|
|
|
1410
1413
|
}
|
|
1411
1414
|
}
|
|
1412
1415
|
async function _e(e, t, r = !1, n) {
|
|
1413
|
-
await
|
|
1416
|
+
await _r(t) && (p.server.error(`Port ${t} is in use. Please choose another port.`), process.exit(1)), await le(e, t, r, n);
|
|
1414
1417
|
const o = Ye.watch("./", {
|
|
1415
1418
|
persistent: !0,
|
|
1416
1419
|
ignoreInitial: !0,
|
|
@@ -1423,12 +1426,12 @@ async function _e(e, t, r = !1, n) {
|
|
|
1423
1426
|
};
|
|
1424
1427
|
o.on("add", i).on("change", i).on("unlink", i).on("addDir", i).on("unlinkDir", i).on("error", (c) => g.error(`Watcher error: ${c}`)).on("ready", () => p.server.info("Initial scan complete. Ready for changes."));
|
|
1425
1428
|
}
|
|
1426
|
-
const
|
|
1427
|
-
runtime:
|
|
1429
|
+
const be = {
|
|
1430
|
+
runtime: Ce,
|
|
1428
1431
|
server: _e,
|
|
1429
1432
|
readStore: Je,
|
|
1430
1433
|
readAzionConfig: se,
|
|
1431
|
-
writeStore:
|
|
1434
|
+
writeStore: Te,
|
|
1432
1435
|
writeUserConfig: ee
|
|
1433
1436
|
};
|
|
1434
1437
|
async function $n({
|
|
@@ -1440,7 +1443,7 @@ async function $n({
|
|
|
1440
1443
|
const s = parseInt(t, 10);
|
|
1441
1444
|
_e(e || null, s, r, n);
|
|
1442
1445
|
}
|
|
1443
|
-
function
|
|
1446
|
+
function Ee() {
|
|
1444
1447
|
return Object.values(K).filter((t) => t.metadata?.name).map((t) => t.metadata.name);
|
|
1445
1448
|
}
|
|
1446
1449
|
function Br(e) {
|
|
@@ -1455,7 +1458,7 @@ async function Pn(e, t = {}) {
|
|
|
1455
1458
|
const r = process.env.CLEAN_OUTPUT_MODE === "true";
|
|
1456
1459
|
switch (e) {
|
|
1457
1460
|
case "ls":
|
|
1458
|
-
r &&
|
|
1461
|
+
r && Ee().forEach((n) => console.log(n?.toLowerCase())), r || Ee().forEach((n) => p.option(n));
|
|
1459
1462
|
break;
|
|
1460
1463
|
case "config":
|
|
1461
1464
|
if (!t.preset) {
|
|
@@ -1487,7 +1490,7 @@ const Wr = { processConfigWrapper: Dr }, Mr = ".edge/manifest.json", Lr = "azion
|
|
|
1487
1490
|
if (typeof e == "object")
|
|
1488
1491
|
r = e;
|
|
1489
1492
|
else {
|
|
1490
|
-
const o = await
|
|
1493
|
+
const o = await Se.readAzionConfig(e);
|
|
1491
1494
|
if (!o)
|
|
1492
1495
|
throw new Error(
|
|
1493
1496
|
e ? `Failed to load config from ${e}` : "No configuration found. Please provide a config file or object."
|
|
@@ -1505,7 +1508,7 @@ const Wr = { processConfigWrapper: Dr }, Mr = ".edge/manifest.json", Lr = "azion
|
|
|
1505
1508
|
const i = await H.readFile(o, "utf8");
|
|
1506
1509
|
return rt(i);
|
|
1507
1510
|
})(e || Mr);
|
|
1508
|
-
await
|
|
1511
|
+
await Se.writeUserConfig(n, t), A.feedback.manifest.success(`Config file generated successfully at ${t}`);
|
|
1509
1512
|
};
|
|
1510
1513
|
async function xn(e) {
|
|
1511
1514
|
try {
|
|
@@ -1522,7 +1525,7 @@ async function xn(e) {
|
|
|
1522
1525
|
"Only transform and generate actions are supported"
|
|
1523
1526
|
), process.exit(1));
|
|
1524
1527
|
} catch (t) {
|
|
1525
|
-
g.error(t), p.error(`${t instanceof Error ? t.message : String(t)}${
|
|
1528
|
+
g.error(t), p.error(`${t instanceof Error ? t.message : String(t)}${R}`), await oe(_.OUTPUT_BASE_PATH, { recursive: !0, force: !0 }), process.exit(1);
|
|
1526
1529
|
}
|
|
1527
1530
|
}
|
|
1528
1531
|
async function kn({ command: e, options: t }) {
|
|
@@ -1533,7 +1536,7 @@ async function kn({ command: e, options: t }) {
|
|
|
1533
1536
|
switch (e) {
|
|
1534
1537
|
case "init": {
|
|
1535
1538
|
const s = { ...r };
|
|
1536
|
-
await
|
|
1539
|
+
await Te(s, n), p.info(`Store file initialized with scope: ${n}`);
|
|
1537
1540
|
break;
|
|
1538
1541
|
}
|
|
1539
1542
|
case "destroy":
|
|
@@ -1543,7 +1546,7 @@ async function kn({ command: e, options: t }) {
|
|
|
1543
1546
|
throw new Error(`Invalid command: ${e}`);
|
|
1544
1547
|
}
|
|
1545
1548
|
} catch (s) {
|
|
1546
|
-
p.error(`${s instanceof Error ? s.message : String(s)}${
|
|
1549
|
+
p.error(`${s instanceof Error ? s.message : String(s)}${R}`), process.exit(1);
|
|
1547
1550
|
}
|
|
1548
1551
|
}
|
|
1549
1552
|
function ne(e) {
|
|
@@ -1580,7 +1583,7 @@ async function zr() {
|
|
|
1580
1583
|
const r = t.filepath, n = await h.readFile(r, "utf8");
|
|
1581
1584
|
return { configPath: r, fileContent: n };
|
|
1582
1585
|
}
|
|
1583
|
-
const
|
|
1586
|
+
const je = {
|
|
1584
1587
|
findAndReadConfigFile: zr,
|
|
1585
1588
|
tryParseJSON: ne
|
|
1586
1589
|
};
|
|
@@ -1723,7 +1726,7 @@ async function Xr(e, t) {
|
|
|
1723
1726
|
for (const { placeholder: d, value: y } of r)
|
|
1724
1727
|
if (typeof d != "string" || typeof y != "string")
|
|
1725
1728
|
throw new Error("Placeholder and value must be strings");
|
|
1726
|
-
const { configPath: n, fileContent: s } = await
|
|
1729
|
+
const { configPath: n, fileContent: s } = await je.findAndReadConfigFile(), { start: o, end: i } = Jr(s), c = s.slice(0, o);
|
|
1727
1730
|
let a = s.slice(o, i);
|
|
1728
1731
|
const l = s.slice(i), f = /* @__PURE__ */ new Map();
|
|
1729
1732
|
for (const { placeholder: d, value: y } of r) {
|
|
@@ -1744,7 +1747,7 @@ async function Xr(e, t) {
|
|
|
1744
1747
|
const u = c + a + l;
|
|
1745
1748
|
let m;
|
|
1746
1749
|
try {
|
|
1747
|
-
m = await
|
|
1750
|
+
m = await xe.format(u, {
|
|
1748
1751
|
parser: "babel",
|
|
1749
1752
|
semi: !1,
|
|
1750
1753
|
singleQuote: !0,
|
|
@@ -1779,10 +1782,10 @@ async function Xr(e, t) {
|
|
|
1779
1782
|
}
|
|
1780
1783
|
async function Yr(e, t) {
|
|
1781
1784
|
try {
|
|
1782
|
-
const { configPath: r, fileContent: n } = await
|
|
1785
|
+
const { configPath: r, fileContent: n } = await je.findAndReadConfigFile(), s = Zr(n, e, t);
|
|
1783
1786
|
let o;
|
|
1784
1787
|
try {
|
|
1785
|
-
o = await
|
|
1788
|
+
o = await xe.format(s, {
|
|
1786
1789
|
parser: "babel",
|
|
1787
1790
|
semi: !1,
|
|
1788
1791
|
singleQuote: !0,
|
|
@@ -1912,16 +1915,16 @@ function fe(e, t, r) {
|
|
|
1912
1915
|
}
|
|
1913
1916
|
if (m === -1)
|
|
1914
1917
|
return e;
|
|
1915
|
-
const d = e.substring(a, m + 1).slice(1, -1), y =
|
|
1918
|
+
const d = e.substring(a, m + 1).slice(1, -1), y = ve(d, s, r), T = e.substring(0, a), E = e.substring(m + 1);
|
|
1916
1919
|
return T + `[ ${y} ]` + E;
|
|
1917
1920
|
}
|
|
1918
1921
|
}
|
|
1919
1922
|
}
|
|
1920
1923
|
} else if (typeof n == "number")
|
|
1921
|
-
return
|
|
1924
|
+
return ve(e, t, r);
|
|
1922
1925
|
return e;
|
|
1923
1926
|
}
|
|
1924
|
-
function
|
|
1927
|
+
function ve(e, t, r) {
|
|
1925
1928
|
if (t.length === 0) return e;
|
|
1926
1929
|
const [n, ...s] = t;
|
|
1927
1930
|
if (typeof n != "number") return e;
|
|
@@ -2087,7 +2090,7 @@ async function Cn({ command: e, options: t }) {
|
|
|
2087
2090
|
}
|
|
2088
2091
|
}
|
|
2089
2092
|
async function Fn(e = {}) {
|
|
2090
|
-
const t = e.path || C(
|
|
2093
|
+
const t = e.path || C(_.OUTPUT_BASE_PATH, "telemetry-report.html");
|
|
2091
2094
|
ht(t) || (p.error(
|
|
2092
2095
|
`Telemetry report not found at: ${t}
|
|
2093
2096
|
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function E() {
|
|
|
45
45
|
}
|
|
46
46
|
function k() {
|
|
47
47
|
n.version(globalThis.bundler.version), n.command("store <command>").description("Manage store configuration").option("-c, --config <json>", `Configuration in JSON format (e.g., '{"key": "value"}')`).option("-s, --scope <scope>", "Scope of the store (default: global)").action(async (e, o) => {
|
|
48
|
-
const { storeCommand: t } = await import("./index-
|
|
48
|
+
const { storeCommand: t } = await import("./index-B5d6nLzb.js");
|
|
49
49
|
await t({
|
|
50
50
|
command: e,
|
|
51
51
|
options: o
|
|
@@ -71,7 +71,7 @@ Examples:
|
|
|
71
71
|
$ azbundler build --telemetry json
|
|
72
72
|
`
|
|
73
73
|
).action(async (e) => {
|
|
74
|
-
const { buildCommand: o, manifestCommand: t } = await import("./index-
|
|
74
|
+
const { buildCommand: o, manifestCommand: t } = await import("./index-B5d6nLzb.js"), { dev: i, experimental: l, telemetry: s, ...d } = e;
|
|
75
75
|
if (l && (globalThis.bundler.experimental = !0), s !== void 0) {
|
|
76
76
|
const u = typeof s == "string" ? s : "both";
|
|
77
77
|
process.env.AZ_BUNDLER_TELEMETRY = "true", process.env.AZ_BUNDLER_TELEMETRY_FORMAT = u;
|
|
@@ -82,10 +82,10 @@ Examples:
|
|
|
82
82
|
});
|
|
83
83
|
await t({ action: "generate", config: m });
|
|
84
84
|
}), n.command("dev").description("Start local development environment").argument("[entry]", "Specify the entry file (default: .edge/worker.dev.js)").option("-p, --port <port>", "Specify the port", "3333").option("-x, --experimental [boolean]", "Enable experimental features", !1).option("--skip-framework-build", "Skip framework build step", !1).option("--function-name <name>", "Specify the function name").action(async (e, o) => {
|
|
85
|
-
const { devCommand: t } = await import("./index-
|
|
85
|
+
const { devCommand: t } = await import("./index-B5d6nLzb.js"), { experimental: i } = o;
|
|
86
86
|
i && (globalThis.bundler.experimental = !0), await t({ entry: e, ...o });
|
|
87
87
|
}), n.command("presets <command>").description("Manage presets for Azion projects").argument("[preset]", "Preset name (required for config command)").action(async (e, o) => {
|
|
88
|
-
const { presetsCommand: t } = await import("./index-
|
|
88
|
+
const { presetsCommand: t } = await import("./index-B5d6nLzb.js");
|
|
89
89
|
await t(e, { preset: o });
|
|
90
90
|
}), n.command("manifest [action]").description("Manage manifest files for Azion").argument(
|
|
91
91
|
"[action]",
|
|
@@ -99,7 +99,7 @@ Examples:
|
|
|
99
99
|
$ azbundler manifest -e azion.config.js -o .edge
|
|
100
100
|
`
|
|
101
101
|
).action(async (e, o, t) => {
|
|
102
|
-
const { manifestCommand: i } = await import("./index-
|
|
102
|
+
const { manifestCommand: i } = await import("./index-B5d6nLzb.js");
|
|
103
103
|
await i({
|
|
104
104
|
...o || t,
|
|
105
105
|
action: e
|
|
@@ -117,7 +117,7 @@ Examples:
|
|
|
117
117
|
$ azbundler config replace -k '$EDGE_FUNCTION_NAME' -v "my-func"
|
|
118
118
|
`
|
|
119
119
|
).action(async (e, o) => {
|
|
120
|
-
const { configCommand: t } = await import("./index-
|
|
120
|
+
const { configCommand: t } = await import("./index-B5d6nLzb.js");
|
|
121
121
|
await t({
|
|
122
122
|
command: e,
|
|
123
123
|
options: o
|
|
@@ -130,7 +130,7 @@ Examples:
|
|
|
130
130
|
$ azbundler telemetry --path ./custom-report.html
|
|
131
131
|
`
|
|
132
132
|
).action(async (e) => {
|
|
133
|
-
const { telemetryCommand: o } = await import("./index-
|
|
133
|
+
const { telemetryCommand: o } = await import("./index-B5d6nLzb.js");
|
|
134
134
|
await o(e);
|
|
135
135
|
}), n.parse(process.argv);
|
|
136
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aziontech/bundler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Tool to launch and build JavaScript/Frameworks. This tool automates polyfills for Edge Computing and assists in creating Workers, notably for the Azion platform.",
|
|
5
5
|
"index": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"author": "aziontech",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@aziontech/builder": "1.0.
|
|
16
|
+
"@aziontech/builder": "1.0.3",
|
|
17
17
|
"@aziontech/bundler-telemetry": "1.0.0",
|
|
18
|
-
"@aziontech/config": "1.0.
|
|
18
|
+
"@aziontech/config": "1.0.1",
|
|
19
19
|
"@aziontech/utils": "1.0.0",
|
|
20
|
-
"@aziontech/presets": "1.
|
|
20
|
+
"@aziontech/presets": "1.1.1",
|
|
21
21
|
"@edge-runtime/primitives": "4.0.5",
|
|
22
22
|
"@netlify/framework-info": "^9.9.1",
|
|
23
23
|
"chokidar": "^3.5.3",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"mock-fs": "^5.2.0",
|
|
49
49
|
"puppeteer": "^24.15.0",
|
|
50
50
|
"supertest": "^6.3.3",
|
|
51
|
-
"tmp": "^0.2.
|
|
51
|
+
"tmp": "^0.2.6",
|
|
52
52
|
"ts-jest": "^29.2.6",
|
|
53
53
|
"ts-node": "^10.9.2",
|
|
54
54
|
"vite": "^7.3.1"
|