@netlify/edge-bundler 8.13.0 → 8.13.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.
Files changed (34) hide show
  1. package/deno/lib/common.ts +3 -3
  2. package/deno/lib/stage2.ts +2 -2
  3. package/deno/vendor/deno.land/x/{eszip@v0.37.0 → eszip@v0.40.0}/eszip_wasm.generated.js +61 -59
  4. package/deno/vendor/deno.land/x/eszip@v0.40.0/eszip_wasm_bg.wasm +0 -0
  5. package/dist/node/bundler.js +1 -1
  6. package/dist/node/declaration.d.ts +2 -1
  7. package/dist/node/declaration.js +39 -12
  8. package/dist/node/declaration.test.js +33 -8
  9. package/dist/node/feature_flags.d.ts +2 -2
  10. package/dist/node/feature_flags.js +1 -1
  11. package/dist/node/finder.d.ts +1 -0
  12. package/dist/node/finder.js +19 -7
  13. package/dist/node/finder.test.d.ts +1 -0
  14. package/dist/node/finder.test.js +17 -0
  15. package/dist/node/validation/manifest/index.d.ts +1 -1
  16. package/dist/node/validation/manifest/index.js +5 -4
  17. package/dist/node/validation/manifest/index.test.js +5 -22
  18. package/dist/node/validation/manifest/schema.js +2 -2
  19. package/dist/test/util.js +1 -1
  20. package/package.json +4 -4
  21. package/deno/vendor/deno.land/x/eszip@v0.37.0/eszip_wasm_bg.wasm +0 -0
  22. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/_util/asserts.ts +0 -0
  23. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/_util/os.ts +0 -0
  24. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/_constants.ts +0 -0
  25. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/_interface.ts +0 -0
  26. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/_util.ts +0 -0
  27. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/common.ts +0 -0
  28. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/glob.ts +0 -0
  29. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/mod.ts +0 -0
  30. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/posix.ts +0 -0
  31. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/separator.ts +0 -0
  32. /package/deno/vendor/deno.land/{std@0.178.0 → std@0.177.0}/path/win32.ts +0 -0
  33. /package/deno/vendor/deno.land/x/{eszip@v0.37.0 → eszip@v0.40.0}/loader.ts +0 -0
  34. /package/deno/vendor/deno.land/x/{eszip@v0.37.0 → eszip@v0.40.0}/mod.ts +0 -0
@@ -1,6 +1,6 @@
1
- import { load } from "https://deno.land/x/eszip@v0.37.0/loader.ts";
2
- import { LoadResponse } from "https://deno.land/x/eszip@v0.37.0/mod.ts";
3
- import * as path from "https://deno.land/std@0.178.0/path/mod.ts";
1
+ import { load } from "https://deno.land/x/eszip@v0.40.0/loader.ts";
2
+ import { LoadResponse } from "https://deno.land/x/eszip@v0.40.0/mod.ts";
3
+ import * as path from "https://deno.land/std@0.177.0/path/mod.ts";
4
4
  import { retryAsync } from "https://deno.land/x/retry@v2.0.0/mod.ts";
5
5
  import { isTooManyTries } from "https://deno.land/x/retry@v2.0.0/retry/tooManyTries.ts";
6
6
 
@@ -1,6 +1,6 @@
1
- import { build, LoadResponse } from 'https://deno.land/x/eszip@v0.37.0/mod.ts'
1
+ import { build, LoadResponse } from 'https://deno.land/x/eszip@v0.40.0/mod.ts'
2
2
 
3
- import * as path from 'https://deno.land/std@0.178.0/path/mod.ts'
3
+ import * as path from 'https://deno.land/std@0.177.0/path/mod.ts'
4
4
 
5
5
  import type { InputFunction, WriteStage2Options } from '../../shared/stage2.ts'
6
6
  import { importMapSpecifier, virtualRoot } from '../../shared/consts.ts'
@@ -1,10 +1,10 @@
1
1
  // @generated file from wasmbuild -- do not edit
2
2
  // deno-lint-ignore-file
3
3
  // deno-fmt-ignore-file
4
- // source-hash: 89edd81d716c7387c15968a0de6fbb8736997e92
4
+ // source-hash: bd411f63844f927a64e51f4af9e1e9b07bb6f88b
5
5
  let wasm;
6
6
 
7
- const heap = new Array(32).fill(undefined);
7
+ const heap = new Array(128).fill(undefined);
8
8
 
9
9
  heap.push(undefined, null, true, false);
10
10
 
@@ -16,19 +16,19 @@ function isLikeNone(x) {
16
16
  return x === undefined || x === null;
17
17
  }
18
18
 
19
- let cachedFloat64Memory0 = new Float64Array();
19
+ let cachedFloat64Memory0 = null;
20
20
 
21
21
  function getFloat64Memory0() {
22
- if (cachedFloat64Memory0.byteLength === 0) {
22
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
23
23
  cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
24
24
  }
25
25
  return cachedFloat64Memory0;
26
26
  }
27
27
 
