You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Miniflare supports both the traditional `service-worker` and newer `modules`
11
-
formats for writing workers. To use the `modules` format, enable it with:
10
+
Miniflare supports both the traditional `service-worker` and the newer `modules` formats for writing workers. To use the `modules` format, enable it with:
12
11
13
12
```js
14
13
constmf=newMiniflare({
15
14
modules:true,
16
15
});
17
16
```
18
17
19
-
You can now use `modules` worker scripts like the following:
18
+
You can then use `modules` worker scripts like the following:
20
19
21
20
```js
22
21
exportdefault {
@@ -62,11 +61,9 @@ const mf = new Miniflare({
62
61
The following rules are automatically added to the end of your modules rules
63
62
list. You can override them by specifying rules matching the same `globs`:
4. Text blob bindings (`--text-blob`, `[text_blobs]`)
60
-
5. Data blob bindings (`--data-blob`, `[data_blobs]`)
61
-
6. Custom bindings (`--binding`, `bindings`)
62
-
63
31
## Globals
64
32
65
33
Injecting arbitrary globals is not supported by [workerd](https://github.com/cloudflare/workerd). If you're using a service worker, bindings will be injected as globals, but these must be JSON-serialisable.
66
-
67
-
<Asideheader="Tip">
68
-
69
-
Miniflare will always set the global variable `MINIFLARE` to `true` in its
70
-
sandbox. You can use this as an escape hatch to customise behaviour during local
71
-
development:
72
-
73
-
```js
74
-
if (globalThis.MINIFLARE) {
75
-
// Do something when running in Miniflare
76
-
} else {
77
-
// Do something else when running in the real Workers environment
0 commit comments