wrangler 0.0.0-e88a54e → 0.0.0-e89ee2a5

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 (174) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +47 -16
  3. package/bin/wrangler.js +123 -32
  4. package/kv-asset-handler.js +1 -0
  5. package/package.json +168 -86
  6. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  7. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  8. package/templates/__tests__/tsconfig.json +8 -0
  9. package/templates/checked-fetch.js +30 -0
  10. package/templates/facade.d.ts +17 -0
  11. package/templates/gitignore +167 -0
  12. package/templates/init-tests/test-jest-new-worker.js +23 -0
  13. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  14. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  15. package/templates/middleware/common.ts +67 -0
  16. package/templates/middleware/loader-modules.ts +136 -0
  17. package/templates/middleware/loader-sw.ts +229 -0
  18. package/templates/middleware/middleware-d1-beta.d.ts +3 -0
  19. package/templates/middleware/middleware-ensure-req-body-drained.ts +19 -0
  20. package/templates/middleware/middleware-miniflare3-json-error.ts +33 -0
  21. package/templates/middleware/middleware-multiworker-dev.d.ts +4 -0
  22. package/templates/middleware/middleware-multiworker-dev.ts +68 -0
  23. package/templates/middleware/middleware-pretty-error.ts +40 -0
  24. package/templates/middleware/middleware-scheduled.ts +15 -0
  25. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  26. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  27. package/templates/modules-watch-stub.js +4 -0
  28. package/templates/new-worker-scheduled.js +17 -0
  29. package/templates/new-worker-scheduled.ts +32 -0
  30. package/templates/new-worker.js +3 -3
  31. package/templates/new-worker.ts +22 -4
  32. package/templates/no-op-worker.js +10 -0
  33. package/templates/pages-dev-pipeline.ts +32 -0
  34. package/templates/pages-dev-util.ts +55 -0
  35. package/templates/pages-shim.ts +9 -0
  36. package/templates/pages-template-plugin.ts +190 -0
  37. package/templates/pages-template-worker.ts +198 -0
  38. package/templates/startDevWorker/InspectorProxyWorker.ts +661 -0
  39. package/templates/startDevWorker/ProxyWorker.ts +326 -0
  40. package/templates/tsconfig-sanity.ts +11 -0
  41. package/templates/tsconfig.init.json +105 -0
  42. package/templates/tsconfig.json +6 -103
  43. package/wrangler-dist/InspectorProxyWorker.js +464 -0
  44. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  45. package/wrangler-dist/ProxyWorker.js +237 -0
  46. package/wrangler-dist/ProxyWorker.js.map +6 -0
  47. package/wrangler-dist/cli.d.ts +23948 -0
  48. package/wrangler-dist/cli.js +164439 -134006
  49. package/wrangler-dist/wasm-sync.wasm +0 -0
  50. package/import_meta_url.js +0 -3
  51. package/miniflare-config-stubs/.env.empty +0 -0
  52. package/miniflare-config-stubs/package.empty.json +0 -1
  53. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  54. package/miniflare-dist/index.mjs +0 -79
  55. package/miniflare-dist/index.mjs.map +0 -7
  56. package/pages/functions/buildWorker.ts +0 -62
  57. package/pages/functions/filepath-routing.test.ts +0 -223
  58. package/pages/functions/filepath-routing.ts +0 -181
  59. package/pages/functions/identifiers.ts +0 -78
  60. package/pages/functions/routes.ts +0 -151
  61. package/pages/functions/template-worker.ts +0 -130
  62. package/src/__tests__/configuration.test.ts +0 -2796
  63. package/src/__tests__/dev.test.tsx +0 -496
  64. package/src/__tests__/dev2.test.tsx +0 -154
  65. package/src/__tests__/guess-worker-format.test.ts +0 -58
  66. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  67. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  68. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  69. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  70. package/src/__tests__/helpers/mock-bin.ts +0 -36
  71. package/src/__tests__/helpers/mock-cfetch.ts +0 -207
  72. package/src/__tests__/helpers/mock-console.ts +0 -70
  73. package/src/__tests__/helpers/mock-dialogs.ts +0 -65
  74. package/src/__tests__/helpers/mock-kv.ts +0 -33
  75. package/src/__tests__/helpers/mock-stdin.ts +0 -103
  76. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  77. package/src/__tests__/helpers/run-in-tmp.ts +0 -32
  78. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  79. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  80. package/src/__tests__/https-options.test.ts +0 -127
  81. package/src/__tests__/index.test.ts +0 -991
  82. package/src/__tests__/jest.setup.ts +0 -69
  83. package/src/__tests__/kv.test.ts +0 -1382
  84. package/src/__tests__/logout.test.ts +0 -52
  85. package/src/__tests__/package-manager.test.ts +0 -206
  86. package/src/__tests__/pages.test.ts +0 -44
  87. package/src/__tests__/parse.test.ts +0 -322
  88. package/src/__tests__/publish.test.ts +0 -2704
  89. package/src/__tests__/r2.test.ts +0 -198
  90. package/src/__tests__/route.test.ts +0 -45
  91. package/src/__tests__/secret.test.ts +0 -425
  92. package/src/__tests__/sentry.test.ts +0 -146
  93. package/src/__tests__/tail.test.ts +0 -564
  94. package/src/__tests__/whoami.test.tsx +0 -100
  95. package/src/bundle.ts +0 -142
  96. package/src/cfetch/index.ts +0 -104
  97. package/src/cfetch/internal.ts +0 -139
  98. package/src/cli.ts +0 -19
  99. package/src/config/README.md +0 -107
  100. package/src/config/config.ts +0 -218
  101. package/src/config/diagnostics.ts +0 -80
  102. package/src/config/environment.ts +0 -366
  103. package/src/config/index.ts +0 -62
  104. package/src/config/validation-helpers.ts +0 -486
  105. package/src/config/validation.ts +0 -1090
  106. package/src/create-worker-preview.ts +0 -166
  107. package/src/create-worker-upload-form.ts +0 -217
  108. package/src/dev/dev.tsx +0 -364
  109. package/src/dev/local.tsx +0 -232
  110. package/src/dev/remote.tsx +0 -203
  111. package/src/dev/use-esbuild.ts +0 -100
  112. package/src/dialogs.tsx +0 -77
  113. package/src/entry.ts +0 -208
  114. package/src/environment-variables.ts +0 -33
  115. package/src/https-options.ts +0 -122
  116. package/src/index.tsx +0 -2373
  117. package/src/inspect.ts +0 -617
  118. package/src/kv.ts +0 -319
  119. package/src/miniflare-cli/README.md +0 -30
  120. package/src/miniflare-cli/enum-keys.ts +0 -17
  121. package/src/miniflare-cli/index.ts +0 -37
  122. package/src/module-collection.ts +0 -258
  123. package/src/open-in-browser.ts +0 -25
  124. package/src/package-manager.ts +0 -126
  125. package/src/pages.tsx +0 -1047
  126. package/src/parse.ts +0 -183
  127. package/src/paths.ts +0 -26
  128. package/src/proxy.ts +0 -440
  129. package/src/publish.ts +0 -347
  130. package/src/r2.ts +0 -50
  131. package/src/reporting.ts +0 -131
  132. package/src/selfsigned.d.ts +0 -29
  133. package/src/sites.tsx +0 -280
  134. package/src/tail/filters.ts +0 -279
  135. package/src/tail/index.ts +0 -299
  136. package/src/tail/printing.ts +0 -62
  137. package/src/user.tsx +0 -1118
  138. package/src/whoami.tsx +0 -69
  139. package/src/worker.ts +0 -163
  140. package/templates/static-asset-facade.js +0 -47
  141. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  142. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  143. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  144. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  145. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  146. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  147. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  148. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  149. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  150. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  151. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  152. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  153. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  154. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  155. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  156. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  157. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  158. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  159. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  160. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  161. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  162. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  163. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  164. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  165. package/vendor/wrangler-mime/LICENSE +0 -21
  166. package/vendor/wrangler-mime/Mime.js +0 -97
  167. package/vendor/wrangler-mime/README.md +0 -187
  168. package/vendor/wrangler-mime/cli.js +0 -46
  169. package/vendor/wrangler-mime/index.js +0 -4
  170. package/vendor/wrangler-mime/lite.js +0 -4
  171. package/vendor/wrangler-mime/package.json +0 -52
  172. package/vendor/wrangler-mime/types/other.js +0 -1
  173. package/vendor/wrangler-mime/types/standard.js +0 -1
  174. package/wrangler-dist/cli.js.map +0 -7