28
- let cachedInt32Memory0 = new Int32Array();
28
+ let cachedInt32Memory0 = null;
29
29
 
30
30
  function getInt32Memory0() {
31
- if (cachedInt32Memory0.byteLength === 0) {
31
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
32
32
  cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
33
33
  }
34
34
  return cachedInt32Memory0;
@@ -36,10 +36,10 @@ function getInt32Memory0() {
36
36
 
37
37
  let WASM_VECTOR_LEN = 0;
38
38
 
39
- let cachedUint8Memory0 = new Uint8Array();
39
+ let cachedUint8Memory0 = null;
40
40
 
41
41
  function getUint8Memory0() {
42
- if (cachedUint8Memory0.byteLength === 0) {
42
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
43
43
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
44
44
  }
45
45
  return cachedUint8Memory0;
@@ -111,7 +111,7 @@ function getStringFromWasm0(ptr, len) {
111
111
  }
112
112
 
113
113
  function dropObject(idx) {
114
- if (idx < 36) return;
114
+ if (idx < 132) return;
115
115
  heap[idx] = heap_next;
116
116
  heap_next = idx;
117
117
  }
@@ -122,10 +122,12 @@ function takeObject(idx) {
122
122
  return ret;
123
123
  }
124
124
 
125
- let cachedBigInt64Memory0 = new BigInt64Array();
125
+ let cachedBigInt64Memory0 = null;
126
126
 
127
127
  function getBigInt64Memory0() {
128
- if (cachedBigInt64Memory0.byteLength === 0) {
128
+ if (
129
+ cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0
130
+ ) {
129
131
  cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
130
132
  }
131
133
  return cachedBigInt64Memory0;
@@ -226,7 +228,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
226
228
  }
227
229
  function __wbg_adapter_40(arg0, arg1, arg2) {
228
230
  wasm
229
- ._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdb89611f6af59487(
231
+ ._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9728315a111a4c15(
230
232
  arg0,
231
233
  arg1,
232
234
  addHeapObject(arg2),
@@ -263,7 +265,7 @@ function handleError(f, args) {
263
265
  }
264
266
  }
265
267
  function __wbg_adapter_98(arg0, arg1, arg2, arg3) {
266
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h73ff6ec860ceda5d(
268
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h8467648828c8f7b6(
267
269
  arg0,
268
270
  arg1,
269
271
  addHeapObject(arg2),
@@ -407,23 +409,11 @@ const imports = {
407
409
  const ret = BigInt.asUintN(64, arg0);
408
410
  return addHeapObject(ret);
409
411
  },
410
- __wbg_new_1d9a920c6bfc44a8: function () {
411
- const ret = new Array();
412
- return addHeapObject(ret);
413
- },
414
- __wbindgen_string_new: function (arg0, arg1) {
415
- const ret = getStringFromWasm0(arg0, arg1);
416
- return addHeapObject(ret);
417
- },
418
- __wbg_push_740e4b286702d964: function (arg0, arg1) {
419
- const ret = getObject(arg0).push(getObject(arg1));
420
- return ret;
421
- },
422
- __wbg_length_6e3bbe7c8bd4dbd8: function (arg0) {
412
+ __wbg_length_e498fbc24f9c1d4f: function (arg0) {
423
413
  const ret = getObject(arg0).length;
424
414
  return ret;
425
415
  },
426
- __wbg_new_8d2af00bc1e329ee: function (arg0, arg1) {
416
+ __wbg_new_15d3966e9981a196: function (arg0, arg1) {
427
417
  const ret = new Error(getStringFromWasm0(arg0, arg1));
428
418
  return addHeapObject(ret);
429
419
  },
@@ -431,11 +421,11 @@ const imports = {
431
421
  const ret = wasm.memory;
432
422
  return addHeapObject(ret);
433
423
  },
434
- __wbg_buffer_3f3d764d4747d564: function (arg0) {
424
+ __wbg_buffer_cf65c07de34b9a08: function (arg0) {
435
425
  const ret = getObject(arg0).buffer;
436
426
  return addHeapObject(ret);
437
427
  },
438
- __wbg_newwithbyteoffsetandlength_d9aa266703cb98be: function (
428
+ __wbg_newwithbyteoffsetandlength_9fb2f11355ecadf5: function (
439
429
  arg0,
440
430
  arg1,
441
431
  arg2,
@@ -443,11 +433,23 @@ const imports = {
443
433
  const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
444
434
  return addHeapObject(ret);
445
435
  },
446
- __wbg_new_8c3f0052272a457a: function (arg0) {
436
+ __wbg_new_537b7341ce90bb31: function (arg0) {
447
437
  const ret = new Uint8Array(getObject(arg0));
448
438
  return addHeapObject(ret);
449
439
  },
450
- __wbg_String_91fba7ded13ba54c: function (arg0, arg1) {
440
+ __wbg_new_b525de17f44a8943: function () {
441
+ const ret = new Array();
442
+ return addHeapObject(ret);
443
+ },
444
+ __wbindgen_string_new: function (arg0, arg1) {
445
+ const ret = getStringFromWasm0(arg0, arg1);
446
+ return addHeapObject(ret);
447
+ },
448
+ __wbg_push_49c286f04dd3bf59: function (arg0, arg1) {
449
+ const ret = getObject(arg0).push(getObject(arg1));
450
+ return ret;
451
+ },
452
+ __wbg_String_88810dfeb4021902: function (arg0, arg1) {
451
453
  const ret = String(getObject(arg1));
452
454
  const ptr0 = passStringToWasm0(
453
455
  ret,
@@ -466,15 +468,15 @@ const imports = {
466
468
  const ret = new Error(getStringFromWasm0(arg0, arg1));
467
469
  return addHeapObject(ret);
468
470
  },
469
- __wbg_iterator_6f9d4f28845f426c: function () {
471
+ __wbg_iterator_55f114446221aa5a: function () {
470
472
  const ret = Symbol.iterator;
471
473
  return addHeapObject(ret);
472
474
  },
473
- __wbg_newwithlength_f5933855e4f48a19: function (arg0) {
475
+ __wbg_newwithlength_b56c882b57805732: function (arg0) {
474
476
  const ret = new Uint8Array(arg0 >>> 0);
475
477
  return addHeapObject(ret);
476
478
  },
477
- __wbg_read_1bddf8e8af59d1d6: function (arg0, arg1) {
479
+ __wbg_read_43a845bca3122d77: function (arg0, arg1) {
478
480
  const ret = getObject(arg0).read(getObject(arg1));
479
481
  return addHeapObject(ret);
480
482
  },
@@ -482,7 +484,7 @@ const imports = {
482
484
  const ret = getObject(arg0).done;
483
485
  return ret;
484
486
  },
485
- __wbg_toString_7be108a12ef03bc2: function (arg0) {
487
+ __wbg_toString_8c529acfe543ce16: function (arg0) {
486
488
  const ret = getObject(arg0).toString();
487
489
  return addHeapObject(ret);
488
490
  },
@@ -490,15 +492,15 @@ const imports = {
490
492
  const ret = getObject(arg0).value;
491
493
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
492
494
  },
493
- __wbg_byteLength_87a0436a74adc26c: function (arg0) {
495
+ __wbg_byteLength_29d6f6f493852fd4: function (arg0) {
494
496
  const ret = getObject(arg0).byteLength;
495
497
  return ret;
496
498
  },
497
- __wbg_length_9e1ae1900cb0fbd5: function (arg0) {
499
+ __wbg_length_27a2afe8ab42b09f: function (arg0) {
498
500
  const ret = getObject(arg0).length;
499
501
  return ret;
500
502
  },
501
- __wbg_call_3999bee59e9f7719: function () {
503
+ __wbg_call_96878afb7a8201ca: function () {
502
504
  return handleError(function (arg0, arg1, arg2, arg3) {
503
505
  const ret = getObject(arg0).call(
504
506
  getObject(arg1),
@@ -508,11 +510,11 @@ const imports = {
508
510
  return addHeapObject(ret);
509
511
  }, arguments);
510
512
  },
511
- __wbg_resolve_99fe17964f31ffc0: function (arg0) {
513
+ __wbg_resolve_fd40f858d9db1a04: function (arg0) {
512
514
  const ret = Promise.resolve(getObject(arg0));
513
515
  return addHeapObject(ret);
514
516
  },
515
- __wbg_new_9962f939219f1820: function (arg0, arg1) {
517
+ __wbg_new_9d3a9ce4282a18a8: function (arg0, arg1) {
516
518
  try {
517
519
  var state0 = { a: arg0, b: arg1 };
518
520
  var cb0 = (arg0, arg1) => {
@@ -559,62 +561,62 @@ const imports = {
559
561
  const ret = typeof (getObject(arg0)) === "function";
560
562
  return ret;
561
563
  },
562
- __wbg_get_57245cc7d7c7619d: function (arg0, arg1) {
564
+ __wbg_get_27fe3dac1c4d0224: function (arg0, arg1) {
563
565
  const ret = getObject(arg0)[arg1 >>> 0];
564
566
  return addHeapObject(ret);
565
567
  },
566
- __wbg_next_aaef7c8aa5e212ac: function () {
568
+ __wbg_next_88560ec06a094dea: function () {
567
569
  return handleError(function (arg0) {
568
570
  const ret = getObject(arg0).next();
569
571
  return addHeapObject(ret);
570
572
  }, arguments);
571
573
  },
572
- __wbg_done_1b73b0672e15f234: function (arg0) {
574
+ __wbg_done_1ebec03bbd919843: function (arg0) {
573
575
  const ret = getObject(arg0).done;
574
576
  return ret;
575
577
  },
576
- __wbg_value_1ccc36bc03462d71: function (arg0) {
578
+ __wbg_value_6ac8da5cc5b3efda: function (arg0) {
577
579
  const ret = getObject(arg0).value;
578
580
  return addHeapObject(ret);
579
581
  },
580
- __wbg_get_765201544a2b6869: function () {
582
+ __wbg_get_baf4855f9a986186: function () {
581
583
  return handleError(function (arg0, arg1) {
582
584
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
583
585
  return addHeapObject(ret);
584
586
  }, arguments);
585
587
  },
586
- __wbg_call_97ae9d8645dc388b: function () {
588
+ __wbg_call_95d1ea488d03e4e8: function () {
587
589
  return handleError(function (arg0, arg1) {
588
590
  const ret = getObject(arg0).call(getObject(arg1));
589
591
  return addHeapObject(ret);
590
592
  }, arguments);
591
593
  },
592
- __wbg_next_579e583d33566a86: function (arg0) {
594
+ __wbg_next_b7d530c04fd8b217: function (arg0) {
593
595
  const ret = getObject(arg0).next;
594
596
  return addHeapObject(ret);
595
597
  },
596
- __wbg_isArray_27c46c67f498e15d: function (arg0) {
598
+ __wbg_isArray_39d28997bf6b96b4: function (arg0) {
597
599
  const ret = Array.isArray(getObject(arg0));
598
600
  return ret;
599
601
  },
600
- __wbg_call_168da88779e35f61: function () {
602
+ __wbg_call_9495de66fdbe016b: function () {
601
603
  return handleError(function (arg0, arg1, arg2) {
602
604
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
603
605
  return addHeapObject(ret);
604
606
  }, arguments);
605
607
  },
606
- __wbg_isSafeInteger_dfa0593e8d7ac35a: function (arg0) {
608
+ __wbg_isSafeInteger_8c4789029e885159: function (arg0) {
607
609
  const ret = Number.isSafeInteger(getObject(arg0));
608
610
  return ret;
609
611
  },
610
- __wbg_set_83db9690f9353e79: function (arg0, arg1, arg2) {
612
+ __wbg_set_17499e8aa4003ebd: function (arg0, arg1, arg2) {
611
613
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
612
614
  },
613
615
  __wbindgen_jsval_loose_eq: function (arg0, arg1) {
614
616
  const ret = getObject(arg0) == getObject(arg1);
615
617
  return ret;
616
618
  },
617
- __wbg_instanceof_Uint8Array_971eeda69eb75003: function (arg0) {
619
+ __wbg_instanceof_Uint8Array_01cebe79ca606cca: function (arg0) {
618
620
  let result;
619
621
  try {
620
622
  result = getObject(arg0) instanceof Uint8Array;
@@ -624,7 +626,7 @@ const imports = {
624
626
  const ret = result;
625
627
  return ret;
626
628
  },
627
- __wbg_instanceof_ArrayBuffer_e5e48f4762c5610b: function (arg0) {
629
+ __wbg_instanceof_ArrayBuffer_a69f02ee4c4f5065: function (arg0) {
628
630
  let result;
629
631
  try {
630
632
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -634,14 +636,14 @@ const imports = {
634
636
  const ret = result;
635
637
  return ret;
636
638
  },
637
- __wbg_entries_65a76a413fc91037: function (arg0) {
639
+ __wbg_entries_4e1315b774245952: function (arg0) {
638
640
  const ret = Object.entries(getObject(arg0));
639
641
  return addHeapObject(ret);
640
642
  },
641
643
  __wbindgen_bigint_get_as_i64: function (arg0, arg1) {
642
644
  const v = getObject(arg1);
643
645
  const ret = typeof (v) === "bigint" ? v : undefined;
644
- getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0n : ret;
646
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
645
647
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
646
648
  },
647
649
  __wbindgen_debug_string: function (arg0, arg1) {
@@ -667,16 +669,16 @@ const imports = {
667
669
  const ret = false;
668
670
  return ret;
669
671
  },
670
- __wbg_then_11f7a54d67b4bfad: function (arg0, arg1) {
672
+ __wbg_then_ec5db6d509eb475f: function (arg0, arg1) {
671
673
  const ret = getObject(arg0).then(getObject(arg1));
672
674
  return addHeapObject(ret);
673
675
  },
674
- __wbg_then_cedad20fbbd9418a: function (arg0, arg1, arg2) {
676
+ __wbg_then_f753623316e2873a: function (arg0, arg1, arg2) {
675
677
  const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
676
678
  return addHeapObject(ret);
677
679
  },
678
- __wbindgen_closure_wrapper7365: function (arg0, arg1, arg2) {
679
- const ret = makeMutClosure(arg0, arg1, 272, __wbg_adapter_40);
680
+ __wbindgen_closure_wrapper7456: function (arg0, arg1, arg2) {
681
+ const ret = makeMutClosure(arg0, arg1, 275, __wbg_adapter_40);
680
682
  return addHeapObject(ret);
681
683
  },
682
684
  },
@@ -70,7 +70,7 @@ const bundle = async (sourceDirectories, distDirectory, tomlDeclarations = [], {
70
70
  const userFunctionsWithConfig = Object.fromEntries(await Promise.all(userConfigPromises));
71
71
  // Creating a final declarations array by combining the TOML file with the
72
72
  // deploy configuration API and the in-source configuration.
73
- const declarations = mergeDeclarations(tomlDeclarations, userFunctionsWithConfig, internalFunctionsWithConfig, deployConfig.declarations);
73
+ const declarations = mergeDeclarations(tomlDeclarations, userFunctionsWithConfig, internalFunctionsWithConfig, deployConfig.declarations, featureFlags);
74
74
  const internalFunctionConfig = createFunctionConfig({
75
75
  internalFunctionsWithConfig,
76
76
  declarations,
@@ -1,4 +1,5 @@
1
1
  import { FunctionConfig, Path } from './config.js';
2
+ import { FeatureFlags } from './feature_flags.js';
2
3
  interface BaseDeclaration {
3
4
  cache?: string;
4
5
  function: string;
@@ -14,6 +15,6 @@ type DeclarationWithPattern = BaseDeclaration & {
14
15
  excludedPattern?: string;
15
16
  };
16
17
  export type Declaration = DeclarationWithPath | DeclarationWithPattern;
17
- export declare const mergeDeclarations: (tomlDeclarations: Declaration[], userFunctionsConfig: Record<string, FunctionConfig>, internalFunctionsConfig: Record<string, FunctionConfig>, deployConfigDeclarations: Declaration[]) => Declaration[];
18
+ export declare const mergeDeclarations: (tomlDeclarations: Declaration[], userFunctionsConfig: Record<string, FunctionConfig>, internalFunctionsConfig: Record<string, FunctionConfig>, deployConfigDeclarations: Declaration[], featureFlags?: FeatureFlags) => Declaration[];
18
19
  export declare const parsePattern: (pattern: string) => string;
19
20
  export {};
@@ -1,14 +1,39 @@
1
1
  import regexpAST from 'regexp-tree';
2
- export const mergeDeclarations = (tomlDeclarations, userFunctionsConfig, internalFunctionsConfig, deployConfigDeclarations) => {
2
+ export const mergeDeclarations = (tomlDeclarations, userFunctionsConfig, internalFunctionsConfig, deployConfigDeclarations, featureFlags = {}) => {
3
+ const functionsVisited = new Set();
4
+ let declarations = getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited);
5
+ // eslint-disable-next-line unicorn/prefer-ternary
6
+ if (featureFlags.edge_functions_correct_order) {
7
+ declarations = [
8
+ // INTEGRATIONS
9
+ // 1. Declarations from the integrations deploy config
10
+ ...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
11
+ // 2. Declarations from the integrations ISC
12
+ ...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),
13
+ // USER
14
+ // 3. Declarations from the users toml config
15
+ ...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
16
+ // 4. Declarations from the users ISC
17
+ ...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
18
+ ];
19
+ }
20
+ else {
21
+ declarations = [
22
+ ...getDeclarationsFromInput(tomlDeclarations, userFunctionsConfig, functionsVisited),
23
+ ...getDeclarationsFromInput(deployConfigDeclarations, internalFunctionsConfig, functionsVisited),
24
+ ...createDeclarationsFromFunctionConfigs(internalFunctionsConfig, functionsVisited),
25
+ ...createDeclarationsFromFunctionConfigs(userFunctionsConfig, functionsVisited),
26
+ ];
27
+ }
28
+ return declarations;
29
+ };
30
+ const getDeclarationsFromInput = (inputDeclarations, functionConfigs, functionsVisited) => {
3
31
  var _a;
4
32
  const declarations = [];
5
- const functionsVisited = new Set();
6
- // We start by iterating over all the declarations in the TOML file and in
7
- // the deploy configuration file. For any declaration for which we also have
8
- // a function configuration object, we replace the path because that object
9
- // takes precedence.
10
- for (const declaration of [...tomlDeclarations, ...deployConfigDeclarations]) {
11
- const config = userFunctionsConfig[declaration.function] || internalFunctionsConfig[declaration.function];
33
+ // For any declaration for which we also have a function configuration object,
34
+ // we replace the path because that object takes precedence.
35
+ for (const declaration of inputDeclarations) {
36
+ const config = functionConfigs[declaration.function];
12
37
  if (!config) {
13
38
  // If no config is found, add the declaration as is.
14
39
  declarations.push(declaration);
@@ -28,10 +53,12 @@ export const mergeDeclarations = (tomlDeclarations, userFunctionsConfig, interna
28
53
  }
29
54
  functionsVisited.add(declaration.function);
30
55
  }
31
- // Finally, we must create declarations for functions that are not declared
32
- // in the TOML at all.
33
- for (const name in { ...internalFunctionsConfig, ...userFunctionsConfig }) {
34
- const { cache, path } = internalFunctionsConfig[name] || userFunctionsConfig[name];
56
+ return declarations;
57
+ };
58
+ const createDeclarationsFromFunctionConfigs = (functionConfigs, functionsVisited) => {
59
+ const declarations = [];
60
+ for (const name in functionConfigs) {
61
+ const { cache, path } = functionConfigs[name];
35
62
  // If we have a path specified, create a declaration for each path.
36
63
  if (!functionsVisited.has(name) && path) {
37
64
  const paths = Array.isArray(path) ? path : [path];
@@ -1,22 +1,47 @@
1
1
  import { test, expect } from 'vitest';
2
2
  import { mergeDeclarations } from './declaration.js';
3
3
  const deployConfigDeclarations = [];
4
- test('Deploy config takes precedence over user config', () => {
4
+ test('Ensure the order of edge functions with FF', () => {
5
5
  const deployConfigDeclarations = [
6
- { function: 'framework-a', path: '/path1' },
7
- { function: 'framework-b', path: '/path2' },
6
+ { function: 'framework-manifest-a', path: '/path1' },
7
+ { function: 'framework-manifest-c', path: '/path3' },
8
+ { function: 'framework-manifest-b', path: '/path2' },
8
9
  ];
9
10
  const tomlConfig = [
10
- { function: 'user-a', path: '/path1' },
11
- { function: 'user-b', path: '/path2' },
11
+ { function: 'user-toml-a', path: '/path1' },
12
+ { function: 'user-toml-c', path: '/path3' },
13
+ { function: 'user-toml-b', path: '/path2' },
12
14
  ];
13
15
  const userFuncConfig = {
14
- 'user-c': { path: ['/path1', '/path2'] },
16
+ 'user-isc-c': { path: ['/path1', '/path2'] },
15
17
  };
16
18
  const internalFuncConfig = {
17
- 'framework-c': { path: ['/path1', '/path2'] },
19
+ 'framework-isc-c': { path: ['/path1', '/path2'] },
18
20
  };
19
- expect(mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations)).toMatchSnapshot();
21
+ expect(mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
22
+ edge_functions_correct_order: true,
23
+ })).toMatchSnapshot();
24
+ });
25
+ test('Ensure the order of edge functions without FF', () => {
26
+ const deployConfigDeclarations = [
27
+ { function: 'framework-manifest-a', path: '/path1' },
28
+ { function: 'framework-manifest-c', path: '/path3' },
29
+ { function: 'framework-manifest-b', path: '/path2' },
30
+ ];
31
+ const tomlConfig = [
32
+ { function: 'user-toml-a', path: '/path1' },
33
+ { function: 'user-toml-c', path: '/path3' },
34
+ { function: 'user-toml-b', path: '/path2' },
35
+ ];
36
+ const userFuncConfig = {
37
+ 'user-isc-c': { path: ['/path1', '/path2'] },
38
+ };
39
+ const internalFuncConfig = {
40
+ 'framework-isc-c': { path: ['/path1', '/path2'] },
41
+ };
42
+ expect(mergeDeclarations(tomlConfig, userFuncConfig, internalFuncConfig, deployConfigDeclarations, {
43
+ edge_functions_correct_order: false,
44
+ })).toMatchSnapshot();
20
45
  });
21
46
  test('In-source config takes precedence over netlify.toml config', () => {
22
47
  const tomlConfig = [
@@ -1,14 +1,14 @@
1
1
  declare const defaultFlags: {
2
+ edge_functions_correct_order: boolean;
2
3
  edge_functions_fail_unsupported_regex: boolean;
3
4
  edge_functions_invalid_config_throw: boolean;
4
- edge_functions_manifest_validate_slash: boolean;
5
5
  };
6
6
  type FeatureFlag = keyof typeof defaultFlags;
7
7
  type FeatureFlags = Partial<Record<FeatureFlag, boolean>>;
8
8
  declare const getFlags: (input?: Record<string, boolean>, flags?: {
9
+ edge_functions_correct_order: boolean;
9
10
  edge_functions_fail_unsupported_regex: boolean;
10
11
  edge_functions_invalid_config_throw: boolean;
11
- edge_functions_manifest_validate_slash: boolean;
12
12
  }) => FeatureFlags;
13
13
  export { defaultFlags, getFlags };
14
14
  export type { FeatureFlag, FeatureFlags };
@@ -1,7 +1,7 @@
1
1
  const defaultFlags = {
2
+ edge_functions_correct_order: false,
2
3
  edge_functions_fail_unsupported_regex: false,
3
4
  edge_functions_invalid_config_throw: false,
4
- edge_functions_manifest_validate_slash: false,
5
5
  };
6
6
  const getFlags = (input = {}, flags = defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
7
7
  ...result,
@@ -1,3 +1,4 @@
1
1
  import { EdgeFunction } from './edge_function.js';
2
+ export declare const removeDuplicatesByExtension: (functions: string[]) => string[];
2
3
  declare const findFunctions: (directories: string[]) => Promise<EdgeFunction[]>;
3
4
  export { findFunctions };
@@ -1,12 +1,24 @@
1
1
  import { promises as fs } from 'fs';
2
- import { basename, extname, join } from 'path';
2
+ import { basename, extname, join, parse } from 'path';
3
3
  import { nonNullable } from './utils/non_nullable.js';
4
- const ALLOWED_EXTENSIONS = new Set(['.js', '.jsx', '.ts', '.tsx']);
4
+ // the order of the allowed extensions is also the order we remove duplicates
5
+ // with a lower index meaning a higher precedence over the others
6
+ const ALLOWED_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
7
+ export const removeDuplicatesByExtension = (functions) => {
8
+ const seen = new Map();
9
+ return Object.values(functions.reduce((acc, path) => {
10
+ const { ext, name } = parse(path);
11
+ const extIndex = ALLOWED_EXTENSIONS.indexOf(ext);
12
+ if (!seen.has(name) || seen.get(name) > extIndex) {
13
+ seen.set(name, extIndex);
14
+ return { ...acc, [name]: path };
15
+ }
16
+ return acc;
17
+ }, {}));
18
+ };
5
19
  const findFunctionInDirectory = async (directory) => {
6
20
  const name = basename(directory);
7
- const candidatePaths = [...ALLOWED_EXTENSIONS]
8
- .flatMap((extension) => [`${name}${extension}`, `index${extension}`])
9
- .map((filename) => join(directory, filename));
21
+ const candidatePaths = ALLOWED_EXTENSIONS.flatMap((extension) => [`${name}${extension}`, `index${extension}`]).map((filename) => join(directory, filename));
10
22
  let functionPath;
11
23
  for (const candidatePath of candidatePaths) {
12
24
  try {
@@ -35,14 +47,14 @@ const findFunctionInPath = async (path) => {
35
47
  return findFunctionInDirectory(path);
36
48
  }
37
49
  const extension = extname(path);
38
- if (ALLOWED_EXTENSIONS.has(extension)) {
50
+ if (ALLOWED_EXTENSIONS.includes(extension)) {
39
51
  return { name: basename(path, extension), path };
40
52
  }
41
53
  };
42
54
  const findFunctionsInDirectory = async (baseDirectory) => {
43
55
  let items = [];
44
56
  try {
45
- items = await fs.readdir(baseDirectory);
57
+ items = await fs.readdir(baseDirectory).then(removeDuplicatesByExtension);
46
58
  }
47
59
  catch {
48
60
  // no-op
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { test, expect } from 'vitest';
2
+ import { removeDuplicatesByExtension } from './finder.js';
3
+ test('filters out any duplicate files based on the extension', () => {
4
+ const functions = [
5
+ 'file1.js',
6
+ 'file1.ts',
7
+ 'file2.tsx',
8
+ 'file2.jsx',
9
+ 'file3.tsx',
10
+ 'file3.js',
11
+ 'file4.ts',
12
+ 'file5.ts',
13
+ 'file5.tsx',
14
+ ];
15
+ const expected = ['file1.js', 'file2.jsx', 'file3.js', 'file4.ts', 'file5.ts'];
16
+ expect(removeDuplicatesByExtension(functions)).toStrictEqual(expected);
17
+ });
@@ -1,4 +1,4 @@
1
1
  import { FeatureFlags } from '../../feature_flags.js';
2
2
  import ManifestValidationError from './error.js';
3
- export declare const validateManifest: (manifestData: unknown, featureFlags?: FeatureFlags) => void;
3
+ export declare const validateManifest: (manifestData: unknown, _featureFlags?: FeatureFlags) => void;
4
4
  export { ManifestValidationError };
@@ -4,13 +4,13 @@ import betterAjvErrors from 'better-ajv-errors';
4
4
  import ManifestValidationError from './error.js';
5
5
  import edgeManifestSchema from './schema.js';
6
6
  let manifestValidator;
7
- const initializeValidator = (featureFlags) => {
7
+ const initializeValidator = () => {
8
8
  if (manifestValidator === undefined) {
9
9
  const ajv = new Ajv({ allErrors: true });
10
10
  ajvErrors(ajv);
11
11
  // regex pattern for manifest route pattern
12
12
  // checks if the pattern string starts with ^ and ends with $
13
- const normalizedPatternRegex = featureFlags.edge_functions_manifest_validate_slash ? /^\^\/.*\$$/ : /^\^.*\$$/;
13
+ const normalizedPatternRegex = /^\^.*\$$/;
14
14
  ajv.addFormat('regexPattern', {
15
15
  validate: (data) => normalizedPatternRegex.test(data),
16
16
  });
@@ -19,8 +19,9 @@ const initializeValidator = (featureFlags) => {
19
19
  return manifestValidator;
20
20
  };
21
21
  // throws on validation error
22
- export const validateManifest = (manifestData, featureFlags = {}) => {
23
- const validate = initializeValidator(featureFlags);
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ export const validateManifest = (manifestData, _featureFlags = {}) => {
24
+ const validate = initializeValidator();
24
25
  const valid = validate(manifestData);
25
26
  if (!valid) {
26
27
  let errorOutput;
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import { test, expect, describe, beforeEach, vi } from 'vitest';
2
+ import { test, expect, describe } from 'vitest';
3
3
  import { validateManifest, ManifestValidationError } from './index.js';
4
4
  // We need to disable all color outputs for the tests as they are different on different platforms, CI, etc.
5
5
  // This only works if this is the same instance of chalk that better-ajv-errors uses
@@ -92,42 +92,25 @@ describe('bundle', () => {
92
92
  });
93
93
  });
94
94
  describe('route', () => {
95
- let freshValidateManifest;
96
- beforeEach(async () => {
97
- // reset all modules, to get a fresh AJV validator for FF changes
98
- vi.resetModules();
99
- const indexImport = await import('./index.js');
100
- freshValidateManifest = indexImport.validateManifest;
101
- });
102
95
  test('should throw on additional property', () => {
103
96
  const manifest = getBaseManifest();
104
97
  manifest.routes[0].foo = 'bar';
105
- expect(() => freshValidateManifest(manifest)).toThrowErrorMatchingSnapshot();
98
+ expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
106
99
  });
107
100
  test('should throw on invalid pattern', () => {
108
101
  const manifest = getBaseManifest();
109
102
  manifest.routes[0].pattern = '/^/hello/?$/';
110
- expect(() => freshValidateManifest(manifest)).toThrowErrorMatchingSnapshot();
111
- });
112
- test('should not throw on missing beginning slash without FF', () => {
113
- const manifest = getBaseManifest();
114
- manifest.routes[0].pattern = '^hello/?$';
115
- expect(() => freshValidateManifest(manifest, { edge_functions_manifest_validate_slash: false })).not.toThrowError();
116
- });
117
- test('should throw on missing beginning slash with FF', () => {
118
- const manifest = getBaseManifest();
119
- manifest.routes[0].pattern = '^hello/?$';
120
- expect(() => freshValidateManifest(manifest, { edge_functions_manifest_validate_slash: true })).toThrowErrorMatchingSnapshot();
103
+ expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
121
104
  });
122
105
  test('should throw on missing function', () => {
123
106
  const manifest = getBaseManifest();
124
107
  delete manifest.routes[0].function;
125
- expect(() => freshValidateManifest(manifest)).toThrowErrorMatchingSnapshot();
108
+ expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
126
109
  });
127
110
  test('should throw on missing pattern', () => {
128
111
  const manifest = getBaseManifest();
129
112
  delete manifest.routes[0].pattern;
130
- expect(() => freshValidateManifest(manifest)).toThrowErrorMatchingSnapshot();
113
+ expect(() => validateManifest(manifest)).toThrowErrorMatchingSnapshot();
131
114
  });
132
115
  });
133
116
  // No tests for post_cache_routes as schema shared with routes
@@ -16,7 +16,7 @@ const routesSchema = {
16
16
  pattern: {
17
17
  type: 'string',
18
18
  format: 'regexPattern',
19
- errorMessage: 'pattern needs to be a regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards',
19
+ errorMessage: 'pattern must be a regex that starts with ^ and ends with $ (e.g. ^/blog/[d]{4}$)',
20
20
  },
21
21
  generator: { type: 'string' },
22
22
  },
@@ -31,7 +31,7 @@ const functionConfigSchema = {
31
31
  items: {
32
32
  type: 'string',
33
33
  format: 'regexPattern',
34
- errorMessage: 'excluded_patterns needs to be an array of regex that starts with ^ followed by / and ends with $ without any additional slashes before and afterwards',
34
+ errorMessage: 'excluded_patterns must be an array of regex that starts with ^ and ends with $ (e.g. ^/blog/[d]{4}$)',
35
35
  },
36
36
  },
37
37
  on_error: { type: 'string' },
package/dist/test/util.js CHANGED
@@ -42,7 +42,7 @@ const runESZIP = async (eszipPath) => {
42
42
  const extractCommand = execa('deno', [
43
43
  'run',
44
44
  '--allow-all',
45
- 'https://deno.land/x/eszip@v0.37.0/eszip.ts',
45
+ 'https://deno.land/x/eszip@v0.40.0/eszip.ts',
46
46
  'x',
47
47
  eszipPath,
48
48
  tmpDir.path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "8.13.0",
3
+ "version": "8.13.2",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",
@@ -58,7 +58,7 @@
58
58
  "@types/node": "^14.18.32",
59
59
  "@types/semver": "^7.3.9",
60
60
  "@types/uuid": "^9.0.0",
61
- "@vitest/coverage-c8": "^0.29.7",
61
+ "@vitest/coverage-c8": "^0.30.0",
62
62
  "archiver": "^5.3.1",
63
63
  "chalk": "^4.1.2",
64
64
  "cpy": "^9.0.1",
@@ -66,8 +66,8 @@
66
66
  "husky": "^8.0.0",
67
67
  "nock": "^13.2.4",
68
68
  "tar": "^6.1.11",
69
- "typescript": "^4.5.4",
70
- "vitest": "^0.29.7"
69
+ "typescript": "^5.0.0",
70
+ "vitest": "^0.30.0"
71
71
  },
72
72
  "engines": {
73
73
  "node": "^14.16.0 || >=16.0.0"