wrangler 0.0.0-e3cab74 → 0.0.0-e452a35

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 (102) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +27 -14
  3. package/bin/wrangler.js +49 -5
  4. package/miniflare-dist/index.mjs +4886 -0
  5. package/package.json +42 -28
  6. package/pages/functions/buildPlugin.ts +105 -0
  7. package/pages/functions/buildWorker.ts +93 -4
  8. package/pages/functions/filepath-routing.test.ts +136 -25
  9. package/pages/functions/filepath-routing.ts +14 -3
  10. package/pages/functions/routes.ts +6 -1
  11. package/pages/functions/template-plugin.ts +147 -0
  12. package/pages/functions/template-worker.ts +21 -8
  13. package/src/__tests__/config-cache.test.ts +36 -0
  14. package/src/__tests__/configuration.test.ts +1514 -367
  15. package/src/__tests__/dev.test.tsx +870 -84
  16. package/src/__tests__/guess-worker-format.test.ts +37 -18
  17. package/src/__tests__/helpers/mock-account-id.ts +22 -4
  18. package/src/__tests__/helpers/mock-cfetch.ts +8 -4
  19. package/src/__tests__/helpers/mock-console.ts +35 -10
  20. package/src/__tests__/helpers/mock-dialogs.ts +26 -1
  21. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  22. package/src/__tests__/helpers/mock-istty.ts +27 -0
  23. package/src/__tests__/helpers/mock-kv.ts +9 -16
  24. package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
  25. package/src/__tests__/helpers/mock-stdin.ts +103 -0
  26. package/src/__tests__/helpers/run-in-tmp.ts +10 -0
  27. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  28. package/src/__tests__/https-options.test.ts +130 -0
  29. package/src/__tests__/index.test.ts +137 -747
  30. package/src/__tests__/init.test.ts +1557 -0
  31. package/src/__tests__/jest.setup.ts +28 -8
  32. package/src/__tests__/kv.test.ts +598 -258
  33. package/src/__tests__/logger.test.ts +115 -0
  34. package/src/__tests__/pages.test.ts +657 -0
  35. package/src/__tests__/parse.test.ts +8 -0
  36. package/src/__tests__/publish.test.ts +4003 -941
  37. package/src/__tests__/r2.test.ts +69 -34
  38. package/src/__tests__/route.test.ts +45 -0
  39. package/src/__tests__/secret.test.ts +228 -73
  40. package/src/__tests__/tail.test.ts +146 -20
  41. package/src/__tests__/user.test.ts +131 -0
  42. package/src/__tests__/whoami.test.tsx +26 -7
  43. package/src/abort.d.ts +3 -0
  44. package/src/bundle.ts +74 -7
  45. package/src/cfetch/index.ts +21 -4
  46. package/src/cfetch/internal.ts +20 -14
  47. package/src/cli.ts +5 -11
  48. package/src/config/README.md +7 -7
  49. package/src/config/config.ts +69 -100
  50. package/src/config/environment.ts +119 -4
  51. package/src/config/index.ts +177 -4
  52. package/src/config/validation-helpers.ts +228 -23
  53. package/src/config/validation.ts +687 -174
  54. package/src/config-cache.ts +45 -0
  55. package/src/{api/preview.ts → create-worker-preview.ts} +74 -36
  56. package/src/{api/form_data.ts → create-worker-upload-form.ts} +55 -18
  57. package/src/dev/dev-vars.ts +36 -0
  58. package/src/dev/dev.tsx +422 -0
  59. package/src/dev/local.tsx +318 -0
  60. package/src/dev/remote.tsx +227 -0
  61. package/src/dev/use-esbuild.ts +118 -0
  62. package/src/dialogs.tsx +16 -6
  63. package/src/durable.ts +102 -0
  64. package/src/entry.ts +279 -14
  65. package/src/environment-variables.ts +3 -1
  66. package/src/errors.ts +11 -0
  67. package/src/https-options.ts +123 -0
  68. package/src/index.tsx +1268 -806
  69. package/src/inspect.ts +64 -11
  70. package/src/intl-polyfill.d.ts +139 -0
  71. package/src/{kv.tsx → kv.ts} +195 -62
  72. package/src/logger.ts +66 -0
  73. package/src/miniflare-cli/README.md +30 -0
  74. package/src/miniflare-cli/enum-keys.ts +17 -0
  75. package/src/miniflare-cli/index.ts +41 -0
  76. package/src/miniflare-cli/request-context.ts +40 -0
  77. package/src/module-collection.ts +94 -6
  78. package/src/open-in-browser.ts +9 -3
  79. package/src/package-manager.ts +9 -8
  80. package/src/pages.tsx +1057 -75
  81. package/src/parse.ts +24 -5
  82. package/src/proxy.ts +143 -54
  83. package/src/publish.ts +444 -229
  84. package/src/selfsigned.d.ts +29 -0
  85. package/src/sites.tsx +98 -44
  86. package/src/tail/index.ts +2 -2
  87. package/src/tail/printing.ts +13 -8
  88. package/src/update-check.ts +19 -0
  89. package/src/user.tsx +263 -109
  90. package/src/whoami.tsx +2 -1
  91. package/src/{api/worker.ts → worker.ts} +24 -30
  92. package/templates/gitignore +171 -0
  93. package/templates/new-worker.ts +16 -1
  94. package/templates/static-asset-facade.js +1 -1
  95. package/wrangler-dist/cli.js +55345 -69246
  96. package/src/__tests__/helpers/mock-user.ts +0 -27
  97. package/src/__tests__/logout.test.ts +0 -50
  98. package/src/__tests__/sentry.test.ts +0 -146
  99. package/src/dev.tsx +0 -961
  100. package/src/guess-worker-format.ts +0 -68
  101. package/src/reporting.ts +0 -115
  102. package/wrangler-dist/cli.js.map +0 -7
