@netlify/edge-bundler 4.4.1 → 4.4.3

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.
@@ -4,16 +4,12 @@ export const getDeclarationsFromConfig = (tomlDeclarations, functionsConfig) =>
4
4
  const functionsVisited = new Set();
5
5
  // We start by iterating over all the TOML declarations. For any declaration
6
6
  // for which we also have a function configuration object, we replace the
7
- // path because that object takes precedence.
7
+ // defined config (currently path or cache or both) because that object takes
8
+ // precedence.
8
9
  for (const declaration of tomlDeclarations) {
9
- const { path } = (_a = functionsConfig[declaration.function]) !== null && _a !== void 0 ? _a : {};
10
- if (path) {
11
- functionsVisited.add(declaration.function);
12
- declarations.push({ ...declaration, path });
13
- }
14
- else {
15
- declarations.push(declaration);
16
- }
10
+ const config = (_a = functionsConfig[declaration.function]) !== null && _a !== void 0 ? _a : {};
11
+ functionsVisited.add(declaration.function);
12
+ declarations.push({ ...declaration, ...config });
17
13
  }
18
14
  // Finally, we must create declarations for functions that are not declared
19
15
  // in the TOML at all.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { test, expect } from 'vitest';
2
+ import { getDeclarationsFromConfig } from './declaration.js';
3
+ test('In source config takes precedence over netlify.toml config', () => {
4
+ const tomlConfig = [
5
+ { function: 'geolocation', path: '/geo', cache: 'off' },
6
+ { function: 'json', path: '/json', cache: 'manual' },
7
+ ];
8
+ const funcConfig = {
9
+ geolocation: { path: '/geo-isc', cache: 'manual' },
10
+ json: { path: '/json', cache: 'off' },
11
+ };
12
+ const expectedDeclarations = [
13
+ { function: 'geolocation', path: '/geo-isc', cache: 'manual' },
14
+ { function: 'json', path: '/json', cache: 'off' },
15
+ ];
16
+ const declarations = getDeclarationsFromConfig(tomlConfig, funcConfig);
17
+ expect(declarations).toEqual(expectedDeclarations);
18
+ });
19
+ test("Declarations don't break if no in source config is provided", () => {
20
+ const tomlConfig = [
21
+ { function: 'geolocation', path: '/geo', cache: 'off' },
22
+ { function: 'json', path: '/json', cache: 'manual' },
23
+ ];
24
+ const funcConfig = {
25
+ geolocation: { path: '/geo-isc', cache: 'manual' },
26
+ json: {},
27
+ };
28
+ const expectedDeclarations = [
29
+ { function: 'geolocation', path: '/geo-isc', cache: 'manual' },
30
+ { function: 'json', path: '/json', cache: 'manual' },
31
+ ];
32
+ const declarations = getDeclarationsFromConfig(tomlConfig, funcConfig);
33
+ expect(declarations).toEqual(expectedDeclarations);
34
+ });
35
+ test('In source config works independent of the netlify.toml file if a path is defined and otherwise if no path is set', () => {
36
+ const tomlConfig = [{ function: 'geolocation', path: '/geo', cache: 'off' }];
37
+ const funcConfigWithPath = {
38
+ json: { path: '/json', cache: 'off' },
39
+ };
40
+ const funcConfigWithoutPath = {
41
+ json: { cache: 'off' },
42
+ };
43
+ const expectedDeclarationsWithISCPath = [
44
+ { function: 'geolocation', path: '/geo', cache: 'off' },
45
+ { function: 'json', path: '/json', cache: 'off' },
46
+ ];
47
+ const expectedDeclarationsWithoutISCPath = [{ function: 'geolocation', path: '/geo', cache: 'off' }];
48
+ const declarationsWithISCPath = getDeclarationsFromConfig(tomlConfig, funcConfigWithPath);
49
+ const declarationsWithoutISCPath = getDeclarationsFromConfig(tomlConfig, funcConfigWithoutPath);
50
+ expect(declarationsWithISCPath).toEqual(expectedDeclarationsWithISCPath);
51
+ expect(declarationsWithoutISCPath).toEqual(expectedDeclarationsWithoutISCPath);
52
+ });
@@ -7,7 +7,7 @@ import { BundleFormat } from '../bundle.js';
7
7
  import { wrapBundleError } from '../bundle_error.js';
8
8
  import { wrapNpmImportError } from '../npm_import_error.js';
9
9
  import { getFileHash } from '../utils/sha256.js';
10
- const BOOTSTRAP_LATEST = 'https://637b7052e167bb00082f54f1--edge.netlify.com/bootstrap/index-combined.ts';
10
+ const BOOTSTRAP_LATEST = 'https://637cf7ce9214b300099b3aa8--edge.netlify.com/bootstrap/index-combined.ts';
11
11
  const bundleJS = async ({ buildID, debug, deno, distDirectory, functions, importMap, }) => {
12
12
  const stage2Path = await generateStage2({ distDirectory, functions, fileName: `${buildID}-pre.js` });
13
13
  const extension = '.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "4.4.1",
3
+ "version": "4.4.3",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",