wrangler 0.0.0-e1c615f → 0.0.0-e6733a3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "0.0.0-e1c615f",
3
+ "version": "0.0.0-e6733a3",
4
4
  "author": "wrangler@cloudflare.com",
5
5
  "description": "Command-line interface for all things Cloudflare Workers",
6
6
  "bin": {
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "esbuild": "0.14.1",
40
- "miniflare": "2.0.0-rc.5",
40
+ "miniflare": "2.1.0",
41
41
  "path-to-regexp": "^6.2.0",
42
42
  "semiver": "^1.1.0"
43
43
  },
@@ -59,6 +59,7 @@
59
59
  "chokidar": "^3.5.2",
60
60
  "clipboardy": "^3.0.0",
61
61
  "command-exists": "^1.2.9",
62
+ "devtools-protocol": "^0.0.955664",
62
63
  "execa": "^6.0.0",
63
64
  "faye-websocket": "^0.11.4",
64
65
  "finalhandler": "^1.1.2",
@@ -6,6 +6,7 @@ type Options = {
6
6
  outfile: string;
7
7
  minify?: boolean;
8
8
  sourcemap?: boolean;
9
+ fallbackService?: string;
9
10
  watch?: boolean;
10
11
  onEnd?: () => void;
11
12
  };
@@ -15,6 +16,7 @@ export function buildWorker({
15
16
  outfile = "bundle.js",
16
17
  minify = false,
17
18
  sourcemap = false,
19
+ fallbackService = "ASSETS",
18
20
  watch = false,
19
21
  onEnd = () => {},
20
22
  }: Options) {
@@ -31,6 +33,9 @@ export function buildWorker({
31
33
  sourcemap,
32
34
  watch,
33
35
  allowOverwrite: true,
36
+ define: {
37
+ __FALLBACK_SERVICE__: JSON.stringify(fallbackService),
38
+ },
34
39
  plugins: [
35
40
  {
36
41
  name: "wrangler notifier and monitor",
@@ -29,6 +29,8 @@ type RouteHandler = {
29
29
 
30
30
  // inject `routes` via ESBuild
31
31
  declare const routes: RouteHandler[];
32
+ // define `__FALLBACK_SERVICE__` via ESBuild
33
+ declare const __FALLBACK_SERVICE__: string;
32
34
 
33
35
  // expect an ASSETS fetcher binding pointing to the asset-server stage
34
36
  type Env = {
@@ -40,6 +42,7 @@ type WorkerContext = {
40
42
  waitUntil: (promise: Promise<unknown>) => void;
41
43
  };
42
44
 
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- `env` can be used by __FALLBACK_SERVICE_FETCH__
43
46
  function* executeRequest(request: Request, env: Env) {
44
47
  const requestPath = new URL(request.url).pathname;
45
48
 
@@ -86,9 +89,13 @@ function* executeRequest(request: Request, env: Env) {
86
89
  }
87
90
  }
88
91
 
89
- // Finally, yield to the asset-server
92
+ // Finally, yield to the fallback service (`env.ASSETS.fetch` in Pages' case)
90
93
  return {
91
- handler: () => env.ASSETS.fetch(request.url, request),
94
+ handler: () =>
95
+ __FALLBACK_SERVICE__
96
+ ? // @ts-expect-error expecting __FALLBACK_SERVICE__ to be the name of a service binding, so fetch should be defined
97
+ env[__FALLBACK_SERVICE__].fetch(request)
98
+ : fetch(request),
92
99
  params: {} as Params,
93
100
  };
94
101
  }
package/src/api/worker.ts CHANGED
@@ -112,7 +112,7 @@ export interface CfWorkerInit {
112
112
  /**
113
113
  * The name of the worker.
114
114
  */
115
- name: string | void;
115
+ name: string | undefined;
116
116
  /**
117
117
  * The entrypoint module.
118
118
  */
@@ -120,7 +120,7 @@ export interface CfWorkerInit {
120
120
  /**
121
121
  * The list of additional modules.
122
122
  */
123
- modules: void | CfModule[];
123
+ modules: undefined | CfModule[];
124
124
  /**
125
125
  * All the bindings
126
126
  */
@@ -130,10 +130,10 @@ export interface CfWorkerInit {
130
130
  vars?: CfVars;
131
131
  services?: CfService[];
132
132
  };
133
- migrations: void | CfDurableObjectMigrations;
134
- compatibility_date: string | void;
135
- compatibility_flags: void | string[];
136
- usage_model: void | "bundled" | "unbound";
133
+ migrations: undefined | CfDurableObjectMigrations;
134
+ compatibility_date: string | undefined;
135
+ compatibility_flags: undefined | string[];
136
+ usage_model: undefined | "bundled" | "unbound";
137
137
  }
138
138
 
139
139
  /**