@netlify/edge-bundler 2.3.1 → 2.5.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.
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { FunctionConfig } from './config.js';
|
|
2
|
-
interface
|
|
2
|
+
interface BaseDeclaration {
|
|
3
3
|
function: string;
|
|
4
|
-
|
|
4
|
+
name?: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
declare type DeclarationWithPath = BaseDeclaration & {
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
declare type DeclarationWithPattern = BaseDeclaration & {
|
|
8
10
|
pattern: string;
|
|
9
|
-
}
|
|
11
|
+
};
|
|
10
12
|
declare type Declaration = DeclarationWithPath | DeclarationWithPattern;
|
|
11
13
|
export declare const getDeclarationsFromConfig: (tomlDeclarations: Declaration[], functionsConfig: Record<string, FunctionConfig>) => Declaration[];
|
|
12
14
|
export { Declaration, DeclarationWithPath, DeclarationWithPattern };
|
|
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'url';
|
|
|
5
5
|
import del from 'del';
|
|
6
6
|
import { wrapBundleError } from '../bundle_error.js';
|
|
7
7
|
import { getFileHash } from '../utils/sha256.js';
|
|
8
|
-
const BOOTSTRAP_LATEST = 'https://
|
|
8
|
+
const BOOTSTRAP_LATEST = 'https://6335ada772145800075958c3--edge.netlify.com/bootstrap/index-combined.ts';
|
|
9
9
|
const bundleJS = async ({ buildID, debug, deno, distDirectory, functions, importMap, }) => {
|
|
10
10
|
const stage2Path = await generateStage2({ distDirectory, functions, fileName: `${buildID}-pre.js` });
|
|
11
11
|
const extension = '.js';
|
|
@@ -51,7 +51,7 @@ const getLocalEntryPoint = (functions, { formatExportTypeError = defaultFormatEx
|
|
|
51
51
|
return `
|
|
52
52
|
try {
|
|
53
53
|
const { default: func } = await import("${url}");
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
if (typeof func === "function") {
|
|
56
56
|
functions["${func.name}"] = func;
|
|
57
57
|
metadata.functions["${func.name}"] = ${JSON.stringify(metadata)}
|
package/dist/node/manifest.d.ts
CHANGED
package/dist/node/manifest.js
CHANGED
|
@@ -24,6 +24,23 @@ test('Generates a manifest with different bundles', () => {
|
|
|
24
24
|
expect(manifest.routes).toEqual(expectedRoutes);
|
|
25
25
|
expect(manifest.bundler_version).toBe(env.npm_package_version);
|
|
26
26
|
});
|
|
27
|
+
test('Generates a manifest with display names', () => {
|
|
28
|
+
const functions = [
|
|
29
|
+
{ name: 'func-1', path: '/path/to/func-1.ts' },
|
|
30
|
+
{ name: 'func-2', path: '/path/to/func-2.ts' },
|
|
31
|
+
];
|
|
32
|
+
const declarations = [
|
|
33
|
+
{ function: 'func-1', name: 'Display Name', path: '/f1/*' },
|
|
34
|
+
{ function: 'func-2', path: '/f2/*' },
|
|
35
|
+
];
|
|
36
|
+
const manifest = generateManifest({ bundles: [], declarations, functions });
|
|
37
|
+
const expectedRoutes = [
|
|
38
|
+
{ function: 'func-1', name: 'Display Name', pattern: '^/f1/.*/?$' },
|
|
39
|
+
{ function: 'func-2', pattern: '^/f2/.*/?$' },
|
|
40
|
+
];
|
|
41
|
+
expect(manifest.routes).toEqual(expectedRoutes);
|
|
42
|
+
expect(manifest.bundler_version).toBe(env.npm_package_version);
|
|
43
|
+
});
|
|
27
44
|
test('Excludes functions for which there are function files but no matching config declarations', () => {
|
|
28
45
|
const bundle1 = {
|
|
29
46
|
extension: '.ext2',
|