|
1 | 1 | # miniflare |
2 | 2 |
|
| 3 | +## 3.20250214.0 |
| 4 | + |
| 5 | +### Patch Changes |
| 6 | + |
| 7 | +- [#8171](https://github.com/cloudflare/workers-sdk/pull/8171) [`5e06177`](https://github.com/cloudflare/workers-sdk/commit/5e06177861b29aa9b114f9ecb50093190af94f4b) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: update dependencies of "miniflare" package |
| 8 | + |
| 9 | + The following dependency versions have been updated: |
| 10 | + |
| 11 | + | Dependency | From | To | |
| 12 | + | ------------------------- | ------------- | ------------- | |
| 13 | + | workerd | 1.20250204.0 | 1.20250214.0 | |
| 14 | + | @cloudflare/workers-types | ^4.20250204.0 | ^4.20250214.0 | |
| 15 | + |
3 | 16 | ## 3.20250204.1 |
4 | 17 |
|
5 | 18 | ### Patch Changes |
|
567 | 580 | import { Miniflare } from "miniflare"; |
568 | 581 |
|
569 | 582 | const mf = new Miniflare({ |
570 | | - workers: [ |
571 | | - { |
572 | | - wrappedBindings: { |
573 | | - Greeter: { |
574 | | - scriptName: "impl", |
575 | | - }, |
576 | | - }, |
577 | | - modules: true, |
578 | | - script: `export default { fetch(){ return new Response(''); } }`, |
579 | | - }, |
580 | | - { |
581 | | - modules: true, |
582 | | - name: "impl", |
583 | | - script: ` |
| 583 | + workers: [ |
| 584 | + { |
| 585 | + wrappedBindings: { |
| 586 | + Greeter: { |
| 587 | + scriptName: "impl", |
| 588 | + }, |
| 589 | + }, |
| 590 | + modules: true, |
| 591 | + script: `export default { fetch(){ return new Response(''); } }`, |
| 592 | + }, |
| 593 | + { |
| 594 | + modules: true, |
| 595 | + name: "impl", |
| 596 | + script: ` |
584 | 597 | class Greeter { |
585 | 598 | sayHello(name) { |
586 | 599 | return "Hello " + name; |
|
591 | 604 | return new Greeter(); |
592 | 605 | } |
593 | 606 | `, |
594 | | - }, |
595 | | - ], |
| 607 | + }, |
| 608 | + ], |
596 | 609 | }); |
597 | 610 |
|
598 | 611 | const { Greeter } = await mf.getBindings(); |
|
612 | 625 | import { Miniflare } from "miniflare"; |
613 | 626 |
|
614 | 627 | const mf = new Miniflare({ |
615 | | - workers: [ |
616 | | - { |
617 | | - modules: true, |
618 | | - script: `export default { fetch() { return new Response(''); } }`, |
619 | | - serviceBindings: { |
620 | | - SUM: { |
621 | | - name: "sum-worker", |
622 | | - entrypoint: "SumEntrypoint", |
623 | | - }, |
624 | | - }, |
625 | | - }, |
626 | | - { |
627 | | - modules: true, |
628 | | - name: "sum-worker", |
629 | | - script: ` |
| 628 | + workers: [ |
| 629 | + { |
| 630 | + modules: true, |
| 631 | + script: `export default { fetch() { return new Response(''); } }`, |
| 632 | + serviceBindings: { |
| 633 | + SUM: { |
| 634 | + name: "sum-worker", |
| 635 | + entrypoint: "SumEntrypoint", |
| 636 | + }, |
| 637 | + }, |
| 638 | + }, |
| 639 | + { |
| 640 | + modules: true, |
| 641 | + name: "sum-worker", |
| 642 | + script: ` |
630 | 643 | import { WorkerEntrypoint } from 'cloudflare:workers'; |
631 | 644 | |
632 | 645 | export default { fetch() { return new Response(''); } } |
|
637 | 650 | } |
638 | 651 | } |
639 | 652 | `, |
640 | | - }, |
641 | | - ], |
| 653 | + }, |
| 654 | + ], |
642 | 655 | }); |
643 | 656 |
|
644 | 657 | const { SUM } = await mf.getBindings(); |
|
704 | 717 | import { kCurrentWorker, Miniflare } from "miniflare"; |
705 | 718 |
|
706 | 719 | const mf = new Miniflare({ |
707 | | - workers: [ |
708 | | - { |
709 | | - name: "a", |
710 | | - serviceBindings: { |
711 | | - A_RPC_SERVICE: { name: kCurrentWorker, entrypoint: "RpcEntrypoint" }, |
712 | | - A_NAMED_SERVICE: { name: "a", entrypoint: "namedEntrypoint" }, |
713 | | - B_NAMED_SERVICE: { name: "b", entrypoint: "anotherNamedEntrypoint" }, |
714 | | - }, |
715 | | - compatibilityFlags: ["rpc"], |
716 | | - modules: true, |
717 | | - script: ` |
| 720 | + workers: [ |
| 721 | + { |
| 722 | + name: "a", |
| 723 | + serviceBindings: { |
| 724 | + A_RPC_SERVICE: { name: kCurrentWorker, entrypoint: "RpcEntrypoint" }, |
| 725 | + A_NAMED_SERVICE: { name: "a", entrypoint: "namedEntrypoint" }, |
| 726 | + B_NAMED_SERVICE: { name: "b", entrypoint: "anotherNamedEntrypoint" }, |
| 727 | + }, |
| 728 | + compatibilityFlags: ["rpc"], |
| 729 | + modules: true, |
| 730 | + script: ` |
718 | 731 | import { WorkerEntrypoint } from "cloudflare:workers"; |
719 | 732 | |
720 | 733 | export class RpcEntrypoint extends WorkerEntrypoint { |
|
727 | 740 | |
728 | 741 | ... |
729 | 742 | `, |
730 | | - }, |
731 | | - { |
732 | | - name: "b", |
733 | | - modules: true, |
734 | | - script: ` |
| 743 | + }, |
| 744 | + { |
| 745 | + name: "b", |
| 746 | + modules: true, |
| 747 | + script: ` |
735 | 748 | export const anotherNamedEntrypoint = { |
736 | 749 | fetch(request, env, ctx) { return new Response("b:named:pong"); } |
737 | 750 | }; |
738 | 751 | `, |
739 | | - }, |
740 | | - ], |
| 752 | + }, |
| 753 | + ], |
741 | 754 | }); |
742 | 755 | ``` |
743 | 756 |
|
|
855 | 868 | import { Miniflare, Response } from "miniflare"; |
856 | 869 |
|
857 | 870 | const mf = new Miniflare({ |
858 | | - serviceBindings: { |
859 | | - SERVICE(request, instance) { |
860 | | - assert(instance === mf); |
861 | | - return new Response(); |
862 | | - }, |
863 | | - }, |
| 871 | + serviceBindings: { |
| 872 | + SERVICE(request, instance) { |
| 873 | + assert(instance === mf); |
| 874 | + return new Response(); |
| 875 | + }, |
| 876 | + }, |
864 | 877 | }); |
865 | 878 | ``` |
866 | 879 |
|
|
880 | 893 | import { Miniflare } from "miniflare"; |
881 | 894 |
|
882 | 895 | const mf1 = new Miniflare({ |
883 | | - scriptPath: "index.mjs", |
| 896 | + scriptPath: "index.mjs", |
884 | 897 | }); |
885 | 898 |
|
886 | 899 | const mf2 = new Miniflare({ |
887 | | - rootPath: "a/b", |
888 | | - scriptPath: "c/index.mjs", |
| 900 | + rootPath: "a/b", |
| 901 | + scriptPath: "c/index.mjs", |
889 | 902 | }); |
890 | 903 |
|
891 | 904 | const mf3 = new Miniflare({ |
892 | | - rootPath: "/a/b", |
893 | | - workers: [ |
894 | | - { |
895 | | - name: "1", |
896 | | - rootPath: "c", |
897 | | - scriptPath: "index.mjs", |
898 | | - }, |
899 | | - { |
900 | | - name: "2", |
901 | | - scriptPath: "index.mjs", |
902 | | - }, |
903 | | - ], |
| 905 | + rootPath: "/a/b", |
| 906 | + workers: [ |
| 907 | + { |
| 908 | + name: "1", |
| 909 | + rootPath: "c", |
| 910 | + scriptPath: "index.mjs", |
| 911 | + }, |
| 912 | + { |
| 913 | + name: "2", |
| 914 | + scriptPath: "index.mjs", |
| 915 | + }, |
| 916 | + ], |
904 | 917 | }); |
905 | 918 | ``` |
906 | 919 |
|
|
916 | 929 | import { kCurrentWorker, Miniflare } from "miniflare"; |
917 | 930 |
|
918 | 931 | const mf = new Miniflare({ |
919 | | - serviceBindings: { |
920 | | - SELF: kCurrentWorker, |
921 | | - }, |
922 | | - modules: true, |
923 | | - script: `export default { |
| 932 | + serviceBindings: { |
| 933 | + SELF: kCurrentWorker, |
| 934 | + }, |
| 935 | + modules: true, |
| 936 | + script: `export default { |
924 | 937 | fetch(request, env, ctx) { |
925 | 938 | const { pathname } = new URL(request.url); |
926 | 939 | if (pathname === "/recurse") { |
|
945 | 958 |
|
946 | 959 | ```js |
947 | 960 | const mf = new Miniflare({ |
948 | | - modules: true, |
949 | | - modulesRoot: "..", |
950 | | - scriptPath: "../worker.mjs", |
| 961 | + modules: true, |
| 962 | + modulesRoot: "..", |
| 963 | + scriptPath: "../worker.mjs", |
951 | 964 | }); |
952 | 965 | ``` |
953 | 966 |
|
|
1005 | 1018 |
|
1006 | 1019 | ```js |
1007 | 1020 | const mf = new Miniflare({ |
1008 | | - modules: [ |
1009 | | - { |
1010 | | - type: "PythonModule", |
1011 | | - path: "index", |
1012 | | - contents: |
1013 | | - "from js import Response;\ndef fetch(request):\n return Response.new('hello')", |
1014 | | - }, |
1015 | | - ], |
1016 | | - compatibilityFlags: ["experimental"], |
| 1021 | + modules: [ |
| 1022 | + { |
| 1023 | + type: "PythonModule", |
| 1024 | + path: "index", |
| 1025 | + contents: |
| 1026 | + "from js import Response;\ndef fetch(request):\n return Response.new('hello')", |
| 1027 | + }, |
| 1028 | + ], |
| 1029 | + compatibilityFlags: ["experimental"], |
1017 | 1030 | }); |
1018 | 1031 | ``` |
1019 | 1032 |
|
|
1150 | 1163 |
|
1151 | 1164 | ```ts |
1152 | 1165 | const mf = new Miniflare({ |
1153 | | - log, |
1154 | | - modules: true, |
1155 | | - script: ` |
| 1166 | + log, |
| 1167 | + modules: true, |
| 1168 | + script: ` |
1156 | 1169 | export default { |
1157 | 1170 | fetch(req, env, ctx) { |
1158 | 1171 | const two = env.UNSAFE_EVAL.eval('1+1'); |
1159 | 1172 | return new Response('two = ' + two); // returns 'two = 2' |
1160 | 1173 | } |
1161 | 1174 | } |
1162 | 1175 | `, |
1163 | | - unsafeEvalBinding: "UNSAFE_EVAL", |
| 1176 | + unsafeEvalBinding: "UNSAFE_EVAL", |
1164 | 1177 | }); |
1165 | 1178 | ``` |
1166 | 1179 |
|
|
0 commit comments