@@ -0,0 +1,326 @@
1
+ import {
2
+ createDeferred,
3
+ DeferredPromise,
4
+ urlFromParts,
5
+ } from "../../src/api/startDevWorker/utils";
6
+ import type {
7
+ ProxyData,
8
+ ProxyWorkerIncomingRequestBody,
9
+ ProxyWorkerOutgoingRequestBody,
10
+ } from "../../src/api/startDevWorker/events";
11
+
12
+ interface Env {
13
+ PROXY_CONTROLLER: Fetcher;
14
+ PROXY_CONTROLLER_AUTH_SECRET: string;
15
+ DURABLE_OBJECT: DurableObjectNamespace;
16
+ }
17
+
18
+ // request.cf.hostMetadata is verbose to type using the workers-types Request -- this allows us to have Request correctly typed in this scope
19
+ type Request = Parameters<
20
+ NonNullable<
21
+ ExportedHandler<Env, unknown, ProxyWorkerIncomingRequestBody>["fetch"]
22
+ >
23
+ >[0];
24
+
25
+ const LIVE_RELOAD_PROTOCOL = "WRANGLER_PROXYWORKER_LIVE_RELOAD_PROTOCOL";
26
+ export default {
27
+ fetch(req, env) {
28
+ const singleton = env.DURABLE_OBJECT.idFromName("");
29
+ const inspectorProxy = env.DURABLE_OBJECT.get(singleton);
30
+
31
+ return inspectorProxy.fetch(req);
32
+ },
33
+ } as ExportedHandler<Env, unknown, ProxyWorkerIncomingRequestBody>;
34
+
35
+ export class ProxyWorker implements DurableObject {
36
+ constructor(readonly state: DurableObjectState, readonly env: Env) {}
37
+
38
+ proxyData?: ProxyData;
39
+ requestQueue = new Map<Request, DeferredPromise<Response>>();
40
+ requestRetryQueue = new Map<Request, DeferredPromise<Response>>();
41
+
42
+ fetch(request: Request) {
43
+ if (isRequestForLiveReloadWebsocket(request)) {
44
+ // requests for live-reload websocket
45
+
46
+ return this.handleLiveReloadWebSocket(request);
47
+ }
48
+
49
+ if (isRequestFromProxyController(request, this.env)) {
50
+ // requests from ProxyController
51
+
52
+ return this.processProxyControllerRequest(request);
53
+ }
54
+
55
+ // regular requests to be proxied
56
+ const deferred = createDeferred<Response>();
57
+
58
+ this.requestQueue.set(request, deferred);
59
+ this.processQueue();
60
+
61
+ return deferred.promise;
62
+ }
63
+
64
+ handleLiveReloadWebSocket(request: Request) {
65
+ const { 0: response, 1: liveReload } = new WebSocketPair();
66
+ const websocketProtocol =
67
+ request.headers.get("Sec-WebSocket-Protocol") ?? "";
68
+
69
+ this.state.acceptWebSocket(liveReload, ["live-reload"]);
70
+
71
+ return new Response(null, {
72
+ status: 101,
73
+ webSocket: response,
74
+ headers: { "Sec-WebSocket-Protocol": websocketProtocol },
75
+ });
76
+ }
77
+
78
+ processProxyControllerRequest(request: Request) {
79
+ const event = request.cf?.hostMetadata;
80
+ switch (event?.type) {
81
+ case "pause":
82
+ this.proxyData = undefined;
83
+ break;
84
+
85
+ case "play":
86
+ this.proxyData = event.proxyData;
87
+ this.processQueue();
88
+ this.state
89
+ .getWebSockets("live-reload")
90
+ .forEach((ws) => ws.send("reload"));
91
+
92
+ break;
93
+ }
94
+
95
+ return new Response(null, { status: 204 });
96
+ }
97
+
98
+ /**
99
+ * Process requests that are being retried first, then process newer requests.
100
+ * Requests that are being retried are, by definition, older than requests which haven't been processed yet.
101
+ * We don't need to be more accurate than this re ordering, since the requests are being fired off synchronously.
102
+ */
103
+ *getOrderedQueue() {
104
+ yield* this.requestRetryQueue;
105
+ yield* this.requestQueue;
106
+ }
107
+
108
+ processQueue() {
109
+ const { proxyData } = this; // store proxyData at the moment this function was called
110
+ if (proxyData === undefined) return;
111
+
112
+ for (const [request, deferredResponse] of this.getOrderedQueue()) {
113
+ this.requestRetryQueue.delete(request);
114
+ this.requestQueue.delete(request);
115
+
116
+ const outerUrl = new URL(request.url);
117
+ const headers = new Headers(request.headers);
118
+
119
+ // override url parts for proxying
120
+ const userWorkerUrl = new URL(request.url);
121
+ Object.assign(userWorkerUrl, proxyData.userWorkerUrl);
122
+
123
+ // set request.url in the UserWorker
124
+ const innerUrl = new URL(request.url);
125
+ Object.assign(innerUrl, proxyData.userWorkerInnerUrlOverrides);
126
+ headers.set("MF-Original-URL", innerUrl.href);
127
+ headers.set("MF-Disable-Pretty-Error", "true"); // disables the UserWorker miniflare instance from rendering the pretty error -- instead the ProxyWorker miniflare instance will intercept the json error response and render the pretty error page
128
+
129
+ rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);
130
+
131
+ // merge proxyData headers with the request headers
132
+ for (const [key, value] of Object.entries(proxyData.headers ?? {})) {
133
+ if (value === undefined) continue;
134
+
135
+ if (key.toLowerCase() === "cookie") {
136
+ const existing = request.headers.get("cookie") ?? "";
137
+ headers.set("cookie", `${existing};${value}`);
138
+ } else {
139
+ headers.set(key, value);
140
+ }
141
+ }
142
+
143
+ // explicitly NOT await-ing this promise, we are in a loop and want to process the whole queue quickly + synchronously
144
+ void fetch(userWorkerUrl, new Request(request, { headers }))
145
+ .then((res) => {
146
+ res = new Response(res.body, res);
147
+ rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
148
+
149
+ if (isHtmlResponse(res)) {
150
+ res = insertLiveReloadScript(request, res, this.env, proxyData);
151
+ }
152
+
153
+ deferredResponse.resolve(res);
154
+ })
155
+ .catch((error: Error) => {
156
+ // errors here are network errors or from response post-processing
157
+ // to catch only network errors, use the 2nd param of the fetch.then()
158
+
159
+ // we have crossed an async boundary, so proxyData may have changed
160
+ // if proxyData.userWorkerUrl has changed, it means there is a new downstream UserWorker
161
+ // and that this error is stale since it was for a request to the old UserWorker
162
+ // so here we construct a newUserWorkerUrl so we can compare it to the (old) userWorkerUrl
163
+ const newUserWorkerUrl =
164
+ this.proxyData && urlFromParts(this.proxyData.userWorkerUrl);
165
+
166
+ // only report errors if the downstream proxy has NOT changed
167
+ if (userWorkerUrl.href === newUserWorkerUrl?.href) {
168
+ void sendMessageToProxyController(this.env, {
169
+ type: "error",
170
+ error: {
171
+ name: error.name,
172
+ message: error.message,
173
+ stack: error.stack,
174
+ cause: error.cause,
175
+ },
176
+ });
177
+
178
+ deferredResponse.reject(error);
179
+ }
180
+
181
+ // if the request can be retried (subset of idempotent requests which have no body), requeue it
182
+ else if (request.method === "GET" || request.method === "HEAD") {
183
+ this.requestRetryQueue.set(request, deferredResponse);
184
+ // we would only end up here if the downstream UserWorker is chang*ing*
185
+ // i.e. we are in a `pause`d state and expecting a `play` message soon
186
+ // this request will be processed (retried) when the `play` message arrives
187
+ // for that reason, we do not need to call `this.processQueue` here
188
+ // (but, also, it can't hurt to call it since it bails when
189
+ // in a `pause`d state i.e. `this.proxyData` is undefined)
190
+ }
191
+
192
+ // if the request cannot be retried, respond with 503 Service Unavailable
193
+ // important to note, this is not an (unexpected) error -- it is an acceptable flow of local development
194
+ // it would be incorrect to retry non-idempotent requests
195
+ // and would require cloning all body streams to avoid stream reuse (which is inefficient but not out of the question in the future)
196
+ // this is a good enough UX for now since it solves the most common GET use-case
197
+ else {
198
+ deferredResponse.resolve(
199
+ new Response(
200
+ "Your worker restarted mid-request. Please try sending the request again. Only GET or HEAD requests are retried automatically.",
201
+ {
202
+ status: 503,
203
+ headers: { "Retry-After": "0" },
204
+ }
205
+ )
206
+ );
207
+ }
208
+ });
209
+ }
210
+ }
211
+ }
212
+
213
+ function isRequestFromProxyController(req: Request, env: Env): boolean {
214
+ return req.headers.get("Authorization") === env.PROXY_CONTROLLER_AUTH_SECRET;
215
+ }
216
+ function isHtmlResponse(res: Response): boolean {
217
+ return res.headers.get("content-type")?.startsWith("text/html") ?? false;
218
+ }
219
+ function isRequestForLiveReloadWebsocket(req: Request): boolean {
220
+ const websocketProtocol = req.headers.get("Sec-WebSocket-Protocol");
221
+ const isWebSocketUpgrade = req.headers.get("Upgrade") === "websocket";
222
+
223
+ return isWebSocketUpgrade && websocketProtocol === LIVE_RELOAD_PROTOCOL;
224
+ }
225
+
226
+ function sendMessageToProxyController(
227
+ env: Env,
228
+ message: ProxyWorkerOutgoingRequestBody
229
+ ) {
230
+ return env.PROXY_CONTROLLER.fetch("http://dummy", {
231
+ method: "POST",
232
+ body: JSON.stringify(message),
233
+ });
234
+ }
235
+
236
+ function insertLiveReloadScript(
237
+ request: Request,
238
+ response: Response,
239
+ env: Env,
240
+ proxyData: ProxyData
241
+ ) {
242
+ const htmlRewriter = new HTMLRewriter();
243
+
244
+ // if preview-token-expired response, errorDetails will contain "Invalid Workers Preview configuration"
245
+ let errorDetails = "";
246
+ htmlRewriter.on("#cf-error-details", {
247
+ text(element) {
248
+ errorDetails += element.text;
249
+ },
250
+ });
251
+
252
+ htmlRewriter.onDocument({
253
+ end(end) {
254
+ if (
255
+ response.status === 400 &&
256
+ errorDetails.includes("Invalid Workers Preview configuration")
257
+ ) {
258
+ void sendMessageToProxyController(env, {
259
+ type: "previewTokenExpired",
260
+ proxyData,
261
+ });
262
+ }
263
+
264
+ // if liveReload enabled, append a script tag
265
+ // TODO: compare to existing nodejs implementation
266
+ if (proxyData.liveReload) {
267
+ const websocketUrl = new URL(request.url);
268
+ websocketUrl.protocol =
269
+ websocketUrl.protocol === "http:" ? "ws:" : "wss:";
270
+
271
+ end.append(
272
+ `
273
+ <script>
274
+ (function() {
275
+ var ws;
276
+ function recover() {
277
+ ws = null;
278
+ setTimeout(initLiveReload, 100);
279
+ }
280
+ function initLiveReload() {
281
+ if (ws) return;
282
+ var origin = (location.protocol === "http:" ? "ws://" : "wss://") + location.host;
283
+ ws = new WebSocket(origin + "/cdn-cgi/live-reload", "${LIVE_RELOAD_PROTOCOL}");
284
+ ws.onclose = recover;
285
+ ws.onerror = recover;
286
+ ws.onmessage = location.reload.bind(location);
287
+ }
288
+ })();
289
+ </script>
290
+ `,
291
+ { html: true }
292
+ );
293
+ }
294
+ },
295
+ });
296
+
297
+ return htmlRewriter.transform(response);
298
+ }
299
+
300
+ /**
301
+ * Rewrite references to URLs in request/response headers.
302
+ *
303
+ * This function is used to map the URLs in headers like Origin and Access-Control-Allow-Origin
304
+ * so that this proxy is transparent to the Client Browser and User Worker.
305
+ */
306
+ function rewriteUrlRelatedHeaders(headers: Headers, from: URL, to: URL) {
307
+ const setCookie = headers.getAll("Set-Cookie");
308
+ headers.delete("Set-Cookie");
309
+ headers.forEach((value, key) => {
310
+ if (typeof value === "string" && value.includes(from.host)) {
311
+ headers.set(
312
+ key,
313
+ value.replaceAll(from.origin, to.origin).replaceAll(from.host, to.host)
314
+ );
315
+ }
316
+ });
317
+ for (const cookie of setCookie) {
318
+ headers.append(
319
+ "Set-Cookie",
320
+ cookie.replace(
321
+ new RegExp(`Domain=${from.hostname}($|;|,)`),
322
+ `Domain=${to.hostname}$1`
323
+ )
324
+ );
325
+ }
326
+ }
@@ -0,0 +1,11 @@
1
+ // @ts-nocheck `@types/node` should NOT be included
2
+ Buffer.from("test");
3
+
4
+ // @ts-expect-error `@types/jest` should NOT be included
5
+ test("test");
6
+
7
+ // `@cloudflare/workers-types` should be included
8
+ const _handler: ExportedHandler = {};
9
+ new HTMLRewriter();
10
+
11
+ export {};
@@ -0,0 +1,105 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
+ "lib": [
16
+ "es2021"
17
+ ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
18
+ "jsx": "react" /* Specify what JSX code is generated. */,
19
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
20
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
21
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
22
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
23
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
24
+ // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
25
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
26
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
27
+
28
+ /* Modules */
29
+ "module": "es2022" /* Specify what module code is generated. */,
30
+ // "rootDir": "./", /* Specify the root folder within your source files. */
31
+ "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
36
+ "types": [
37
+ "@cloudflare/workers-types"
38
+ ] /* Specify type package names to be included without being referenced in a source file. */,
39
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
40
+ "resolveJsonModule": true /* Enable importing .json files */,
41
+ // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
42
+
43
+ /* JavaScript Support */
44
+ "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
45
+ "checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
46
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
47
+
48
+ /* Emit */
49
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
50
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
51
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
52
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
53
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
54
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
55
+ // "removeComments": true, /* Disable emitting comments. */
56
+ "noEmit": true /* Disable emitting files from a compilation. */,
57
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
58
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
59
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
60
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
61
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
63
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
64
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
65
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
66
+ // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
67
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
68
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
69
+ // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
70
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
71
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
72
+
73
+ /* Interop Constraints */
74
+ "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
75
+ "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
76
+ // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
77
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
78
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
79
+
80
+ /* Type Checking */
81
+ "strict": true /* Enable all strict type-checking options. */,
82
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
83
+ // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
84
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
85
+ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
86
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
87
+ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
88
+ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
89
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
90
+ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
91
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
92
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
93
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
94
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
95
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
96
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
97
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
98
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
99
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
100
+
101
+ /* Completeness */
102
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
103
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
104
+ }
105
+ }
@@ -1,105 +1,8 @@
1
1
  {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
- "lib": [
16
- "es2021"
17
- ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
18
- // "jsx": "preserve", /* Specify what JSX code is generated. */
19
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
20
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
21
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
22
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
23
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
24
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
25
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
26
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
27
-
28
- /* Modules */
29
- "module": "es2022" /* Specify what module code is generated. */,
30
- // "rootDir": "./", /* Specify the root folder within your source files. */
31
- "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
32
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
36
- "types": [
37
- "@cloudflare/workers-types"
38
- ] /* Specify type package names to be included without being referenced in a source file. */,
39
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
40
- "resolveJsonModule": true /* Enable importing .json files */,
41
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
42
-
43
- /* JavaScript Support */
44
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
45
- "checkJs": true /* Enable error reporting in type-checked JavaScript files. */,
46
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
47
-
48
- /* Emit */
49
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
50
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
51
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
52
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
53
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
54
- // "outDir": "./", /* Specify an output folder for all emitted files. */
55
- // "removeComments": true, /* Disable emitting comments. */
56
- "noEmit": true /* Disable emitting files from a compilation. */,
57
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
58
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
59
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
60
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
61
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
63
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
64
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
65
- // "newLine": "crlf", /* Set the newline character for emitting files. */
66
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
67
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
68
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
69
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
70
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
71
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
72
-
73
- /* Interop Constraints */
74
- "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
75
- "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
76
- // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
77
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
78
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
79
-
80
- /* Type Checking */
81
- "strict": true /* Enable all strict type-checking options. */,
82
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
83
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
84
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
85
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
86
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
87
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
88
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
89
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
90
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
91
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
92
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
93
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
94
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
95
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
96
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
97
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
98
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
99
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
100
-
101
- /* Completeness */
102
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
103
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
104
- }
2
+ "extends": "@cloudflare/workers-tsconfig/tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["@cloudflare/workers-types"]
5
+ },
6
+ "include": ["**/*.ts"],
7
+ "exclude": ["__tests__", "./init-tests/**"]
105
8
  }