wrangler 0.0.0-e7a0cd5b → 0.0.0-e87ad068
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/README.md +3 -3
- package/bin/wrangler.js +30 -10
- package/miniflare-dist/index.mjs +254 -128
- package/package.json +27 -19
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +797 -98
- package/src/__tests__/constellation.test.ts +371 -0
- package/src/__tests__/d1/d1.test.ts +82 -0
- package/src/__tests__/d1/execute.test.ts +66 -0
- package/src/__tests__/d1/migrate.test.ts +257 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +91 -49
- package/src/__tests__/deployments.test.ts +330 -56
- package/src/__tests__/dev.test.tsx +198 -90
- package/src/__tests__/generate.test.ts +12 -10
- package/src/__tests__/guess-worker-format.test.ts +35 -0
- package/src/__tests__/helpers/end-event-loop.ts +6 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/mock-dialogs.ts +71 -85
- package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +128 -27
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/helpers/msw/index.ts +32 -1
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +92 -72
- package/src/__tests__/init.test.ts +1033 -631
- package/src/__tests__/jest.setup.ts +19 -42
- package/src/__tests__/kv.test.ts +355 -231
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +94 -51
- package/src/__tests__/middleware.scheduled.test.ts +42 -32
- package/src/__tests__/middleware.test.ts +212 -122
- package/src/__tests__/mtls-certificates.test.ts +589 -0
- package/src/__tests__/pages/deployment-list.test.ts +80 -0
- package/src/__tests__/pages/functions-build.test.ts +529 -0
- package/src/__tests__/pages/pages.test.ts +81 -0
- package/src/__tests__/pages/project-create.test.ts +63 -0
- package/src/__tests__/pages/project-list.test.ts +110 -0
- package/src/__tests__/pages/project-upload.test.ts +500 -0
- package/src/__tests__/pages/publish.test.ts +2864 -0
- package/src/__tests__/pages-deployment-tail.test.ts +957 -0
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +2227 -1005
- package/src/__tests__/pubsub.test.ts +226 -100
- package/src/__tests__/queues.test.ts +238 -77
- package/src/__tests__/r2.test.ts +55 -57
- package/src/__tests__/secret.test.ts +179 -130
- package/src/__tests__/tail.test.ts +313 -113
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +43 -26
- package/src/__tests__/unstableDev.test.ts +61 -0
- package/src/__tests__/user.test.ts +35 -72
- package/src/__tests__/whoami.test.tsx +8 -114
- package/src/__tests__/worker-namespace.test.ts +83 -69
- package/src/api/dev.ts +180 -60
- package/src/api/index.ts +10 -1
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +80 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +371 -0
- package/src/bundle.ts +315 -148
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +33 -33
- package/src/cli.ts +4 -4
- package/src/config/config.ts +14 -7
- package/src/config/environment.ts +120 -24
- package/src/config/index.ts +117 -35
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +430 -19
- package/src/constellation/createProject.tsx +51 -0
- package/src/constellation/deleteProject.ts +51 -0
- package/src/constellation/deleteProjectModel.ts +76 -0
- package/src/constellation/index.ts +75 -0
- package/src/constellation/listCatalog.tsx +35 -0
- package/src/constellation/listModel.tsx +49 -0
- package/src/constellation/listProject.tsx +28 -0
- package/src/constellation/listRuntime.tsx +28 -0
- package/src/constellation/options.ts +17 -0
- package/src/constellation/types.ts +17 -0
- package/src/constellation/uploadModel.tsx +84 -0
- package/src/constellation/utils.ts +90 -0
- package/src/create-worker-preview.ts +19 -8
- package/src/create-worker-upload-form.ts +81 -18
- package/src/d1/backups.tsx +47 -46
- package/src/d1/constants.ts +5 -0
- package/src/d1/create.tsx +85 -37
- package/src/d1/{delete.tsx → delete.ts} +12 -15
- package/src/d1/execute.tsx +228 -156
- package/src/d1/index.ts +31 -7
- package/src/d1/list.tsx +27 -13
- package/src/d1/migrations/apply.tsx +235 -0
- package/src/d1/migrations/create.tsx +79 -0
- package/src/d1/migrations/helpers.ts +171 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +95 -0
- package/src/d1/migrations/options.ts +23 -0
- package/src/d1/options.ts +12 -2
- package/src/d1/splitter.ts +161 -0
- package/src/d1/types.ts +32 -0
- package/src/d1/utils.ts +12 -2
- package/src/delete.ts +8 -16
- package/src/deployments.ts +340 -46
- package/src/deprecated/index.ts +8 -302
- package/src/dev/dev.tsx +66 -46
- package/src/dev/local.tsx +339 -104
- package/src/dev/remote.tsx +36 -3
- package/src/dev/start-server.ts +146 -101
- package/src/dev/use-esbuild.ts +82 -56
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/{dev-registry.tsx → dev-registry.ts} +13 -1
- package/src/dev.tsx +202 -125
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +21 -17
- package/src/docs/helpers.ts +50 -0
- package/src/docs/index.ts +54 -0
- package/src/entry.ts +26 -11
- package/src/environment-variables/factory.ts +89 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +303 -0
- package/src/git-client.ts +15 -4
- package/src/{index.tsx → index.ts} +148 -63
- package/src/init.ts +301 -197
- package/src/inspect.ts +122 -6
- package/src/jest.d.ts +4 -0
- package/src/kv/helpers.ts +7 -4
- package/src/kv/index.ts +15 -17
- package/src/logger.ts +36 -5
- package/src/metrics/metrics-config.ts +3 -3
- package/src/metrics/send-event.ts +6 -1
- package/src/miniflare-cli/assets.ts +64 -28
- package/src/miniflare-cli/index.ts +6 -9
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +92 -26
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/pages/build.ts +423 -0
- package/src/pages/buildFunctions.ts +140 -0
- package/src/pages/deployment-tails.ts +281 -0
- package/src/pages/deployments.tsx +11 -33
- package/src/pages/{dev.tsx → dev.ts} +192 -126
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +73 -69
- package/src/pages/functions/buildWorker.ts +342 -117
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx → functions.ts} +8 -4
- package/src/pages/{index.tsx → index.ts} +11 -3
- package/src/pages/projects.tsx +12 -22
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +45 -214
- package/src/pages/types.ts +6 -9
- package/src/pages/upload.tsx +58 -14
- package/src/pages/utils.ts +14 -3
- package/src/parse.ts +23 -1
- package/src/paths.ts +1 -1
- package/src/proxy.ts +5 -0
- package/src/publish/index.ts +20 -16
- package/src/publish/publish.ts +81 -48
- package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
- package/src/queues/cli/commands/consumer/add.ts +24 -24
- package/src/queues/cli/commands/consumer/index.ts +3 -6
- package/src/queues/cli/commands/consumer/remove.ts +11 -18
- package/src/queues/cli/commands/create.ts +8 -8
- package/src/queues/cli/commands/delete.ts +8 -8
- package/src/queues/cli/commands/index.ts +6 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/queues/client.ts +1 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +1 -0
- package/src/r2/index.ts +40 -28
- package/src/secret/index.ts +18 -17
- package/src/{sites.tsx → sites.ts} +165 -53
- package/src/tail/createTail.ts +103 -3
- package/src/tail/filters.ts +1 -1
- package/src/tail/index.ts +8 -11
- package/src/tail/printing.ts +27 -0
- package/src/traverse-module-graph.ts +54 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +85 -57
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx → user.ts} +124 -82
- package/src/utils/render.ts +93 -0
- package/src/{whoami.tsx → whoami.ts} +37 -71
- package/src/worker.ts +61 -3
- package/src/yargs-types.ts +22 -5
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +9 -3
- package/templates/d1-beta-facade.js +95 -25
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +8 -6
- package/templates/gitignore +1 -0
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +2 -2
- package/templates/middleware/loader-sw.ts +51 -31
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/new-worker.ts +3 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-dev-util.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +19 -10
- package/templates/serve-static-assets.ts +17 -14
- package/templates/service-bindings-module-facade.js +1 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +105 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +902 -77
- package/wrangler-dist/cli.js +131685 -140615
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/api-devregistry.test.js +0 -57
- package/src/__tests__/d1.test.ts +0 -72
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/__tests__/helpers/mock-cfetch.ts +0 -333
- package/src/__tests__/pages.test.ts +0 -2223
- package/src/d1/types.tsx +0 -14
- package/src/dialogs.tsx +0 -163
- package/src/environment-variables.ts +0 -50
- package/src/pages/build.tsx +0 -238
- package/src/user/env-vars.ts +0 -46
- package/templates/experimental-local-cache-stubs.js +0 -27
- /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
- /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
- /package/src/pages/{hash.tsx → hash.ts} +0 -0
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
Awaitable,
|
|
3
|
+
Dispatcher,
|
|
4
|
+
Middleware,
|
|
5
|
+
__facade_invoke__,
|
|
6
|
+
__facade_register__,
|
|
7
|
+
__facade_registerInternal__,
|
|
8
|
+
} from "./common";
|
|
9
|
+
export { __facade_register__, __facade_registerInternal__ };
|
|
10
|
+
|
|
11
|
+
// Miniflare 2's `EventTarget` follows the spec and doesn't allow exceptions to
|
|
12
|
+
// be caught by `dispatchEvent`. Instead it has a custom `ThrowingEventTarget`
|
|
6
13
|
// class that rethrows errors from event listeners in `dispatchEvent`.
|
|
7
14
|
// We'd like errors to be propagated to the top-level `addEventListener`, so
|
|
8
15
|
// we'd like to use `ThrowingEventTarget`. Unfortunately, `ThrowingEventTarget`
|
|
@@ -15,45 +22,52 @@ if ((globalThis as any).MINIFLARE) {
|
|
|
15
22
|
__FACADE_EVENT_TARGET__ = new EventTarget();
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
listener: EventListenerOrEventListenerObject,
|
|
22
|
-
options?: EventTargetAddEventListenerOptions | boolean
|
|
23
|
-
) => void;
|
|
24
|
-
var __facade_removeEventListener__: (
|
|
25
|
-
type: string,
|
|
26
|
-
listener: EventListenerOrEventListenerObject,
|
|
27
|
-
options?: EventTargetEventListenerOptions | boolean
|
|
28
|
-
) => void;
|
|
29
|
-
var __facade_dispatchEvent__: (event: Event) => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function __facade_isSpecialEvent__(type: string) {
|
|
25
|
+
function __facade_isSpecialEvent__(
|
|
26
|
+
type: string
|
|
27
|
+
): type is "fetch" | "scheduled" {
|
|
33
28
|
return type === "fetch" || type === "scheduled";
|
|
34
29
|
}
|
|
35
|
-
|
|
30
|
+
const __facade__originalAddEventListener__ = globalThis.addEventListener;
|
|
31
|
+
const __facade__originalRemoveEventListener__ = globalThis.removeEventListener;
|
|
32
|
+
const __facade__originalDispatchEvent__ = globalThis.dispatchEvent;
|
|
33
|
+
|
|
34
|
+
globalThis.addEventListener = function (type, listener, options) {
|
|
36
35
|
if (__facade_isSpecialEvent__(type)) {
|
|
37
|
-
__FACADE_EVENT_TARGET__.addEventListener(
|
|
36
|
+
__FACADE_EVENT_TARGET__.addEventListener(
|
|
37
|
+
type,
|
|
38
|
+
listener as EventListenerOrEventListenerObject,
|
|
39
|
+
options
|
|
40
|
+
);
|
|
38
41
|
} else {
|
|
39
|
-
|
|
42
|
+
__facade__originalAddEventListener__(type, listener, options);
|
|
40
43
|
}
|
|
41
44
|
};
|
|
42
|
-
globalThis.
|
|
45
|
+
globalThis.removeEventListener = function (type, listener, options) {
|
|
43
46
|
if (__facade_isSpecialEvent__(type)) {
|
|
44
|
-
__FACADE_EVENT_TARGET__.removeEventListener(
|
|
47
|
+
__FACADE_EVENT_TARGET__.removeEventListener(
|
|
48
|
+
type,
|
|
49
|
+
listener as EventListenerOrEventListenerObject,
|
|
50
|
+
options
|
|
51
|
+
);
|
|
45
52
|
} else {
|
|
46
|
-
|
|
53
|
+
__facade__originalRemoveEventListener__(type, listener, options);
|
|
47
54
|
}
|
|
48
55
|
};
|
|
49
|
-
globalThis.
|
|
56
|
+
globalThis.dispatchEvent = function (event) {
|
|
50
57
|
if (__facade_isSpecialEvent__(event.type)) {
|
|
51
|
-
__FACADE_EVENT_TARGET__.dispatchEvent(event);
|
|
58
|
+
return __FACADE_EVENT_TARGET__.dispatchEvent(event);
|
|
52
59
|
} else {
|
|
53
|
-
|
|
60
|
+
return __facade__originalDispatchEvent__(event);
|
|
54
61
|
}
|
|
55
62
|
};
|
|
56
63
|
|
|
64
|
+
declare global {
|
|
65
|
+
var addMiddleware: typeof __facade_register__;
|
|
66
|
+
var addMiddlewareInternal: typeof __facade_registerInternal__;
|
|
67
|
+
}
|
|
68
|
+
globalThis.addMiddleware = __facade_register__;
|
|
69
|
+
globalThis.addMiddlewareInternal = __facade_registerInternal__;
|
|
70
|
+
|
|
57
71
|
const __facade_waitUntil__ = Symbol("__facade_waitUntil__");
|
|
58
72
|
const __facade_response__ = Symbol("__facade_response__");
|
|
59
73
|
const __facade_dispatched__ = Symbol("__facade_dispatched__");
|
|
@@ -154,7 +168,7 @@ class __Facade_ScheduledEvent__ extends __Facade_ExtendableEvent__ {
|
|
|
154
168
|
}
|
|
155
169
|
}
|
|
156
170
|
|
|
157
|
-
|
|
171
|
+
__facade__originalAddEventListener__("fetch", (event) => {
|
|
158
172
|
const ctx: ExecutionContext = {
|
|
159
173
|
waitUntil: event.waitUntil.bind(event),
|
|
160
174
|
passThroughOnException: event.passThroughOnException.bind(event),
|
|
@@ -169,6 +183,8 @@ globalThis.addEventListener("fetch", (event) => {
|
|
|
169
183
|
});
|
|
170
184
|
|
|
171
185
|
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
|
|
186
|
+
// @ts-expect-error `waitUntil` types are currently broken, blocked on
|
|
187
|
+
// https://github.com/cloudflare/workerd/pull/191
|
|
172
188
|
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
|
|
173
189
|
}
|
|
174
190
|
};
|
|
@@ -181,6 +197,8 @@ globalThis.addEventListener("fetch", (event) => {
|
|
|
181
197
|
|
|
182
198
|
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
|
|
183
199
|
facadeEvent[__facade_dispatched__] = true;
|
|
200
|
+
// @ts-expect-error `waitUntil` types are currently broken, blocked on
|
|
201
|
+
// https://github.com/cloudflare/workerd/pull/191
|
|
184
202
|
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
|
|
185
203
|
|
|
186
204
|
const response = facadeEvent[__facade_response__];
|
|
@@ -201,7 +219,7 @@ globalThis.addEventListener("fetch", (event) => {
|
|
|
201
219
|
);
|
|
202
220
|
});
|
|
203
221
|
|
|
204
|
-
|
|
222
|
+
__facade__originalAddEventListener__("scheduled", (event) => {
|
|
205
223
|
const facadeEvent = new __Facade_ScheduledEvent__("scheduled", {
|
|
206
224
|
scheduledTime: event.scheduledTime,
|
|
207
225
|
cron: event.cron,
|
|
@@ -209,5 +227,7 @@ globalThis.addEventListener("scheduled", (event) => {
|
|
|
209
227
|
});
|
|
210
228
|
|
|
211
229
|
__FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
|
|
230
|
+
// @ts-expect-error `waitUntil` types are currently broken, blocked on
|
|
231
|
+
// https://github.com/cloudflare/workerd/pull/191
|
|
212
232
|
event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
|
|
213
233
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Middleware } from "./common";
|
|
2
|
+
|
|
3
|
+
interface JsonError {
|
|
4
|
+
message?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
cause?: JsonError;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function reduceError(e: any): JsonError {
|
|
11
|
+
return {
|
|
12
|
+
name: e?.name,
|
|
13
|
+
message: e?.message ?? String(e),
|
|
14
|
+
stack: e?.stack,
|
|
15
|
+
cause: e?.cause === undefined ? undefined : reduceError(e.cause),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// See comment in `bundle.ts` for details on why this is needed
|
|
20
|
+
const jsonError: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
|
21
|
+
try {
|
|
22
|
+
return await middlewareCtx.next(request, env);
|
|
23
|
+
} catch (e: any) {
|
|
24
|
+
const error = reduceError(e);
|
|
25
|
+
return Response.json(error, {
|
|
26
|
+
status: 500,
|
|
27
|
+
headers: { "MF-Experimental-Error-Stack": "true" },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default jsonError;
|
package/templates/new-worker.ts
CHANGED
|
@@ -17,6 +17,9 @@ export interface Env {
|
|
|
17
17
|
//
|
|
18
18
|
// Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
|
|
19
19
|
// MY_BUCKET: R2Bucket;
|
|
20
|
+
//
|
|
21
|
+
// Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
|
|
22
|
+
// MY_SERVICE: Fetcher;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export default {
|
|
@@ -7,7 +7,7 @@ import { isRoutingRuleMatch } from "./pages-dev-util";
|
|
|
7
7
|
// @ts-ignore routes are injected
|
|
8
8
|
const routes = __ROUTES__;
|
|
9
9
|
|
|
10
|
-
export default {
|
|
10
|
+
export default <ExportedHandler<{ ASSETS: Fetcher }>>{
|
|
11
11
|
fetch(request, env, context) {
|
|
12
12
|
const { pathname } = new URL(request.url);
|
|
13
13
|
|
|
@@ -19,6 +19,9 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
for (const include of routes.include) {
|
|
21
21
|
if (isRoutingRuleMatch(pathname, include)) {
|
|
22
|
+
if (worker.fetch === undefined) {
|
|
23
|
+
throw new TypeError("Entry point missing `fetch` handler");
|
|
24
|
+
}
|
|
22
25
|
return worker.fetch(request, env, context);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
@@ -45,7 +45,10 @@ function transformRoutingRuleToRegExp(rule: string): RegExp {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// /foo* => /foo.* => ^/foo.*$
|
|
48
|
-
|
|
48
|
+
// /*.* => /*\.* => /.*\..* => ^/.*\..*$
|
|
49
|
+
transformedRule = `^${transformedRule
|
|
50
|
+
.replaceAll(/\./g, "\\.")
|
|
51
|
+
.replaceAll(/\*/g, ".*")}$`;
|
|
49
52
|
|
|
50
53
|
// ^/foo.*$ => /^\/foo.*$/
|
|
51
54
|
return new RegExp(transformedRule);
|
package/templates/pages-shim.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// This Worker is used as a default when no Pages Functions are present.
|
|
2
2
|
// It proxies the request directly on to the asset server binding.
|
|
3
3
|
|
|
4
|
-
export default {
|
|
4
|
+
export default <ExportedHandler<{ ASSETS: Fetcher }>>{
|
|
5
5
|
async fetch(request, env, context) {
|
|
6
|
+
// @ts-expect-error due to a bug in `@cloudflare/workers-types`, the `cf`
|
|
7
|
+
// types from the `request` parameter and `RequestInit` are incompatible.
|
|
8
|
+
// We'll get this fixed very soon.
|
|
6
9
|
const response = await env.ASSETS.fetch(request.url, request);
|
|
7
10
|
return new Response(response.body, response);
|
|
8
11
|
},
|
|
@@ -119,20 +119,25 @@ function* executeRequest(request: Request, relativePathname: string) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export default function (pluginArgs) {
|
|
122
|
+
export default function (pluginArgs: unknown) {
|
|
123
123
|
const onRequest: PagesPluginFunction = async (workerContext) => {
|
|
124
124
|
let { request } = workerContext;
|
|
125
125
|
const { env, next, data } = workerContext;
|
|
126
126
|
|
|
127
127
|
const url = new URL(request.url);
|
|
128
|
+
// TODO: Replace this with something actually legible.
|
|
128
129
|
const relativePathname = `/${
|
|
129
|
-
url.pathname.
|
|
130
|
+
url.pathname.replace(workerContext.functionPath, "") || ""
|
|
130
131
|
}`.replace(/^\/\//, "/");
|
|
131
132
|
|
|
132
133
|
const handlerIterator = executeRequest(request, relativePathname);
|
|
133
134
|
const pluginNext = async (input?: RequestInfo, init?: RequestInit) => {
|
|
134
135
|
if (input !== undefined) {
|
|
135
|
-
|
|
136
|
+
let url = input;
|
|
137
|
+
if (typeof input === "string") {
|
|
138
|
+
url = new URL(input, request.url).toString();
|
|
139
|
+
}
|
|
140
|
+
request = new Request(url, init);
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
const result = handlerIterator.next();
|
|
@@ -140,7 +145,7 @@ export default function (pluginArgs) {
|
|
|
140
145
|
if (result.done === false) {
|
|
141
146
|
const { handler, params, path } = result.value;
|
|
142
147
|
const context = {
|
|
143
|
-
request,
|
|
148
|
+
request: new Request(request.clone()),
|
|
144
149
|
functionPath: workerContext.functionPath + path,
|
|
145
150
|
next: pluginNext,
|
|
146
151
|
params,
|
|
@@ -154,13 +159,9 @@ export default function (pluginArgs) {
|
|
|
154
159
|
|
|
155
160
|
const response = await handler(context);
|
|
156
161
|
|
|
157
|
-
|
|
158
|
-
return new Response(
|
|
159
|
-
[101, 204, 205, 304].includes(response.status) ? null : response.body,
|
|
160
|
-
{ ...response, headers: new Headers(response.headers) }
|
|
161
|
-
);
|
|
162
|
+
return cloneResponse(response);
|
|
162
163
|
} else {
|
|
163
|
-
return next();
|
|
164
|
+
return next(request);
|
|
164
165
|
}
|
|
165
166
|
};
|
|
166
167
|
|
|
@@ -169,3 +170,11 @@ export default function (pluginArgs) {
|
|
|
169
170
|
|
|
170
171
|
return onRequest;
|
|
171
172
|
}
|
|
173
|
+
|
|
174
|
+
// This makes a Response mutable
|
|
175
|
+
const cloneResponse = (response: Response) =>
|
|
176
|
+
// https://fetch.spec.whatwg.org/#null-body-status
|
|
177
|
+
new Response(
|
|
178
|
+
[101, 204, 205, 304].includes(response.status) ? null : response.body,
|
|
179
|
+
response
|
|
180
|
+
);
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
// @ts-expect-error
|
|
2
1
|
import worker from "__ENTRY_POINT__";
|
|
3
2
|
import {
|
|
4
3
|
getAssetFromKV,
|
|
5
4
|
NotFoundError,
|
|
6
5
|
MethodNotAllowedError,
|
|
7
|
-
|
|
6
|
+
serveSinglePageApp,
|
|
8
7
|
} from "__KV_ASSET_HANDLER__";
|
|
9
|
-
|
|
8
|
+
import type { Options, CacheControl } from "__KV_ASSET_HANDLER__";
|
|
10
9
|
import manifest from "__STATIC_CONTENT_MANIFEST";
|
|
11
10
|
import type * as kvAssetHandler from "@cloudflare/kv-asset-handler";
|
|
12
11
|
|
|
13
12
|
const ASSET_MANIFEST = JSON.parse(manifest);
|
|
14
13
|
|
|
15
|
-
// @ts-expect-error
|
|
16
14
|
export * from "__ENTRY_POINT__";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
// Injected as `esbuild` `define`s
|
|
17
|
+
declare global {
|
|
18
|
+
const __CACHE_CONTROL_OPTIONS__: Partial<CacheControl>;
|
|
19
|
+
const __SERVE_SINGLE_PAGE_APP__: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default <ExportedHandler<{ __STATIC_CONTENT: KVNamespace }>>{
|
|
23
|
+
...worker,
|
|
24
|
+
async fetch(request, env, ctx) {
|
|
25
|
+
let options: Partial<Options> = {
|
|
25
26
|
ASSET_MANIFEST,
|
|
26
27
|
ASSET_NAMESPACE: env.__STATIC_CONTENT,
|
|
27
28
|
cacheControl: __CACHE_CONTROL_OPTIONS__,
|
|
28
|
-
|
|
29
|
+
mapRequestToAsset: __SERVE_SINGLE_PAGE_APP__
|
|
30
|
+
? serveSinglePageApp
|
|
31
|
+
: undefined,
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
try {
|
|
@@ -34,7 +37,7 @@ export default {
|
|
|
34
37
|
)(
|
|
35
38
|
{
|
|
36
39
|
request,
|
|
37
|
-
waitUntil(promise
|
|
40
|
+
waitUntil(promise) {
|
|
38
41
|
return ctx.waitUntil(promise);
|
|
39
42
|
},
|
|
40
43
|
},
|
|
@@ -54,7 +57,7 @@ export default {
|
|
|
54
57
|
} catch (e) {
|
|
55
58
|
if (e instanceof NotFoundError || e instanceof MethodNotAllowedError) {
|
|
56
59
|
// if a known error is thrown then serve from actual worker
|
|
57
|
-
return await worker.fetch(request, env, ctx);
|
|
60
|
+
return await worker.fetch?.(request, env, ctx);
|
|
58
61
|
}
|
|
59
62
|
// otherwise it's a real error, so throw it
|
|
60
63
|
throw e;
|
|
@@ -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
|
+
}
|
package/templates/tsconfig.json
CHANGED
|
@@ -1,106 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
"jest"
|
|
39
|
-
] /* Specify type package names to be included without being referenced in a source file. */,
|
|
40
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
41
|
-
"resolveJsonModule": true /* Enable importing .json files */,
|
|
42
|
-
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
43
|
-
|
|
44
|
-
/* JavaScript Support */
|
|
45
|
-
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
|
|
46
|
-
"checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
|
|
47
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
|
48
|
-
|
|
49
|
-
/* Emit */
|
|
50
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
51
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
52
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
53
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
54
|
-
// "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. */
|
|
55
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
56
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
57
|
-
"noEmit": true /* Disable emitting files from a compilation. */,
|
|
58
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
59
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
|
60
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
61
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
62
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
63
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
64
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
65
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
66
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
67
|
-
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
|
68
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
|
69
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
70
|
-
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
|
71
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
72
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
73
|
-
|
|
74
|
-
/* Interop Constraints */
|
|
75
|
-
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
76
|
-
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
|
|
77
|
-
// "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
|
78
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
79
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
80
|
-
|
|
81
|
-
/* Type Checking */
|
|
82
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
83
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
84
|
-
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
85
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
86
|
-
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
|
87
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
88
|
-
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
|
89
|
-
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
|
90
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
91
|
-
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
|
92
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
|
93
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
94
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
95
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
96
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
97
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
98
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
|
99
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
100
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
101
|
-
|
|
102
|
-
/* Completeness */
|
|
103
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
104
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
105
|
-
}
|
|
4
|
+
"types": ["@cloudflare/workers-types"]
|
|
5
|
+
},
|
|
6
|
+
"include": ["**/*.ts"],
|
|
7
|
+
"exclude": ["__tests__", "./init-tests/**"]
|
|
106
8
|
}
|