@@ -1,4 +1,4 @@
1
- import { fetch } from "undici";
1
+ import { fetch, Headers } from "undici";
2
2
  import { getEnvironmentVariableFactory } from "../environment-variables";
3
3
  import { ParseError, parseJSON } from "../parse";
4
4
  import { getAPIToken, loginOrRefreshIfRequired } from "../user";
@@ -26,12 +26,13 @@ export const getCloudflareAPIBaseURL = getEnvironmentVariableFactory({
26
26
  export async function fetchInternal<ResponseType>(
27
27
  resource: string,
28
28
  init: RequestInit = {},
29
- queryParams?: URLSearchParams
29
+ queryParams?: URLSearchParams,
30
+ abortSignal?: AbortSignal
30
31
  ): Promise<ResponseType> {
31
32
  await requireLoggedIn();
32
33
  const apiToken = requireApiToken();
33
34
  const headers = cloneHeaders(init.headers);
34
- addAuthorizationHeader(headers, apiToken);
35
+ addAuthorizationHeaderIfUnspecified(headers, apiToken);
35
36
 
36
37
  const queryString = queryParams ? `?${queryParams.toString()}` : "";
37
38
  const method = init.method ?? "GET";
@@ -41,11 +42,12 @@ export async function fetchInternal<ResponseType>(
41
42
  method,
42
43
  ...init,
43
44
  headers,
45
+ signal: abortSignal,
44
46
  }
45
47
  );
46
48
  const jsonText = await response.text();
47
49
  try {
48
- return parseJSON(jsonText) as ResponseType;
50
+ return parseJSON<ResponseType>(jsonText);
49
51
  } catch (err) {
50
52
  throw new ParseError({
51
53
  text: "Received a malformed response from the API",
@@ -72,7 +74,11 @@ function truncate(text: string, maxLength: number): string {
72
74
  function cloneHeaders(
73
75
  headers: HeadersInit | undefined
74
76
  ): Record<string, string> {
75
- return { ...headers };
77
+ return headers instanceof Headers
78
+ ? Object.fromEntries(headers.entries())
79
+ : Array.isArray(headers)
80
+ ? Object.fromEntries(headers)
81
+ : { ...headers };
76
82
  }
77
83
 
78
84
  async function requireLoggedIn(): Promise<void> {
@@ -83,23 +89,20 @@ async function requireLoggedIn(): Promise<void> {
83
89
  }
84
90
 
85
91
  function requireApiToken(): string {
86
- const apiToken = getAPIToken();
87
- if (!apiToken) {
92
+ const authToken = getAPIToken();
93
+ if (!authToken) {
88
94
  throw new Error("No API token found.");
89
95
  }
90
- return apiToken;
96
+ return authToken;
91
97
  }
92
98
 
93
- function addAuthorizationHeader(
99
+ function addAuthorizationHeaderIfUnspecified(
94
100
  headers: Record<string, string>,
95
101
  apiToken: string
96
102
  ): void {
97
- if ("Authorization" in headers) {
98
- throw new Error(
99
- "The request already specifies an authorisation header - cannot add a new one."
100
- );
103
+ if (!("Authorization" in headers)) {
104
+ headers["Authorization"] = `Bearer ${apiToken}`;
101
105
  }
102
- headers["Authorization"] = `Bearer ${apiToken}`;
103
106
  }
104
107
 
105
108
  /**
@@ -108,6 +111,9 @@ function addAuthorizationHeader(
108
111
  * doesn't return json. We inline the implementation and try not to share
109
112
  * any code with the other calls. We should push back on any new APIs that
110
113
  * try to introduce non-"standard" response structures.
114
+ *
115
+ * Note: any calls to fetchKVGetValue must call encodeURIComponent on key
116
+ * before passing it
111
117
  */
112
118
 
113
119
  export async function fetchKVGetValue(
package/src/cli.ts CHANGED
@@ -1,19 +1,13 @@
1
+ import "dotenv/config"; // Grab locally specified env params from a `.env` file.
1
2
  import process from "process";
2
3
  import { hideBin } from "yargs/helpers";
3
- import { reportError, initReporting } from "./reporting";
4
+ import { FatalError } from "./errors";
4
5
  import { main } from ".";
5
6
 
6
- try {
7
- initReporting();
8
- } catch (error) {}
9
-
10
- process.on("uncaughtExceptionMonitor", async (err, origin) => {
11
- await reportError(err, origin);
12
- });
13
-
14
- main(hideBin(process.argv)).catch(() => {
7
+ main(hideBin(process.argv)).catch((e) => {
15
8
  // The logging of any error that was thrown from `main()` is handled in the `yargs.fail()` handler.
16
9
  // Here we just want to ensure that the process exits with a non-zero code.
17
10
  // We don't want to do this inside the `main()` function, since that would kill the process when running our tests.
18
- process.exit(1);
11
+ const exitCode = (e instanceof FatalError && e.code) || 1;
12
+ process.exit(exitCode);
19
13
  });
@@ -25,31 +25,30 @@ This includes the `EnvironmentInheritable` and `EnvironmentNonInheritable` field
25
25
  ### Config
26
26
 
27
27
  The "non-overridable" types are defined in the [`ConfigFields`](./config.ts) type.
28
- Notably this also contains a property called `env` which is the container for the named environment configuration.
29
-
30
28
  The `Config` type is the overall configuration, which consists of the `ConfigFields` and also an `Environment`.
31
- In this case the `Environment`, here, corresponds to the top level environment.
29
+ In this case the `Environment`, here, corresponds to the "currently active" environment. This is specified by the `--env` command line argument.
30
+ If there is no argument passed then the currently active environment is the "top-level" environment.
32
31
  The fields in `Config` and `Environment` are not generally optional and so you can expect they have been filled with suitable inherited or default values.
33
32
  These types should be used when you are working with fields that should be passed to commands.
34
33
 
35
34
  ### RawConfig
36
35
 
37
36
  The `RawConfig` type is a version of `Config`, where all the fields are optional.
38
- The `RawConfig` type also includes `DeprecatedConfigFields` and extends and contains the `RawEnvironment` type,
39
- which is a version of `Environment` where all the fields are optional.
37
+ The `RawConfig` type includes `DeprecatedConfigFields` and `EnvironmentMap`.
38
+ It also extends the `RawEnvironment` type, which is a version of `Environment` where all the fields are optional.
40
39
  These optional fields map to the actual fields found in the `wrangler.toml`.
41
40
  These types should be used when you are working with raw configuration that is read or will be written to a `wrangler.toml`.
42
41
 
43
42
  ## Validation
44
43
 
45
- Validation is triggered by passing a `RawConfig` object to the `normalizeAndValidateConfig()` function.
44
+ Validation is triggered by passing a `RawConfig` object, and the active environment name, to the `normalizeAndValidateConfig()` function.
46
45
  This function will return:
47
46
 
48
47
  - a `Config` object, where all the fields have suitable valid values
49
48
  - a `Diagnostics` object, which contains any errors or warnings from the validation process
50
49
 
51
50
  The field values may have been parsed directly from the `RawConfig`, inherited into a named environment from the top-level environment, or given a default value.
52
- Generally, if there are any warnings they should be presented to the user via `console.warn()` messages,
51
+ Generally, if there are any warnings they should be presented to the user via `logger.warn()` messages,
53
52
  and if there are any errors then an `Error` should be thrown describing these errors.
54
53
 
55
54
  The `Diagnostics` object is hierarchical: each `Diagnostics` instance can contain a collection of child `Diagnostics` instance.
@@ -62,6 +61,7 @@ The [high level API](./index.ts) for configuration processing consists of the `f
62
61
  ### readConfig()
63
62
 
64
63
  The `readConfig()` function will find the nearest `wrangler.toml` file, load and parse it, then validate and normalize the values into a `Config` object.
64
+ Note that you should pass the current active environment name in as a parameter. The resulting `Config` object will contain only the fields appropriate to that environment.
65
65
  If there are validation errors then it will throw a suitable error.
66
66
 
67
67
  ## Changing configuration
@@ -3,7 +3,7 @@ import type { Environment, RawEnvironment } from "./environment";
3
3
  /**
4
4
  * This is the static type definition for the configuration object.
5
5
  *
6
- * It reflects the configuration that you can write in wrangler.toml,
6
+ * It reflects a normalized and validated version of the configuration that you can write in wrangler.toml,
7
7
  * and optionally augment with arguments passed directly to wrangler.
8
8
  *
9
9
  * For more information about the configuration object, see the
@@ -20,20 +20,16 @@ import type { Environment, RawEnvironment } from "./environment";
20
20
  * - `@breaking`: the deprecation/optionality is a breaking change from wrangler 1.
21
21
  * - `@todo`: there's more work to be done (with details attached).
22
22
  */
23
- export type Config = ConfigFields<Environment> & Environment;
23
+ export type Config = ConfigFields<DevConfig> & Environment;
24
24
 
25
- export type RawConfig = Partial<ConfigFields<RawEnvironment>> &
25
+ export type RawConfig = Partial<ConfigFields<RawDevConfig>> &
26
26
  RawEnvironment &
27
- DeprecatedConfigFields;
27
+ DeprecatedConfigFields &
28
+ EnvironmentMap;
28
29
 
29
- export interface ConfigFields<Env extends RawEnvironment> {
30
+ export interface ConfigFields<Dev extends RawDevConfig> {
30
31
  configPath: string | undefined;
31
32
 
32
- /**
33
- * The entrypoint/path to the JavaScript file that will be executed.
34
- */
35
- main: string | undefined;
36
-
37
33
  /**
38
34
  * A boolean to enable "legacy" style wrangler environments (from wrangler 1).
39
35
  * These have been superseded by Services, but there may be projects that won't
@@ -42,59 +38,10 @@ export interface ConfigFields<Env extends RawEnvironment> {
42
38
  */
43
39
  legacy_env: boolean;
44
40
 
45
- /**
46
- * The `env` section defines overrides for the configuration for different environments.
47
- *
48
- * All environment fields can be specified at the top level of the config indicating the default environment settings.
49
- *
50
- * - Some fields are inherited and overridable in each environment.
51
- * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
52
- *
53
- * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
54
- *
55
- * @default `{}`
56
- */
57
- env: {
58
- [envName: string]: Env;
59
- };
60
-
61
41
  /**
62
42
  * Options to configure the development server that your worker will use.
63
- *
64
- * @default `{}`
65
43
  */
66
- dev: {
67
- /**
68
- * IP address for the local dev server to listen on,
69
- *
70
- * @default `127.0.0.1`
71
- * @todo this needs to be implemented
72
- */
73
- ip?: string;
74
-
75
- /**
76
- * Port for the local dev server to listen on
77
- *
78
- * @default `8787`
79
- */
80
- port?: number;
81
-
82
- /**
83
- * Protocol that local wrangler dev server listens to requests on.
84
- *
85
- * @default `http`
86
- * @todo this needs to be implemented
87
- */
88
- local_protocol?: string;
89
-
90
- /**
91
- * Protocol that wrangler dev forwards requests on
92
- *
93
- * @default `https`
94
- * @todo this needs to be implemented
95
- */
96
- upstream_protocol?: string;
97
- };
44
+ dev: Dev;
98
45
 
99
46
  /**
100
47
  * A list of migrations that should be uploaded with your Worker.
@@ -190,25 +137,58 @@ export interface ConfigFields<Env extends RawEnvironment> {
190
137
  | undefined;
191
138
 
192
139
  /**
193
- * Configures a custom build step to be run by Wrangler when building your Worker.
140
+ * A list of data files that your worker should be bound to. This is
141
+ * the "legacy" way of binding to a data file. ES module workers should
142
+ * do proper module imports.
143
+ */
144
+ data_blobs:
145
+ | {
146
+ [key: string]: string;
147
+ }
148
+ | undefined;
149
+ }
150
+
151
+ export interface DevConfig {
152
+ /**
153
+ * IP address for the local dev server to listen on,
154
+ *
155
+ * @default `localhost`
156
+ */
157
+ ip: string;
158
+
159
+ /**
160
+ * Port for the local dev server to listen on
194
161
  *
195
- * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
196
- * for more details.
162
+ * @default `8787`
163
+ */
164
+ port: number | undefined;
165
+
166
+ /**
167
+ * Protocol that local wrangler dev server listens to requests on.
197
168
  *
198
- * @default {}
169
+ * @default `http`
199
170
  */
200
- build: {
201
- /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
202
- command?: string;
203
- /** The directory in which the command is executed. */
204
- cwd?: string;
205
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
206
- watch_dir?: string;
207
- /** Deprecated field previously used to configure the build and upload of the script. */
208
- upload?: DeprecatedUpload;
209
- };
171
+ local_protocol: "http" | "https";
172
+
173
+ /**
174
+ * Protocol that wrangler dev forwards requests on
175
+ *
176
+ * Setting this to `http` is not currently implemented.
177
+ * See https://github.com/cloudflare/wrangler2/issues/583
178
+ *
179
+ * @default `https`
180
+ * @todo this needs to be implemented https://github.com/cloudflare/wrangler2/issues/583
181
+ */
182
+ upstream_protocol: "https" | "http";
183
+
184
+ /**
185
+ * Host to forward requests to, defaults to the host of the first route of project
186
+ */
187
+ host: Config["route"];
210
188
  }
211
189
 
190
+ export type RawDevConfig = Partial<DevConfig>;
191
+
212
192
  export interface DeprecatedConfigFields {
213
193
  /**
214
194
  * The project "type". A holdover from wrangler 1.x.
@@ -227,39 +207,28 @@ export interface DeprecatedConfigFields {
227
207
  * @breaking
228
208
  */
229
209
  webpack_config?: string;
230
- }
231
210
 
232
- /**
233
- * Deprecated upload configuration.
234
- */
235
- export interface DeprecatedUpload {
236
211
  /**
237
- * The format of the Worker script.
238
- *
239
- * @deprecated We infer the format automatically now.
212
+ * Configuration only used by a standalone use of the miniflare binary.
213
+ * @deprecated
240
214
  */
241
- format?: "modules" | "service-worker";
215
+ miniflare?: unknown;
216
+ }
242
217
 
218
+ interface EnvironmentMap {
243
219
  /**
244
- * The directory you wish to upload your worker from,
245
- * relative to the wrangler.toml file.
220
+ * The `env` section defines overrides for the configuration for different environments.
246
221
  *
247
- * Defaults to the directory containing the wrangler.toml file.
222
+ * All environment fields can be specified at the top level of the config indicating the default environment settings.
248
223
  *
249
- * @deprecated
250
- * @breaking In wrangler 1, this defaults to ./dist, whereas in wrangler 2 it defaults to ./
251
- */
252
- dir?: string;
253
-
254
- /**
255
- * The path to the Worker script, relative to `upload.dir`.
224
+ * - Some fields are inherited and overridable in each environment.
225
+ * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
256
226
  *
257
- * @deprecated This will be replaced by a command line argument.
258
- */
259
- main?: string;
260
-
261
- /**
262
- * @deprecated This is now defined at the top level `rules` field.
227
+ * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
228
+ *
229
+ * @default `{}`
263
230
  */
264
- rules?: Environment["rules"];
231
+ env?: {
232
+ [envName: string]: RawEnvironment;
233
+ };
265
234
  }
@@ -8,6 +8,24 @@ export interface Environment
8
8
  extends EnvironmentInheritable,
9
9
  EnvironmentNonInheritable {}
10
10
 
11
+ export type SimpleRoute = string;
12
+ export type ZoneIdRoute = {
13
+ pattern: string;
14
+ zone_id: string;
15
+ custom_domain?: boolean;
16
+ };
17
+ export type ZoneNameRoute = {
18
+ pattern: string;
19
+ zone_name: string;
20
+ custom_domain?: boolean;
21
+ };
22
+ export type CustomDomainRoute = { pattern: string; custom_domain: boolean };
23
+ export type Route =
24
+ | SimpleRoute
25
+ | ZoneIdRoute
26
+ | ZoneNameRoute
27
+ | CustomDomainRoute;
28
+
11
29
  /**
12
30
  * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
13
31
  * that can be inherited (and overridden) from the top-level environment.
@@ -51,6 +69,11 @@ interface EnvironmentInheritable {
51
69
  */
52
70
  compatibility_flags: string[];
53
71
 
72
+ /**
73
+ * The entrypoint/path to the JavaScript file that will be executed.
74
+ */
75
+ main: string | undefined;
76
+
54
77
  /**
55
78
  * Whether we use <name>.<subdomain>.workers.dev to
56
79
  * test and deploy your worker.
@@ -59,7 +82,7 @@ interface EnvironmentInheritable {
59
82
  * @breaking
60
83
  * @inheritable
61
84
  */
62
- workers_dev: boolean;
85
+ workers_dev: boolean | undefined;
63
86
 
64
87
  /**
65
88
  * A list of routes that your worker should be published to.
@@ -69,7 +92,7 @@ interface EnvironmentInheritable {
69
92
  *
70
93
  * @inheritable
71
94
  */
72
- routes: string[] | undefined;
95
+ routes: Route[] | undefined;
73
96
 
74
97
  /**
75
98
  * A route that your worker should be published to. Literally
@@ -80,7 +103,12 @@ interface EnvironmentInheritable {
80
103
  *
81
104
  * @inheritable
82
105
  */
83
- route: string | undefined;
106
+ route: Route | undefined;
107
+
108
+ /**
109
+ * Path to a custom tsconfig
110
+ */
111
+ tsconfig: string | undefined;
84
112
 
85
113
  /**
86
114
  * The function to use to replace jsx syntax.
@@ -121,7 +149,7 @@ interface EnvironmentInheritable {
121
149
  *
122
150
  * @inheritable
123
151
  */
124
- usage_model: undefined | "bundled" | "unbound";
152
+ usage_model: "bundled" | "unbound" | undefined;
125
153
 
126
154
  /**
127
155
  * An ordered list of rules that define which modules to import,
@@ -133,6 +161,39 @@ interface EnvironmentInheritable {
133
161
  */
134
162
  rules: Rule[];
135
163
 
164
+ /**
165
+ * Configures a custom build step to be run by Wrangler when building your Worker.
166
+ *
167
+ * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
168
+ * for more details.
169
+ *
170
+ * @default {}
171
+ */
172
+ build: {
173
+ /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
174
+ command?: string;
175
+ /** The directory in which the command is executed. */
176
+ cwd?: string;
177
+ /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
178
+ watch_dir?: string;
179
+ /**
180
+ * Deprecated field previously used to configure the build and upload of the script.
181
+ * @deprecated
182
+ */
183
+ upload?: DeprecatedUpload;
184
+ };
185
+
186
+ /**
187
+ * Minify the script before uploading.
188
+ * @inheritable
189
+ */
190
+ minify: boolean | undefined;
191
+
192
+ /**
193
+ * Add polyfills for node builtin modules and globals
194
+ */
195
+ node_compat: boolean | undefined;
196
+
136
197
  /**
137
198
  * TODO: remove this as it has been deprecated.
138
199
  *
@@ -181,6 +242,8 @@ interface EnvironmentNonInheritable {
181
242
  class_name: string;
182
243
  /** The script where the Durable Object is defined (if it's external to this worker) */
183
244
  script_name?: string;
245
+ /** The service environment of the script_name to bind to */
246
+ environment?: string;
184
247
  }[];
185
248
  };
186
249
 
@@ -224,6 +287,24 @@ interface EnvironmentNonInheritable {
224
287
  preview_bucket_name?: string;
225
288
  }[];
226
289
 
290
+ /**
291
+ * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
292
+ *
293
+ * NOTE: This field is not automatically inherited from the top level environment,
294
+ * and so must be specified in every named environment.
295
+ *
296
+ * @default `[]`
297
+ * @nonInheritable
298
+ */
299
+ services: {
300
+ /** The binding name used to refer to the bound service. */
301
+ binding: string;
302
+ /** The name of the service. */
303
+ service: string;
304
+ /** The environment of the service (e.g. production, staging, etc). */
305
+ environment?: string;
306
+ }[];
307
+
227
308
  /**
228
309
  * "Unsafe" tables for features that aren't directly supported by wrangler.
229
310
  *
@@ -277,6 +358,40 @@ interface EnvironmentDeprecated {
277
358
  }[];
278
359
  }
279
360
 
361
+ /**
362
+ * Deprecated upload configuration.
363
+ */
364
+ export interface DeprecatedUpload {
365
+ /**
366
+ * The format of the Worker script.
367
+ *
368
+ * @deprecated We infer the format automatically now.
369
+ */
370
+ format?: "modules" | "service-worker";
371
+
372
+ /**
373
+ * The directory you wish to upload your worker from,
374
+ * relative to the wrangler.toml file.
375
+ *
376
+ * Defaults to the directory containing the wrangler.toml file.
377
+ *
378
+ * @deprecated
379
+ */
380
+ dir?: string;
381
+
382
+ /**
383
+ * The path to the Worker script, relative to `upload.dir`.
384
+ *
385
+ * @deprecated This will be replaced by a command line argument.
386
+ */
387
+ main?: string;
388
+
389
+ /**
390
+ * @deprecated This is now defined at the top level `rules` field.
391
+ */
392
+ rules?: Environment["rules"];
393
+ }
394
+
280
395
  /**
281
396
  * The raw environment configuration that we read from the config file.
282
397
  *