edge-functions 6.0.0-stage.1 → 6.0.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
CHANGED
|
@@ -356,43 +356,43 @@ E2E tests run daily in the [Bundler Examples](https://github.com/aziontech/bundl
|
|
|
356
356
|
Table:
|
|
357
357
|
| Test | Status |
|
|
358
358
|
| ------------------------------------ | ------ |
|
|
359
|
-
| Next 14 2 15 Middleware |
|
|
360
|
-
| Next 13 5 6 I18n |
|
|
361
|
-
| Next 12 3 4 I18n |
|
|
362
|
-
| Hexo Static |
|
|
363
|
-
| Next 13 5 6 Middleware |
|
|
364
|
-
| Next 12 3 4 Middleware |
|
|
365
|
-
| Next Node Pages 12 3 1 |
|
|
366
|
-
| Next 13 5 6 Config |
|
|
367
|
-
| Next 12 3 4 Config |
|
|
368
|
-
| Next Static |
|
|
369
|
-
| Gatsby Static |
|
|
370
|
-
| Next Node Pages 12 3 1 Fs |
|
|
371
|
-
| Vue Vite Static |
|
|
372
|
-
| Next 12 Static |
|
|
373
|
-
| Astro Static |
|
|
374
|
-
| Qwik Static |
|
|
375
|
-
| Simple Js Env Vars |
|
|
376
|
-
| Eleventy Static |
|
|
377
|
-
| Simple Js Network List |
|
|
378
|
-
| Angular Static |
|
|
379
|
-
| React Static |
|
|
380
|
-
| Svelte Static |
|
|
381
|
-
| Stencil Static |
|
|
382
|
-
| Vitepress Static |
|
|
383
|
-
| Preact Static |
|
|
384
|
-
| Vuepress Static |
|
|
385
|
-
| Nuxt Static |
|
|
386
|
-
| Docusaurus Static |
|
|
387
|
-
| Simple Js Firewall Event |
|
|
388
|
-
| Simple Js Network List With Firewall |
|
|
389
|
-
| Jekyll Static |
|
|
390
|
-
| Simple Js Esm Worker |
|
|
391
|
-
| Simple Js Esm Node |
|
|
392
|
-
| Simple Ts Esm |
|
|
393
|
-
| Simple Js Esm |
|
|
394
|
-
|
|
395
|
-
Last test run date:
|
|
359
|
+
| Next 14 2 15 Middleware | ⚠️ |
|
|
360
|
+
| Next 13 5 6 I18n | ⚠️ |
|
|
361
|
+
| Next 12 3 4 I18n | ⚠️ |
|
|
362
|
+
| Hexo Static | ⚠️ |
|
|
363
|
+
| Next 13 5 6 Middleware | ⚠️ |
|
|
364
|
+
| Next 12 3 4 Middleware | ⚠️ |
|
|
365
|
+
| Next Node Pages 12 3 1 | ⚠️ |
|
|
366
|
+
| Next 13 5 6 Config | ⚠️ |
|
|
367
|
+
| Next 12 3 4 Config | ⚠️ |
|
|
368
|
+
| Next Static | ⚠️ |
|
|
369
|
+
| Gatsby Static | ⚠️ |
|
|
370
|
+
| Next Node Pages 12 3 1 Fs | ⚠️ |
|
|
371
|
+
| Vue Vite Static | ⚠️ |
|
|
372
|
+
| Next 12 Static | ⚠️ |
|
|
373
|
+
| Astro Static | ⚠️ |
|
|
374
|
+
| Qwik Static | ⚠️ |
|
|
375
|
+
| Simple Js Env Vars | ⚠️ |
|
|
376
|
+
| Eleventy Static | ⚠️ |
|
|
377
|
+
| Simple Js Network List | ⚠️ |
|
|
378
|
+
| Angular Static | ⚠️ |
|
|
379
|
+
| React Static | ⚠️ |
|
|
380
|
+
| Svelte Static | ⚠️ |
|
|
381
|
+
| Stencil Static | ⚠️ |
|
|
382
|
+
| Vitepress Static | ⚠️ |
|
|
383
|
+
| Preact Static | ⚠️ |
|
|
384
|
+
| Vuepress Static | ⚠️ |
|
|
385
|
+
| Nuxt Static | ⚠️ |
|
|
386
|
+
| Docusaurus Static | ⚠️ |
|
|
387
|
+
| Simple Js Firewall Event | ⚠️ |
|
|
388
|
+
| Simple Js Network List With Firewall | ⚠️ |
|
|
389
|
+
| Jekyll Static | ⚠️ |
|
|
390
|
+
| Simple Js Esm Worker | ⚠️ |
|
|
391
|
+
| Simple Js Esm Node | ⚠️ |
|
|
392
|
+
| Simple Ts Esm | ⚠️ |
|
|
393
|
+
| Simple Js Esm | ⚠️ |
|
|
394
|
+
|
|
395
|
+
Last test run date: 08/19/25 03:14:09 AM
|
|
396
396
|
|
|
397
397
|
## Contributing
|
|
398
398
|
|
|
@@ -1408,11 +1408,6 @@ var injectBindingsIntoFile = async (func, bucketsSetup, isProduction) => {
|
|
|
1408
1408
|
`No prefix provided for binding in function '${func.name}', using storage prefix: ${prefix}`
|
|
1409
1409
|
);
|
|
1410
1410
|
}
|
|
1411
|
-
if (bindingPrefix) {
|
|
1412
|
-
feedback4.postbuild.info(
|
|
1413
|
-
`Using provided prefix for binding in function '${func.name}': ${prefix}`
|
|
1414
|
-
);
|
|
1415
|
-
}
|
|
1416
1411
|
const bindingTemplate = createStorageBindingTemplate({
|
|
1417
1412
|
bucket: bucketName,
|
|
1418
1413
|
prefix
|
|
@@ -1494,10 +1489,38 @@ var createStorageSymlink = async (storage, sourceDir, targetDir, prefix) => {
|
|
|
1494
1489
|
const targetPath = path3.join(targetDir, storageName, prefix);
|
|
1495
1490
|
await fsPromises6.mkdir(path3.join(targetDir, storageName), { recursive: true });
|
|
1496
1491
|
try {
|
|
1497
|
-
await fsPromises6.
|
|
1498
|
-
|
|
1492
|
+
const folders = await fsPromises6.readdir(path3.join(targetDir, storageName));
|
|
1493
|
+
await Promise.all(
|
|
1494
|
+
folders.filter((folder) => folder !== prefix).map(async (folder) => {
|
|
1495
|
+
const folderPath = path3.join(targetDir, storageName, folder);
|
|
1496
|
+
try {
|
|
1497
|
+
const stats = await fsPromises6.lstat(folderPath);
|
|
1498
|
+
if (stats.isSymbolicLink()) {
|
|
1499
|
+
await fsPromises6.unlink(folderPath);
|
|
1500
|
+
} else if (stats.isDirectory()) {
|
|
1501
|
+
await fsPromises6.rmdir(folderPath, { recursive: true });
|
|
1502
|
+
} else {
|
|
1503
|
+
await fsPromises6.unlink(folderPath);
|
|
1504
|
+
}
|
|
1505
|
+
} catch (err) {
|
|
1506
|
+
debug.warn(`Failed to remove ${folderPath}:`, err);
|
|
1507
|
+
}
|
|
1508
|
+
})
|
|
1509
|
+
);
|
|
1510
|
+
debug.info(`Cleaned up existing storage items in: ${path3.join(targetDir, storageName)}`);
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
debug.warn(`Storage directory not found or empty: ${path3.join(targetDir, storageName)}`);
|
|
1513
|
+
}
|
|
1514
|
+
try {
|
|
1515
|
+
const stats = await fsPromises6.lstat(targetPath);
|
|
1516
|
+
if (stats.isSymbolicLink()) {
|
|
1517
|
+
await fsPromises6.unlink(targetPath);
|
|
1518
|
+
debug.info(`Removed existing symlink: ${targetPath}`);
|
|
1519
|
+
} else if (stats.isDirectory()) {
|
|
1520
|
+
await fsPromises6.rmdir(targetPath, { recursive: true });
|
|
1521
|
+
debug.info(`Removed existing directory: ${targetPath}`);
|
|
1522
|
+
}
|
|
1499
1523
|
} catch (error) {
|
|
1500
|
-
debug.warn(`Storage link not found: ${targetPath}`);
|
|
1501
1524
|
}
|
|
1502
1525
|
await fsPromises6.symlink(sourceDir, targetPath, "dir");
|
|
1503
1526
|
debug.info(`Storage link created: ${storageName} -> ${sourceDir}`);
|
|
@@ -1542,8 +1565,6 @@ var setupStorage = async ({ config }) => {
|
|
|
1542
1565
|
}
|
|
1543
1566
|
const providedPrefix = storage.prefix;
|
|
1544
1567
|
const prefix = providedPrefix || generateTimestampPrefix();
|
|
1545
|
-
globalThis.AZION_BUCKET_NAME = storage.name;
|
|
1546
|
-
globalThis.AZION_BUCKET_PREFIX = prefix;
|
|
1547
1568
|
if (!providedPrefix) {
|
|
1548
1569
|
feedback5.storage.info(
|
|
1549
1570
|
`No prefix provided for storage '${storage.name}', generating version prefix: ${prefix}`
|
|
@@ -1777,7 +1798,8 @@ async function initializeServer(port, workerCode) {
|
|
|
1777
1798
|
}
|
|
1778
1799
|
function setCurrentBucketName(edgeFunction, config) {
|
|
1779
1800
|
const bucketName = edgeFunction?.bindings?.storage?.bucket || config?.edgeStorage?.[0].name || "";
|
|
1780
|
-
|
|
1801
|
+
const prefix = edgeFunction?.bindings?.storage?.prefix || config?.edgeStorage?.[0].prefix || "";
|
|
1802
|
+
return { bucketName, prefix };
|
|
1781
1803
|
}
|
|
1782
1804
|
function findEntryPathForFunction(entries, functionName, targetFunctionPath) {
|
|
1783
1805
|
const entryPath = Object.keys(entries).find((key) => {
|
|
@@ -1802,18 +1824,21 @@ function defineCurrentFunction(entries, config, functionName) {
|
|
|
1802
1824
|
throw new Error(`Function "${functionName}" not found in edge functions configuration`);
|
|
1803
1825
|
}
|
|
1804
1826
|
const entryPath2 = findEntryPathForFunction(entries, functionName, targetFunction.path);
|
|
1827
|
+
const bucketName2 = setCurrentBucketName(targetFunction, config);
|
|
1805
1828
|
return {
|
|
1806
1829
|
name: targetFunction.name,
|
|
1807
|
-
|
|
1830
|
+
bucket: bucketName2.bucketName,
|
|
1831
|
+
prefix: bucketName2.prefix,
|
|
1808
1832
|
path: normalizePathExtension(entryPath2)
|
|
1809
1833
|
};
|
|
1810
1834
|
}
|
|
1811
1835
|
const entryPath = Object.keys(entries)[0];
|
|
1812
1836
|
const defaultFunction = config.edgeFunctions?.[0];
|
|
1813
|
-
const bucketName = setCurrentBucketName(defaultFunction);
|
|
1837
|
+
const bucketName = setCurrentBucketName(defaultFunction, config);
|
|
1814
1838
|
return {
|
|
1815
1839
|
name: defaultFunction?.name,
|
|
1816
|
-
bucket: bucketName,
|
|
1840
|
+
bucket: bucketName.bucketName,
|
|
1841
|
+
prefix: bucketName.prefix,
|
|
1817
1842
|
path: normalizePathExtension(entryPath)
|
|
1818
1843
|
};
|
|
1819
1844
|
}
|
|
@@ -1824,11 +1849,17 @@ async function manageServer(workerPath, port, skipFrameworkBuild = false, functi
|
|
|
1824
1849
|
}
|
|
1825
1850
|
const {
|
|
1826
1851
|
setup: { entry },
|
|
1827
|
-
config: { edgeFunctions }
|
|
1852
|
+
config: { edgeFunctions, edgeStorage }
|
|
1828
1853
|
} = await buildCommand({ production: false, skipFrameworkBuild });
|
|
1829
1854
|
let workerCode;
|
|
1830
1855
|
try {
|
|
1831
|
-
const {
|
|
1856
|
+
const {
|
|
1857
|
+
path: finalPath,
|
|
1858
|
+
bucket,
|
|
1859
|
+
prefix
|
|
1860
|
+
} = defineCurrentFunction(entry, { edgeFunctions, edgeStorage }, functionName);
|
|
1861
|
+
globalThis.AZION_BUCKET_NAME = bucket;
|
|
1862
|
+
globalThis.AZION_BUCKET_PREFIX = prefix;
|
|
1832
1863
|
workerCode = await readWorkerFile(finalPath);
|
|
1833
1864
|
} catch (error) {
|
|
1834
1865
|
feedback7.server.error(error.message);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
readAzionConfig,
|
|
8
8
|
writeStore,
|
|
9
9
|
writeUserConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IHOEJARI.js";
|
|
11
11
|
|
|
12
12
|
// lib/commands/dev/command.ts
|
|
13
13
|
async function devCommand({
|
|
@@ -17,7 +17,7 @@ async function devCommand({
|
|
|
17
17
|
functionName
|
|
18
18
|
}) {
|
|
19
19
|
const parsedPort = parseInt(port, 10);
|
|
20
|
-
const { server } = await import("./env-
|
|
20
|
+
const { server } = await import("./env-TY2DPD5S.js");
|
|
21
21
|
const entryPoint = entry || null;
|
|
22
22
|
server(entryPoint, parsedPort, skipFrameworkBuild, functionName);
|
|
23
23
|
}
|
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-IHOEJARI.js";
|
|
7
7
|
|
|
8
8
|
// lib/main.ts
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -70,7 +70,7 @@ function setupBundlerProcessHandlers() {
|
|
|
70
70
|
function startBundler() {
|
|
71
71
|
AzionBundler.version(globalThis.bundler.version);
|
|
72
72
|
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) => {
|
|
73
|
-
const { storeCommand } = await import("./commands-
|
|
73
|
+
const { storeCommand } = await import("./commands-YEJQLZ4H.js");
|
|
74
74
|
await storeCommand({
|
|
75
75
|
command,
|
|
76
76
|
options
|
|
@@ -92,7 +92,7 @@ Examples:
|
|
|
92
92
|
$ ef build --preset opennextjs --skip-framework-build
|
|
93
93
|
`
|
|
94
94
|
).action(async (options) => {
|
|
95
|
-
const { buildCommand, manifestCommand } = await import("./commands-
|
|
95
|
+
const { buildCommand, manifestCommand } = await import("./commands-YEJQLZ4H.js");
|
|
96
96
|
const { dev, experimental, ...buildOptions } = options;
|
|
97
97
|
if (experimental) globalThis.bundler.experimental = true;
|
|
98
98
|
const { config } = await buildCommand({
|
|
@@ -102,13 +102,13 @@ Examples:
|
|
|
102
102
|
await manifestCommand({ action: "generate", config });
|
|
103
103
|
});
|
|
104
104
|
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).option("--function-name <name>", "Specify the function name").action(async (entry, options) => {
|
|
105
|
-
const { devCommand } = await import("./commands-
|
|
105
|
+
const { devCommand } = await import("./commands-YEJQLZ4H.js");
|
|
106
106
|
const { experimental } = options;
|
|
107
107
|
if (experimental) globalThis.bundler.experimental = true;
|
|
108
108
|
await devCommand({ entry, ...options });
|
|
109
109
|
});
|
|
110
110
|
AzionBundler.command("presets <command>").description("Manage presets for Azion projects").argument("[preset]", "Preset name (required for config command)").action(async (command, preset) => {
|
|
111
|
-
const { presetsCommand } = await import("./commands-
|
|
111
|
+
const { presetsCommand } = await import("./commands-YEJQLZ4H.js");
|
|
112
112
|
await presetsCommand(command, { preset });
|
|
113
113
|
});
|
|
114
114
|
AzionBundler.command("manifest [action]").description("Manage manifest files for Azion").argument(
|
|
@@ -124,7 +124,7 @@ Examples:
|
|
|
124
124
|
$ ef manifest -e azion.config.js -o .edge
|
|
125
125
|
`
|
|
126
126
|
).action(async (action, options) => {
|
|
127
|
-
const { manifestCommand } = await import("./commands-
|
|
127
|
+
const { manifestCommand } = await import("./commands-YEJQLZ4H.js");
|
|
128
128
|
await manifestCommand({
|
|
129
129
|
...options,
|
|
130
130
|
action
|
|
@@ -143,7 +143,7 @@ Examples:
|
|
|
143
143
|
$ ef config replace -k '$EDGE_FUNCTION_NAME' -v "my-func"
|
|
144
144
|
`
|
|
145
145
|
).action(async (command, options) => {
|
|
146
|
-
const { configCommand } = await import("./commands-
|
|
146
|
+
const { configCommand } = await import("./commands-YEJQLZ4H.js");
|
|
147
147
|
await configCommand({
|
|
148
148
|
command,
|
|
149
149
|
options
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-functions",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@edge-runtime/primitives": "4.0.5",
|
|
46
46
|
"@netlify/framework-info": "^9.9.1",
|
|
47
|
-
"azion": "~2.0.0
|
|
47
|
+
"azion": "~2.0.0",
|
|
48
48
|
"chokidar": "^3.5.3",
|
|
49
49
|
"commander": "^10.0.1",
|
|
50
50
|
"cosmiconfig": "^9.0.0",
|