edge-functions 5.2.0 → 5.3.0-stage.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// lib/env/runtime.ts
|
|
2
|
-
import { EdgeRuntime } from "edge-runtime";
|
|
3
2
|
import {
|
|
4
3
|
fetchContext,
|
|
5
4
|
FetchEventContext,
|
|
@@ -13,6 +12,337 @@ import {
|
|
|
13
12
|
cryptoContext,
|
|
14
13
|
promisesContext
|
|
15
14
|
} from "azion/bundler/polyfills";
|
|
15
|
+
|
|
16
|
+
// lib/env/edge-vm/edge-vm.ts
|
|
17
|
+
import { load as loadPrimitives } from "@edge-runtime/primitives/dist/load.js";
|
|
18
|
+
import { runInContext } from "vm";
|
|
19
|
+
|
|
20
|
+
// lib/env/edge-vm/vm.ts
|
|
21
|
+
import { resolve } from "path";
|
|
22
|
+
import { pathToFileURL } from "url";
|
|
23
|
+
import vm from "node:vm";
|
|
24
|
+
var VM = class {
|
|
25
|
+
context;
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
const context = vm.createContext(
|
|
28
|
+
{},
|
|
29
|
+
{
|
|
30
|
+
name: "Edge Runtime",
|
|
31
|
+
codeGeneration: options.codeGeneration ?? {
|
|
32
|
+
strings: false,
|
|
33
|
+
wasm: true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
this.context = options.extend?.(context) ?? context;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Allows to run arbitrary code within the VM.
|
|
41
|
+
*/
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
evaluate(code) {
|
|
44
|
+
return vm.runInContext(code, this.context, {
|
|
45
|
+
importModuleDynamically: async (specifier) => {
|
|
46
|
+
try {
|
|
47
|
+
const fileUrl = pathToFileURL(resolve(specifier)).href;
|
|
48
|
+
return await import(fileUrl);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
if (process.env.DEBUG) {
|
|
51
|
+
console.warn(
|
|
52
|
+
">>> [edge-runtime] dynamic import failed, returning empty module:",
|
|
53
|
+
specifier
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const mod = new vm.SourceTextModule("export default {}", { context: this.context });
|
|
57
|
+
await mod.link(() => {
|
|
58
|
+
return new vm.SourceTextModule("export {}", { context: this.context });
|
|
59
|
+
});
|
|
60
|
+
await mod.evaluate();
|
|
61
|
+
return mod;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// lib/env/edge-vm/edge-vm.ts
|
|
70
|
+
var unhandledRejectionHandlers;
|
|
71
|
+
var uncaughtExceptionHandlers;
|
|
72
|
+
var EdgeVM = class extends VM {
|
|
73
|
+
dispatchFetch;
|
|
74
|
+
constructor(options) {
|
|
75
|
+
super({
|
|
76
|
+
...options,
|
|
77
|
+
extend: (context) => {
|
|
78
|
+
return options?.extend ? options.extend(addPrimitives(context)) : addPrimitives(context);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(this.context, "__onUnhandledRejectionHandlers", {
|
|
82
|
+
set: registerUnhandledRejectionHandlers,
|
|
83
|
+
configurable: false,
|
|
84
|
+
enumerable: false
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "__rejectionHandlers", {
|
|
87
|
+
get: () => unhandledRejectionHandlers,
|
|
88
|
+
configurable: false,
|
|
89
|
+
enumerable: false
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this.context, "__onErrorHandlers", {
|
|
92
|
+
set: registerUncaughtExceptionHandlers,
|
|
93
|
+
configurable: false,
|
|
94
|
+
enumerable: false
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(this, "__errorHandlers", {
|
|
97
|
+
get: () => uncaughtExceptionHandlers,
|
|
98
|
+
configurable: false,
|
|
99
|
+
enumerable: false
|
|
100
|
+
});
|
|
101
|
+
this.evaluate(getDefineEventListenersCode());
|
|
102
|
+
this.dispatchFetch = this.evaluate(getDispatchFetchCode());
|
|
103
|
+
for (const name of transferableConstructors) {
|
|
104
|
+
patchInstanceOf(name, this.context);
|
|
105
|
+
}
|
|
106
|
+
if (options?.initialCode) {
|
|
107
|
+
this.evaluate(options.initialCode);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var transferableConstructors = [
|
|
112
|
+
"Object",
|
|
113
|
+
"Array",
|
|
114
|
+
"RegExp",
|
|
115
|
+
"Uint8Array",
|
|
116
|
+
"ArrayBuffer",
|
|
117
|
+
"Error",
|
|
118
|
+
"SyntaxError",
|
|
119
|
+
"TypeError"
|
|
120
|
+
];
|
|
121
|
+
function patchInstanceOf(item, ctx) {
|
|
122
|
+
const evail = eval;
|
|
123
|
+
ctx[Symbol.for(`node:${item}`)] = evail(item);
|
|
124
|
+
return runInContext(
|
|
125
|
+
`
|
|
126
|
+
globalThis.${item} = new Proxy(${item}, {
|
|
127
|
+
get(target, prop, receiver) {
|
|
128
|
+
if (prop === Symbol.hasInstance && receiver === globalThis.${item}) {
|
|
129
|
+
const nodeTarget = globalThis[Symbol.for('node:${item}')];
|
|
130
|
+
if (nodeTarget) {
|
|
131
|
+
return function(instance) {
|
|
132
|
+
return instance instanceof target || instance instanceof nodeTarget;
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
throw new Error('node target must exist')
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return Reflect.get(target, prop, receiver);
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
`,
|
|
143
|
+
ctx
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function registerUnhandledRejectionHandlers(handlers) {
|
|
147
|
+
if (!unhandledRejectionHandlers) {
|
|
148
|
+
process.on("unhandledRejection", function invokeRejectionHandlers(reason, promise) {
|
|
149
|
+
unhandledRejectionHandlers.forEach((handler) => handler({ reason, promise }));
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
unhandledRejectionHandlers = handlers;
|
|
153
|
+
}
|
|
154
|
+
function registerUncaughtExceptionHandlers(handlers) {
|
|
155
|
+
if (!uncaughtExceptionHandlers) {
|
|
156
|
+
process.on("uncaughtException", function invokeErrorHandlers(error) {
|
|
157
|
+
uncaughtExceptionHandlers.forEach((handler) => handler(error));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
uncaughtExceptionHandlers = handlers;
|
|
161
|
+
}
|
|
162
|
+
function getDefineEventListenersCode() {
|
|
163
|
+
return `
|
|
164
|
+
Object.defineProperty(self, '__listeners', {
|
|
165
|
+
configurable: false,
|
|
166
|
+
enumerable: false,
|
|
167
|
+
value: {},
|
|
168
|
+
writable: true,
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
function __conditionallyUpdatesHandlerList(eventType) {
|
|
172
|
+
if (eventType === 'unhandledrejection') {
|
|
173
|
+
self.__onUnhandledRejectionHandlers = self.__listeners[eventType];
|
|
174
|
+
} else if (eventType === 'error') {
|
|
175
|
+
self.__onErrorHandlers = self.__listeners[eventType];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function addEventListener(type, handler) {
|
|
180
|
+
const eventType = type.toLowerCase();
|
|
181
|
+
if (eventType === 'fetch' && self.__listeners.fetch) {
|
|
182
|
+
throw new TypeError('You can register just one "fetch" event listener');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
self.__listeners[eventType] = self.__listeners[eventType] || [];
|
|
186
|
+
self.__listeners[eventType].push(handler);
|
|
187
|
+
__conditionallyUpdatesHandlerList(eventType);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function removeEventListener(type, handler) {
|
|
191
|
+
const eventType = type.toLowerCase();
|
|
192
|
+
if (self.__listeners[eventType]) {
|
|
193
|
+
self.__listeners[eventType] = self.__listeners[eventType].filter(item => {
|
|
194
|
+
return item !== handler;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (self.__listeners[eventType].length === 0) {
|
|
198
|
+
delete self.__listeners[eventType];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
__conditionallyUpdatesHandlerList(eventType);
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
}
|
|
205
|
+
function getDispatchFetchCode() {
|
|
206
|
+
return `(async function dispatchFetch(input, init) {
|
|
207
|
+
const request = new Request(input, init);
|
|
208
|
+
const event = new FetchEvent(request);
|
|
209
|
+
if (!self.__listeners.fetch) {
|
|
210
|
+
throw new Error("No fetch event listeners found");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const getResponse = ({ response, error }) => {
|
|
214
|
+
if (error || !response || !(response instanceof Response)) {
|
|
215
|
+
console.error(error ? error.toString() : 'The event listener did not respond')
|
|
216
|
+
response = new Response(null, {
|
|
217
|
+
statusText: 'Internal Server Error',
|
|
218
|
+
status: 500
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
response.waitUntil = () => Promise.all(event.awaiting);
|
|
223
|
+
|
|
224
|
+
if (response.status < 300 || response.status >= 400 ) {
|
|
225
|
+
response.headers.delete('content-encoding');
|
|
226
|
+
response.headers.delete('transform-encoding');
|
|
227
|
+
response.headers.delete('content-length');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return response;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
await self.__listeners.fetch[0].call(event, event)
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return getResponse({ error })
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return Promise.resolve(event.response)
|
|
240
|
+
.then(response => getResponse({ response }))
|
|
241
|
+
.catch(error => getResponse({ error }))
|
|
242
|
+
})`;
|
|
243
|
+
}
|
|
244
|
+
function addPrimitives(context) {
|
|
245
|
+
defineProperty(context, "self", { enumerable: true, value: context });
|
|
246
|
+
defineProperty(context, "globalThis", { value: context });
|
|
247
|
+
defineProperty(context, "Symbol", { value: Symbol });
|
|
248
|
+
defineProperty(context, "clearInterval", { value: clearInterval });
|
|
249
|
+
defineProperty(context, "clearTimeout", { value: clearTimeout });
|
|
250
|
+
defineProperty(context, "queueMicrotask", { value: queueMicrotask });
|
|
251
|
+
defineProperty(context, "EdgeRuntime", { value: "edge-runtime" });
|
|
252
|
+
const transferables = getTransferablePrimitivesFromContext(context);
|
|
253
|
+
defineProperties(context, {
|
|
254
|
+
exports: loadPrimitives({
|
|
255
|
+
...transferables,
|
|
256
|
+
WeakRef: runInContext(`WeakRef`, context)
|
|
257
|
+
}),
|
|
258
|
+
enumerable: ["crypto"],
|
|
259
|
+
nonenumerable: [
|
|
260
|
+
// Crypto
|
|
261
|
+
"Crypto",
|
|
262
|
+
"CryptoKey",
|
|
263
|
+
"SubtleCrypto",
|
|
264
|
+
// Fetch APIs
|
|
265
|
+
"fetch",
|
|
266
|
+
"File",
|
|
267
|
+
"FormData",
|
|
268
|
+
"Headers",
|
|
269
|
+
"Request",
|
|
270
|
+
"Response",
|
|
271
|
+
"WebSocket",
|
|
272
|
+
// Structured Clone
|
|
273
|
+
"structuredClone",
|
|
274
|
+
// Blob
|
|
275
|
+
"Blob",
|
|
276
|
+
// URL
|
|
277
|
+
"URL",
|
|
278
|
+
"URLSearchParams",
|
|
279
|
+
"URLPattern",
|
|
280
|
+
// AbortController
|
|
281
|
+
"AbortController",
|
|
282
|
+
"AbortSignal",
|
|
283
|
+
"DOMException",
|
|
284
|
+
// Streams
|
|
285
|
+
"ReadableStream",
|
|
286
|
+
"ReadableStreamBYOBReader",
|
|
287
|
+
"ReadableStreamDefaultReader",
|
|
288
|
+
"TextDecoderStream",
|
|
289
|
+
"TextEncoderStream",
|
|
290
|
+
"TransformStream",
|
|
291
|
+
"WritableStream",
|
|
292
|
+
"WritableStreamDefaultWriter",
|
|
293
|
+
// Encoding
|
|
294
|
+
"atob",
|
|
295
|
+
"btoa",
|
|
296
|
+
"TextEncoder",
|
|
297
|
+
"TextDecoder",
|
|
298
|
+
// Events
|
|
299
|
+
"Event",
|
|
300
|
+
"EventTarget",
|
|
301
|
+
"FetchEvent",
|
|
302
|
+
"PromiseRejectionEvent",
|
|
303
|
+
// Console
|
|
304
|
+
"console",
|
|
305
|
+
// Timers
|
|
306
|
+
"setTimeout",
|
|
307
|
+
"setInterval"
|
|
308
|
+
]
|
|
309
|
+
});
|
|
310
|
+
return context;
|
|
311
|
+
}
|
|
312
|
+
function defineProperty(obj, prop, attrs) {
|
|
313
|
+
Object.defineProperty(obj, prop, {
|
|
314
|
+
configurable: attrs.configurable ?? false,
|
|
315
|
+
enumerable: attrs.enumerable ?? false,
|
|
316
|
+
value: attrs.value,
|
|
317
|
+
writable: attrs.writable ?? true
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function defineProperties(context, options) {
|
|
321
|
+
for (const property of options.enumerable ?? []) {
|
|
322
|
+
if (!options.exports[property]) {
|
|
323
|
+
throw new Error(`Attempt to export a nullable value for "${property}"`);
|
|
324
|
+
}
|
|
325
|
+
defineProperty(context, property, {
|
|
326
|
+
enumerable: true,
|
|
327
|
+
value: options.exports[property]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
for (const property of options.nonenumerable ?? []) {
|
|
331
|
+
if (!options.exports[property]) {
|
|
332
|
+
throw new Error(`Attempt to export a nullable value for "${property}"`);
|
|
333
|
+
}
|
|
334
|
+
defineProperty(context, property, {
|
|
335
|
+
value: options.exports[property]
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function getTransferablePrimitivesFromContext(context) {
|
|
340
|
+
const keys = transferableConstructors.join(",");
|
|
341
|
+
const stringifedObject = `({${keys}})`;
|
|
342
|
+
return runInContext(stringifedObject, context);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// lib/env/runtime.ts
|
|
16
346
|
function runtime(code, isFirewallEvent = false) {
|
|
17
347
|
const extend = (context) => {
|
|
18
348
|
context.RESERVED_FETCH = context.fetch.bind(context);
|
|
@@ -34,7 +364,7 @@ function runtime(code, isFirewallEvent = false) {
|
|
|
34
364
|
context.Promise.withResolvers = promisesContext;
|
|
35
365
|
return context;
|
|
36
366
|
};
|
|
37
|
-
const edgeRuntime = new
|
|
367
|
+
const edgeRuntime = new EdgeVM({
|
|
38
368
|
extend,
|
|
39
369
|
initialCode: code,
|
|
40
370
|
codeGeneration: {
|
|
@@ -55,7 +385,7 @@ import { readFile, writeFile, access } from "fs/promises";
|
|
|
55
385
|
import { constants } from "fs";
|
|
56
386
|
|
|
57
387
|
// lib/constants.ts
|
|
58
|
-
import { join, resolve } from "path";
|
|
388
|
+
import { join, resolve as resolve2 } from "path";
|
|
59
389
|
import { readFileSync } from "fs";
|
|
60
390
|
import { getAbsoluteDirPath } from "azion/utils/node";
|
|
61
391
|
import { tmpdir } from "os";
|
|
@@ -93,7 +423,7 @@ var BUNDLER = {
|
|
|
93
423
|
IS_DEBUG: process.env.DEBUG === "true",
|
|
94
424
|
TEMP_DIR: (projectID) => join(tmpdir(), ".azion", projectID),
|
|
95
425
|
get ROOT_PATH() {
|
|
96
|
-
return
|
|
426
|
+
return resolve2(BUNDLER.LIB_DIR, ".");
|
|
97
427
|
},
|
|
98
428
|
get PACKAGE_JSON() {
|
|
99
429
|
return JSON.parse(readFileSync(`${BUNDLER.ROOT_PATH}/package.json`, "utf8"));
|
|
@@ -262,7 +592,7 @@ var cleanDirectory = async (dirs) => {
|
|
|
262
592
|
};
|
|
263
593
|
|
|
264
594
|
// lib/commands/build/modules/config/utils.ts
|
|
265
|
-
import { join as join4, basename, dirname, extname, resolve as
|
|
595
|
+
import { join as join4, basename, dirname, extname, resolve as resolve3 } from "path";
|
|
266
596
|
var generateTimestamp = () => {
|
|
267
597
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
268
598
|
};
|
|
@@ -278,7 +608,7 @@ var createPathEntriesMap = async ({
|
|
|
278
608
|
const base = basename(entryPath, extname(entryPath));
|
|
279
609
|
const dir = dirname(entryPath);
|
|
280
610
|
const tempFileName = `azion-${base}-${timestamp}.temp.${ext}`;
|
|
281
|
-
const tempPath =
|
|
611
|
+
const tempPath = resolve3(dir, tempFileName);
|
|
282
612
|
const finalExt = bundler === "webpack" ? ".js" : "";
|
|
283
613
|
const devSuffix = production ? "" : ".dev";
|
|
284
614
|
let finalPath;
|
|
@@ -751,14 +1081,15 @@ addEventListener('firewall', (event) => {
|
|
|
751
1081
|
await firewallHandler(request, env, ctx);
|
|
752
1082
|
})().catch(console.error);
|
|
753
1083
|
});`,
|
|
754
|
-
fetchHandler: `
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
1084
|
+
fetchHandler: (isProduction) => `
|
|
1085
|
+
${isProduction ? "export default module;" : `
|
|
1086
|
+
const fetchHandler = handlers.fetch;
|
|
1087
|
+
addEventListener('fetch', (event) => {${contextSetup}
|
|
758
1088
|
event.respondWith((async () => {
|
|
759
1089
|
return fetchHandler(request, env, ctx);
|
|
760
1090
|
})());
|
|
761
|
-
})
|
|
1091
|
+
});`}
|
|
1092
|
+
`,
|
|
762
1093
|
fallbackHandler: (entrypointPath) => {
|
|
763
1094
|
const baseImport = `
|
|
764
1095
|
import module from '${entrypointPath}';
|
|
@@ -808,7 +1139,7 @@ var detectHandlers = async (entrypointPath) => {
|
|
|
808
1139
|
};
|
|
809
1140
|
}
|
|
810
1141
|
};
|
|
811
|
-
var generateWorkerEventHandler = async (entrypointPath) => {
|
|
1142
|
+
var generateWorkerEventHandler = async (entrypointPath, isProduction) => {
|
|
812
1143
|
const { hasFirewall, hasFetch } = await detectHandlers(entrypointPath);
|
|
813
1144
|
if (!hasFirewall && !hasFetch) {
|
|
814
1145
|
return `// No fetch or firewall handlers found in: ${entrypointPath}
|
|
@@ -819,7 +1150,7 @@ console.warn('No Edge Function handlers found. File will run as-is.');`;
|
|
|
819
1150
|
}
|
|
820
1151
|
const parts = [WORKER_TEMPLATES.baseImport(entrypointPath)];
|
|
821
1152
|
if (hasFirewall) parts.push(WORKER_TEMPLATES.firewallHandler);
|
|
822
|
-
if (hasFetch) parts.push(WORKER_TEMPLATES.fetchHandler);
|
|
1153
|
+
if (hasFetch) parts.push(WORKER_TEMPLATES.fetchHandler(isProduction));
|
|
823
1154
|
return parts.join("\n");
|
|
824
1155
|
};
|
|
825
1156
|
var generateLegacyWrapper = (entrypointPath) => {
|
|
@@ -900,7 +1231,7 @@ var processWorkerCode = async (originalCode, handlerPath, isProduction) => {
|
|
|
900
1231
|
case "serviceWorker":
|
|
901
1232
|
return originalCode;
|
|
902
1233
|
case "ESModules":
|
|
903
|
-
return
|
|
1234
|
+
return await generateWorkerEventHandler(handlerPath, isProduction);
|
|
904
1235
|
case "legacy":
|
|
905
1236
|
feedback2.build.warn(WORKER_MESSAGES.LEGACY_DEPRECATION);
|
|
906
1237
|
return generateLegacyWrapper(handlerPath);
|
|
@@ -1145,23 +1476,23 @@ var checkAndChangeAddEventListener = (eventTarget, newEvent, code, replaceCode =
|
|
|
1145
1476
|
return { matchEvent: matchEvent || firewallFunction, codeChanged };
|
|
1146
1477
|
};
|
|
1147
1478
|
function checkPortAvailability(port) {
|
|
1148
|
-
return new Promise((
|
|
1479
|
+
return new Promise((resolve4) => {
|
|
1149
1480
|
const client = new net.Socket();
|
|
1150
1481
|
client.setTimeout(1e3);
|
|
1151
1482
|
client.on("connect", () => {
|
|
1152
1483
|
client.destroy();
|
|
1153
|
-
|
|
1484
|
+
resolve4(true);
|
|
1154
1485
|
});
|
|
1155
1486
|
client.on("timeout", () => {
|
|
1156
1487
|
client.destroy();
|
|
1157
|
-
|
|
1488
|
+
resolve4(false);
|
|
1158
1489
|
});
|
|
1159
1490
|
client.on("error", (err) => {
|
|
1160
1491
|
client.destroy();
|
|
1161
1492
|
if (err.message.includes("ECONNREFUSED")) {
|
|
1162
|
-
|
|
1493
|
+
resolve4(false);
|
|
1163
1494
|
} else {
|
|
1164
|
-
|
|
1495
|
+
resolve4(true);
|
|
1165
1496
|
}
|
|
1166
1497
|
});
|
|
1167
1498
|
client.connect(port, "127.0.0.1");
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
readAzionConfig,
|
|
8
8
|
writeStore,
|
|
9
9
|
writeUserConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4JJITWIU.js";
|
|
11
11
|
|
|
12
12
|
// lib/commands/dev/command.ts
|
|
13
13
|
async function devCommand({
|
|
@@ -16,7 +16,7 @@ async function devCommand({
|
|
|
16
16
|
skipFrameworkBuild = false
|
|
17
17
|
}) {
|
|
18
18
|
const parsedPort = parseInt(port, 10);
|
|
19
|
-
const { server } = await import("./env-
|
|
19
|
+
const { server } = await import("./env-OBIRN3VT.js");
|
|
20
20
|
const entryPoint = entry || null;
|
|
21
21
|
server(entryPoint, parsedPort, skipFrameworkBuild);
|
|
22
22
|
}
|
package/dist/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
BUNDLER,
|
|
4
4
|
debug,
|
|
5
5
|
executeCleanup
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4JJITWIU.js";
|
|
7
7
|
|
|
8
8
|
// lib/main.ts
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -71,7 +71,7 @@ function startBundler() {
|
|
|
71
71
|
AzionBundler.version(globalThis.bundler.version);
|
|
72
72
|
if (process.argv.length === 2) process.argv.push("build");
|
|
73
73
|
AzionBundler.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 (command, options) => {
|
|
74
|
-
const { storeCommand } = await import("./commands-
|
|
74
|
+
const { storeCommand } = await import("./commands-3CZDZLRU.js");
|
|
75
75
|
await storeCommand({
|
|
76
76
|
command,
|
|
77
77
|
options
|
|
@@ -84,7 +84,7 @@ function startBundler() {
|
|
|
84
84
|
"-w, --worker [boolean]",
|
|
85
85
|
"Indicates that the constructed code inserts its own worker expression. Use --worker or --worker=true to enable, --worker=false to disable"
|
|
86
86
|
).option("-d, --dev", "Build in development mode", false).option("-x, --experimental [boolean]", "Enable experimental features", false).option("--skip-framework-build", "Skip framework build step", false).action(async (options) => {
|
|
87
|
-
const { buildCommand, manifestCommand } = await import("./commands-
|
|
87
|
+
const { buildCommand, manifestCommand } = await import("./commands-3CZDZLRU.js");
|
|
88
88
|
const { dev, experimental, ...buildOptions } = options;
|
|
89
89
|
if (experimental) globalThis.bundler.experimental = true;
|
|
90
90
|
const { config } = await buildCommand({
|
|
@@ -94,13 +94,13 @@ function startBundler() {
|
|
|
94
94
|
await manifestCommand({ action: "generate", config });
|
|
95
95
|
});
|
|
96
96
|
AzionBundler.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", false).option("--skip-framework-build", "Skip framework build step", false).action(async (entry, options) => {
|
|
97
|
-
const { devCommand } = await import("./commands-
|
|
97
|
+
const { devCommand } = await import("./commands-3CZDZLRU.js");
|
|
98
98
|
const { experimental } = options;
|
|
99
99
|
if (experimental) globalThis.bundler.experimental = true;
|
|
100
100
|
await devCommand({ entry, ...options });
|
|
101
101
|
});
|
|
102
102
|
AzionBundler.command("presets <command>").description("Manage presets for Azion projects").argument("[preset]", "Preset name (required for config command)").action(async (command, preset) => {
|
|
103
|
-
const { presetsCommand } = await import("./commands-
|
|
103
|
+
const { presetsCommand } = await import("./commands-3CZDZLRU.js");
|
|
104
104
|
await presetsCommand(command, { preset });
|
|
105
105
|
});
|
|
106
106
|
AzionBundler.command("manifest [action]").description("Manage manifest files for Azion").argument(
|
|
@@ -116,14 +116,14 @@ Examples:
|
|
|
116
116
|
$ ef manifest -e azion.config.js -o .edge
|
|
117
117
|
`
|
|
118
118
|
).action(async (action, options) => {
|
|
119
|
-
const { manifestCommand } = await import("./commands-
|
|
119
|
+
const { manifestCommand } = await import("./commands-3CZDZLRU.js");
|
|
120
120
|
await manifestCommand({
|
|
121
121
|
...options,
|
|
122
122
|
action
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
AzionBundler.command("config <command>").description("Manage azion.config settings").option("-k, --key <key...>", "Property key (e.g., build.preset or edgeApplications[0].name)").option("-v, --value <value...>", "Value to be set").option("-a, --all", "Read or delete entire configuration (for read/delete commands)").action(async (command, options) => {
|
|
126
|
-
const { configCommand } = await import("./commands-
|
|
126
|
+
const { configCommand } = await import("./commands-3CZDZLRU.js");
|
|
127
127
|
await configCommand({
|
|
128
128
|
command,
|
|
129
129
|
options
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-functions",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0-stage.2",
|
|
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
|
"main": "dist/main.js",
|
|
6
6
|
"module": "dist/main.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"e2e:start": "yarn submodule:update && tests/scripts/start-e2e-env.sh",
|
|
26
26
|
"e2e:stop": "tests/scripts/stop-e2e-env.sh",
|
|
27
27
|
"e2e:destroy": "tests/scripts/destroy-e2e-env.sh",
|
|
28
|
-
"test:e2e": "yarn e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --
|
|
29
|
-
"test:nodejs-apis": "yarn e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --
|
|
28
|
+
"test:e2e": "yarn e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles --runInBand --config=./jest-e2e.config.js tests/e2e/ --json --outputFile e2e_results.json && yarn e2e:stop; yarn task:reports",
|
|
29
|
+
"test:nodejs-apis": "yarn e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --runInBand --config=./jest-e2e.config.js tests/nodejs-apis/ --json --outputFile nodejs_apis_results.json && yarn e2e:stop && yarn task:reports-nodejs-apis",
|
|
30
30
|
"prepare": "husky install",
|
|
31
31
|
"submodule:update": "git submodule update --init --recursive && git submodule foreach git pull origin main"
|
|
32
32
|
},
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
],
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@edge-runtime/primitives": "4.0.5",
|
|
45
46
|
"@netlify/framework-info": "^9.9.1",
|
|
46
|
-
"azion": "~1.20.
|
|
47
|
+
"azion": "~1.20.1",
|
|
47
48
|
"chokidar": "^3.5.3",
|
|
48
49
|
"commander": "^10.0.1",
|
|
49
50
|
"cosmiconfig": "^9.0.0",
|
|
@@ -102,5 +103,6 @@
|
|
|
102
103
|
"dist",
|
|
103
104
|
"package.json",
|
|
104
105
|
"README.md"
|
|
105
|
-
]
|
|
106
|
+
],
|
|
107
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
106
108
|
}
|