@netlify/edge-bundler 2.4.0 → 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 DeclarationWithPath {
2
+ interface BaseDeclaration {
3
3
  function: string;
4
- path: string;
4
+ name?: string;
5
5
  }
6
- interface DeclarationWithPattern {
7
- function: string;
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 };
@@ -14,6 +14,7 @@ interface Manifest {
14
14
  }[];
15
15
  routes: {
16
16
  function: string;
17
+ name?: string;
17
18
  pattern: string;
18
19
  }[];
19
20
  }
@@ -13,6 +13,7 @@ const generateManifest = ({ bundles = [], declarations = [], functions }) => {
13
13
  const serializablePattern = pattern.source.replace(/\\\//g, '/');
14
14
  return {
15
15
  function: func.name,
16
+ name: declaration.name,
16
17
  pattern: serializablePattern,
17
18
  };
18
19
  });
@@ -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',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",