rspack-plugin-cloudflare 0.1.0 → 0.2.0
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 +8 -5
- package/THIRD_PARTY_NOTICES.txt +139 -0
- package/dist/index.d.ts +51 -7
- package/dist/index.js +3591 -131
- package/dist/index.js.map +1 -1
- package/dist/workers/asset-worker/index.js +5783 -0
- package/dist/workers/asset-worker/index.js.map +1 -0
- package/dist/workers/router-worker/index.js +6245 -0
- package/dist/workers/router-worker/index.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets.d.ts +0 -31
- package/dist/assets.js +0 -112
- package/dist/assets.js.map +0 -1
- package/dist/build.d.ts +0 -216
- package/dist/build.js +0 -140
- package/dist/build.js.map +0 -1
- package/dist/config.d.ts +0 -19
- package/dist/config.js +0 -103
- package/dist/config.js.map +0 -1
- package/dist/containers.d.ts +0 -30
- package/dist/containers.js +0 -167
- package/dist/containers.js.map +0 -1
- package/dist/dev-entry.d.ts +0 -11
- package/dist/dev-entry.js +0 -44
- package/dist/dev-entry.js.map +0 -1
- package/dist/dev-worker.d.ts +0 -73
- package/dist/dev-worker.js +0 -247
- package/dist/dev-worker.js.map +0 -1
- package/dist/dev.d.ts +0 -28
- package/dist/dev.js +0 -422
- package/dist/dev.js.map +0 -1
- package/dist/http.d.ts +0 -23
- package/dist/http.js +0 -89
- package/dist/http.js.map +0 -1
- package/dist/inspector.d.ts +0 -5
- package/dist/inspector.js +0 -41
- package/dist/inspector.js.map +0 -1
- package/dist/miniflare.d.ts +0 -1
- package/dist/miniflare.js +0 -6
- package/dist/miniflare.js.map +0 -1
- package/dist/module-rules.d.ts +0 -4
- package/dist/module-rules.js +0 -29
- package/dist/module-rules.js.map +0 -1
- package/dist/nodejs-compat.d.ts +0 -14
- package/dist/nodejs-compat.js +0 -46
- package/dist/nodejs-compat.js.map +0 -1
- package/dist/options.d.ts +0 -45
- package/dist/options.js +0 -2
- package/dist/options.js.map +0 -1
- package/dist/routing.d.ts +0 -12
- package/dist/routing.js +0 -40
- package/dist/routing.js.map +0 -1
- package/dist/tunnel.d.ts +0 -15
- package/dist/tunnel.js +0 -94
- package/dist/tunnel.js.map +0 -1
- package/dist/worker-config.d.ts +0 -42
- package/dist/worker-config.js +0 -194
- package/dist/worker-config.js.map +0 -1
- package/src/assets.ts +0 -148
- package/src/build.ts +0 -153
- package/src/config.ts +0 -138
- package/src/containers.ts +0 -183
- package/src/dev-entry.ts +0 -50
- package/src/dev-worker.ts +0 -297
- package/src/dev.ts +0 -478
- package/src/http.ts +0 -102
- package/src/index.ts +0 -164
- package/src/inspector.ts +0 -44
- package/src/miniflare.ts +0 -7
- package/src/module-rules.ts +0 -36
- package/src/nodejs-compat.ts +0 -63
- package/src/options.ts +0 -46
- package/src/routing.ts +0 -48
- package/src/tunnel.ts +0 -106
- package/src/worker-config.ts +0 -237
package/dist/module-rules.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
// wrangler's defaults, which apply after any rules in the config
|
|
3
|
-
const DEFAULT_RULES = [
|
|
4
|
-
{ type: 'Text', globs: ['**/*.txt', '**/*.html', '**/*.sql'] },
|
|
5
|
-
{ type: 'Data', globs: ['**/*.bin'] },
|
|
6
|
-
{ type: 'CompiledWasm', globs: ['**/*.wasm', '**/*.wasm?module'] },
|
|
7
|
-
];
|
|
8
|
-
const MODULE_TYPES = ['CompiledWasm', 'Data', 'Text'];
|
|
9
|
-
function isModuleType(type) {
|
|
10
|
-
return MODULE_TYPES.includes(type);
|
|
11
|
-
}
|
|
12
|
-
/** Maps file extensions to the non-JS module type wrangler would give them, with config rules taking precedence. */
|
|
13
|
-
export function getModuleTypes(worker) {
|
|
14
|
-
const types = new Map();
|
|
15
|
-
for (const rule of [...worker.config.rules, ...DEFAULT_RULES]) {
|
|
16
|
-
if (!isModuleType(rule.type)) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
for (const glob of rule.globs) {
|
|
20
|
-
// wrangler's module rules use `**/*.ext` style globs, so the extension is all that matters
|
|
21
|
-
const extension = path.extname(glob.replace(/\?.*$/, ''));
|
|
22
|
-
if (extension && !types.has(extension)) {
|
|
23
|
-
types.set(extension, rule.type);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return types;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=module-rules.js.map
|
package/dist/module-rules.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-rules.js","sourceRoot":"","sources":["../src/module-rules.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,iEAAiE;AACjE,MAAM,aAAa,GAA6C;IAC/D,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE;IAC9D,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE;IACrC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,WAAW,EAAE,kBAAkB,CAAC,EAAE;CAClE,CAAC;AAEF,MAAM,YAAY,GAAsB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAwB,CAAC;AAEhG,SAAS,YAAY,CAAC,IAAY;IACjC,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACpD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,SAAS;QACV,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/B,2FAA2F;YAC3F,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1D,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBACxC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/dist/nodejs-compat.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ResolvedWorker } from './config.js';
|
|
2
|
-
export interface NodeJsCompat {
|
|
3
|
-
/** Builtin specifiers workerd provides natively, mapped to the specifier to import at runtime. */
|
|
4
|
-
externals: Map<string, string>;
|
|
5
|
-
/** Builtin specifiers workerd lacks, mapped to the unenv polyfill file that replaces them. */
|
|
6
|
-
polyfills: Map<string, string>;
|
|
7
|
-
/** A module that sets up injected globals like `process` and runs polyfills, when the preset needs any. */
|
|
8
|
-
injectSource: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Applies Cloudflare's unenv preset, as wrangler and the Vite plugin do: modules workerd has natively stay external,
|
|
12
|
-
* the rest are polyfilled, and globals like `process` are injected for older compatibility dates.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getNodeJsCompat(worker: ResolvedWorker): NodeJsCompat | undefined;
|
package/dist/nodejs-compat.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { getCloudflarePreset } from '@cloudflare/unenv-preset';
|
|
3
|
-
import { defineEnv } from 'unenv';
|
|
4
|
-
import { miniflare } from './miniflare.js';
|
|
5
|
-
function resolvePolyfill(specifier) {
|
|
6
|
-
// polyfills are this package's dependencies, which the user's project can't necessarily resolve
|
|
7
|
-
return fileURLToPath(import.meta.resolve(specifier));
|
|
8
|
-
}
|
|
9
|
-
function createInjectSource(inject, polyfills) {
|
|
10
|
-
const lines = [];
|
|
11
|
-
for (const [index, [globalName, specifier]] of Object.entries(inject).entries()) {
|
|
12
|
-
const [moduleSpecifier, exportName] = typeof specifier === 'string' ? [specifier, 'default'] : specifier;
|
|
13
|
-
if (!moduleSpecifier || !exportName) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
lines.push(`import { ${exportName} as inject${index} } from ${JSON.stringify(resolvePolyfill(moduleSpecifier))};`, `globalThis.${globalName} = inject${index};`);
|
|
17
|
-
}
|
|
18
|
-
for (const polyfill of polyfills) {
|
|
19
|
-
lines.push(`import ${JSON.stringify(resolvePolyfill(polyfill))};`);
|
|
20
|
-
}
|
|
21
|
-
return lines.length > 0 ? lines.join('\n') : undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Applies Cloudflare's unenv preset, as wrangler and the Vite plugin do: modules workerd has natively stay external,
|
|
25
|
-
* the rest are polyfilled, and globals like `process` are injected for older compatibility dates.
|
|
26
|
-
*/
|
|
27
|
-
export function getNodeJsCompat(worker) {
|
|
28
|
-
const { compatibility_date: compatibilityDate, compatibility_flags: compatibilityFlags } = worker.config;
|
|
29
|
-
if (!miniflare.getNodeCompat(compatibilityDate, compatibilityFlags).isNodejsCompatEnabled) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
const { env } = defineEnv({ presets: [getCloudflarePreset({ compatibilityDate, compatibilityFlags })] });
|
|
33
|
-
const nativeModules = new Set(env.external);
|
|
34
|
-
const externals = new Map();
|
|
35
|
-
const polyfills = new Map();
|
|
36
|
-
for (const [specifier, target] of Object.entries(env.alias)) {
|
|
37
|
-
if (nativeModules.has(target)) {
|
|
38
|
-
externals.set(specifier, target);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
polyfills.set(specifier, resolvePolyfill(target));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { externals, polyfills, injectSource: createInjectSource(env.inject, env.polyfill) };
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=nodejs-compat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodejs-compat.js","sourceRoot":"","sources":["../src/nodejs-compat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAa3C,SAAS,eAAe,CAAC,SAAiB;IACzC,gGAAgG;IAChG,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAkD,EAAE,SAA4B;IAC3G,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QACjF,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,CAAC;YACrC,SAAS;QACV,CAAC;QACD,KAAK,CAAC,IAAI,CACT,YAAY,UAAU,aAAa,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,EACtG,cAAc,UAAU,YAAY,KAAK,GAAG,CAC5C,CAAC;IACH,CAAC;IACD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,MAAM,CAAC,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC7F,CAAC"}
|
package/dist/options.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { RspackOptions } from '@rspack/core';
|
|
2
|
-
import type { Unstable_Config } from 'wrangler';
|
|
3
|
-
export type WorkerConfig = Unstable_Config;
|
|
4
|
-
/** Overrides merged into the Wrangler config after it loads, or a function that edits or returns overrides. */
|
|
5
|
-
export type WorkerConfigCustomizer = Partial<WorkerConfig> | ((config: WorkerConfig) => Partial<WorkerConfig> | void);
|
|
6
|
-
export interface AuxiliaryWorkerOptions {
|
|
7
|
-
/** Wrangler config for the auxiliary Worker, relative to the rspack `context`. */
|
|
8
|
-
configPath: string;
|
|
9
|
-
/** Changes the auxiliary Worker's config in code, applied after its config file loads. */
|
|
10
|
-
config?: WorkerConfigCustomizer;
|
|
11
|
-
/** Where `rspack build` writes it, relative to its Wrangler config. Defaults to `dist/<worker name>`. */
|
|
12
|
-
outputDir?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface TunnelOptions {
|
|
15
|
-
/** An existing named tunnel with a route to the dev server. Without one, a Quick Tunnel gets a random trycloudflare.com URL. */
|
|
16
|
-
name?: string;
|
|
17
|
-
/** Email addresses or `*@domain` patterns allowed through a Quick Tunnel, which then asks visitors to sign in. */
|
|
18
|
-
allowedMail?: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface CloudflarePluginOptions {
|
|
21
|
-
/** Wrangler config file, relative to the rspack `context`. Defaults to the nearest wrangler.jsonc, wrangler.json or wrangler.toml at or above `context`. */
|
|
22
|
-
configPath?: string;
|
|
23
|
-
/** Changes the Worker config in code, applied after the config file loads. */
|
|
24
|
-
config?: WorkerConfigCustomizer;
|
|
25
|
-
/** Wrangler environment to use, like `wrangler --env`, for every Worker. Defaults to `CLOUDFLARE_ENV`. */
|
|
26
|
-
environment?: string;
|
|
27
|
-
/** More Workers the entry Worker reaches through service bindings, run and built alongside it. */
|
|
28
|
-
auxiliaryWorkers?: AuxiliaryWorkerOptions[];
|
|
29
|
-
/** Adjusts the rspack config used to bundle a Worker. Return a new config or mutate the one given. */
|
|
30
|
-
worker?: (config: RspackOptions, context: {
|
|
31
|
-
name: string;
|
|
32
|
-
}) => RspackOptions | void;
|
|
33
|
-
/** Where `rspack build` writes the Worker bundle and its generated `wrangler.json`, relative to the Wrangler config. Defaults to `dist/<worker name>`. */
|
|
34
|
-
outputDir?: string;
|
|
35
|
-
/** Where local binding state (KV, Durable Objects, etc.) lives in dev, relative to the Wrangler config. `false` keeps it in memory. Defaults to `.wrangler/state`, shared with `wrangler dev`. */
|
|
36
|
-
persistState?: boolean | {
|
|
37
|
-
path: string;
|
|
38
|
-
};
|
|
39
|
-
/** Port for the workerd inspector in dev, or `false` to turn it off. Defaults to 9229, or the next free port. */
|
|
40
|
-
inspectorPort?: number | false;
|
|
41
|
-
/** Connects bindings marked `remote: true` to their real resources on Cloudflare in dev. `false` keeps every binding local. */
|
|
42
|
-
remoteBindings?: boolean;
|
|
43
|
-
/** Shares the dev server publicly through a Cloudflare Tunnel once it's listening. */
|
|
44
|
-
tunnel?: boolean | TunnelOptions;
|
|
45
|
-
}
|
package/dist/options.js
DELETED
package/dist/options.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
|
package/dist/routing.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface StaticRouting {
|
|
2
|
-
/** Paths that always go to the Worker. */
|
|
3
|
-
userWorker: RegExp[];
|
|
4
|
-
/** Paths that always skip the Worker, from `!/` rules. */
|
|
5
|
-
assetWorker: RegExp[];
|
|
6
|
-
}
|
|
7
|
-
/** Mirrors `assets.run_worker_first`, where `true` sends everything to the Worker and an array holds `/` and `!/` glob rules. */
|
|
8
|
-
export declare function parseStaticRouting(runWorkerFirst: boolean | string[] | undefined): StaticRouting;
|
|
9
|
-
type Route = 'worker' | 'asset' | 'asset-then-worker';
|
|
10
|
-
/** Negative rules win over positive ones, matching Cloudflare's router. */
|
|
11
|
-
export declare function routeRequest(routing: StaticRouting, pathname: string, hasAssets: boolean): Route;
|
|
12
|
-
export {};
|
package/dist/routing.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function ruleToRegExp(rule) {
|
|
2
|
-
const escaped = rule.split('*').map(part => part.replaceAll(/[$()+.?[\\\]^{|}]/g, String.raw `\$&`));
|
|
3
|
-
return new RegExp(`^${escaped.join('.*')}$`);
|
|
4
|
-
}
|
|
5
|
-
/** Mirrors `assets.run_worker_first`, where `true` sends everything to the Worker and an array holds `/` and `!/` glob rules. */
|
|
6
|
-
export function parseStaticRouting(runWorkerFirst) {
|
|
7
|
-
if (runWorkerFirst === true) {
|
|
8
|
-
return { userWorker: [/^\/.*$/], assetWorker: [] };
|
|
9
|
-
}
|
|
10
|
-
const routing = { userWorker: [], assetWorker: [] };
|
|
11
|
-
if (!Array.isArray(runWorkerFirst)) {
|
|
12
|
-
return routing;
|
|
13
|
-
}
|
|
14
|
-
for (const rule of runWorkerFirst) {
|
|
15
|
-
if (rule.startsWith('!/')) {
|
|
16
|
-
routing.assetWorker.push(ruleToRegExp(rule.slice(1)));
|
|
17
|
-
}
|
|
18
|
-
else if (rule.startsWith('/')) {
|
|
19
|
-
routing.userWorker.push(ruleToRegExp(rule));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw new Error(`Invalid \`run_worker_first\` rule '${rule}': rules must start with '/' or '!/'.`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return routing;
|
|
26
|
-
}
|
|
27
|
-
/** Negative rules win over positive ones, matching Cloudflare's router. */
|
|
28
|
-
export function routeRequest(routing, pathname, hasAssets) {
|
|
29
|
-
if (!hasAssets) {
|
|
30
|
-
return 'worker';
|
|
31
|
-
}
|
|
32
|
-
if (routing.assetWorker.some(rule => rule.test(pathname))) {
|
|
33
|
-
return 'asset';
|
|
34
|
-
}
|
|
35
|
-
if (routing.userWorker.some(rule => rule.test(pathname))) {
|
|
36
|
-
return 'worker';
|
|
37
|
-
}
|
|
38
|
-
return 'asset-then-worker';
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=routing.js.map
|
package/dist/routing.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AAOA,SAAS,YAAY,CAAC,IAAY;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG,CAAA,KAAK,CAAC,CAAC,CAAC;IACpG,OAAO,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,iIAAiI;AACjI,MAAM,UAAU,kBAAkB,CAAC,cAA8C;IAChF,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACpD,CAAC;IACD,MAAM,OAAO,GAAkB,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACnE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,uCAAuC,CAAC,CAAC;QACpG,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAID,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,OAAsB,EAAE,QAAgB,EAAE,SAAkB;IACxF,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC5B,CAAC"}
|
package/dist/tunnel.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { TunnelOptions, WorkerConfig } from './options.js';
|
|
2
|
-
export interface Tunnel {
|
|
3
|
-
urls: string[];
|
|
4
|
-
close: () => void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Shares the dev server through a Cloudflare Tunnel: a Quick Tunnel on a random trycloudflare.com URL, or a named
|
|
8
|
-
* tunnel whose routes point at the dev server. wrangler runs it, so it downloads and updates cloudflared as needed.
|
|
9
|
-
*/
|
|
10
|
-
export declare function startTunnel(options: {
|
|
11
|
-
origin: URL;
|
|
12
|
-
tunnel: TunnelOptions;
|
|
13
|
-
config: WorkerConfig;
|
|
14
|
-
cwd: string;
|
|
15
|
-
}): Promise<Tunnel>;
|
package/dist/tunnel.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { unstable_resolveNamedTunnel } from 'wrangler';
|
|
5
|
-
const QUICK_TUNNEL_URL_RE = /https:\/\/[\da-z-]+\.trycloudflare\.com/;
|
|
6
|
-
// cloudflared logs this once the edge accepts the tunnel, which is when the public URL starts working
|
|
7
|
-
const CONNECTED_RE = /Registered tunnel connection/;
|
|
8
|
-
const STARTUP_TIMEOUT_MS = 30000;
|
|
9
|
-
function getWranglerBin() {
|
|
10
|
-
const require = createRequire(import.meta.url);
|
|
11
|
-
return path.join(path.dirname(require.resolve('wrangler/package.json')), 'bin', 'wrangler.js');
|
|
12
|
-
}
|
|
13
|
-
function stopProcessTree(child) {
|
|
14
|
-
if (child.exitCode !== null || child.pid === undefined) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (process.platform === 'win32') {
|
|
18
|
-
// Windows has no SIGTERM for wrangler to forward, so cloudflared would outlive it without killing the whole tree
|
|
19
|
-
spawn('taskkill', ['/pid', String(child.pid), '/t', '/f'], { stdio: 'ignore' });
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
child.kill('SIGTERM');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function waitUntilConnected(child, isNamed) {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
let output = '';
|
|
28
|
-
let quickUrl;
|
|
29
|
-
let settled = false;
|
|
30
|
-
function fail(error) {
|
|
31
|
-
if (!settled) {
|
|
32
|
-
settled = true;
|
|
33
|
-
stopProcessTree(child);
|
|
34
|
-
reject(error);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function onData(data) {
|
|
38
|
-
// only kept for the error message, so a long-running tunnel doesn't keep growing it
|
|
39
|
-
if (output.length < 20000) {
|
|
40
|
-
output += String(data);
|
|
41
|
-
}
|
|
42
|
-
quickUrl ??= QUICK_TUNNEL_URL_RE.exec(output)?.[0];
|
|
43
|
-
if (!settled && CONNECTED_RE.test(output) && (isNamed || quickUrl)) {
|
|
44
|
-
settled = true;
|
|
45
|
-
resolve(quickUrl);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
AbortSignal.timeout(STARTUP_TIMEOUT_MS).addEventListener('abort', () => {
|
|
49
|
-
fail(new Error(`The tunnel didn't connect within ${STARTUP_TIMEOUT_MS / 1000}s:\n${output}`));
|
|
50
|
-
});
|
|
51
|
-
child.stdout?.on('data', onData);
|
|
52
|
-
child.stderr?.on('data', onData);
|
|
53
|
-
child.once('error', fail);
|
|
54
|
-
child.once('exit', (code) => {
|
|
55
|
-
fail(new Error(`wrangler tunnel exited with code ${String(code)}:\n${output}`));
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Shares the dev server through a Cloudflare Tunnel: a Quick Tunnel on a random trycloudflare.com URL, or a named
|
|
61
|
-
* tunnel whose routes point at the dev server. wrangler runs it, so it downloads and updates cloudflared as needed.
|
|
62
|
-
*/
|
|
63
|
-
export async function startTunnel(options) {
|
|
64
|
-
const { origin, tunnel, config } = options;
|
|
65
|
-
const args = ['tunnel'];
|
|
66
|
-
const env = { ...process.env };
|
|
67
|
-
let urls = [];
|
|
68
|
-
if (tunnel.name === undefined) {
|
|
69
|
-
args.push('quick-start', origin.href, ...(tunnel.allowedMail ?? []).flatMap(mail => ['--allowed-mail', mail]));
|
|
70
|
-
if (origin.protocol === 'https:') {
|
|
71
|
-
// the dev server's certificate is for the developer's own hostname, never the loopback address cloudflared dials
|
|
72
|
-
env.NO_TLS_VERIFY = 'true';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
if (tunnel.allowedMail?.length) {
|
|
77
|
-
throw new Error('`tunnel.allowedMail` only works with Quick Tunnels; protect a named tunnel with Cloudflare Access instead.');
|
|
78
|
-
}
|
|
79
|
-
// also checks the tunnel has a route to this dev server, which is the usual setup mistake
|
|
80
|
-
const { hostnames } = await unstable_resolveNamedTunnel(tunnel.name, origin, {
|
|
81
|
-
accountId: config.account_id,
|
|
82
|
-
complianceRegion: config.compliance_region,
|
|
83
|
-
});
|
|
84
|
-
urls = hostnames.map(hostname => `https://${hostname}`);
|
|
85
|
-
args.push('run', tunnel.name);
|
|
86
|
-
}
|
|
87
|
-
const child = spawn(process.execPath, [getWranglerBin(), ...args], { cwd: options.cwd, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
88
|
-
const quickUrl = await waitUntilConnected(child, tunnel.name !== undefined);
|
|
89
|
-
if (quickUrl) {
|
|
90
|
-
urls = [quickUrl];
|
|
91
|
-
}
|
|
92
|
-
return { urls, close: () => stopProcessTree(child) };
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=tunnel.js.map
|
package/dist/tunnel.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../src/tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAKvD,MAAM,mBAAmB,GAAG,yCAAyC,CAAC;AACtE,sGAAsG;AACtG,MAAM,YAAY,GAAG,8BAA8B,CAAC;AACpD,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAOjC,SAAS,cAAc;IACtB,MAAM,OAAO,GA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,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAC5E,IAAI,QAAQ,EAAE,CAAC;QACd,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;AACtD,CAAC"}
|
package/dist/worker-config.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ResolvedWorker } from './config.js';
|
|
2
|
-
import type { CloudflarePluginOptions } from './options.js';
|
|
3
|
-
import type { Compiler, RspackOptions, RspackPluginInstance } from '@rspack/core';
|
|
4
|
-
/** The rspack plugin that holds generated modules, which dev rewrites when the Worker's exports change. */
|
|
5
|
-
export type VirtualModules = InstanceType<Compiler['rspack']['experiments']['VirtualModulesPlugin']>;
|
|
6
|
-
/** Output subdirectory for assets Worker code imports, laid out the way the assets directory serves them. */
|
|
7
|
-
export declare const IMPORTED_ASSETS_DIR = "imported-assets";
|
|
8
|
-
interface AdditionalModule {
|
|
9
|
-
/** File name in the output directory, which is also how the bundle imports it. */
|
|
10
|
-
fileName: string;
|
|
11
|
-
type: 'CompiledWasm' | 'Data';
|
|
12
|
-
}
|
|
13
|
-
/** Copies imported `.wasm`/`.bin` files next to the bundle, where workerd loads them as their own modules. */
|
|
14
|
-
export declare class AdditionalModulesPlugin implements RspackPluginInstance {
|
|
15
|
-
#private;
|
|
16
|
-
/** Every file emitted so far; dev passes these to Miniflare, since rspack's incremental asset list can leave them out. */
|
|
17
|
-
get modules(): AdditionalModule[];
|
|
18
|
-
/** Records a file to emit and returns the specifier the bundle should import it by. */
|
|
19
|
-
add(sourcePath: string, type: AdditionalModule['type']): string;
|
|
20
|
-
apply(compiler: Compiler): void;
|
|
21
|
-
}
|
|
22
|
-
/** Builds the rspack config for the Worker bundle: a single ESM file workerd can load as-is. */
|
|
23
|
-
export declare function createWorkerConfig(options: {
|
|
24
|
-
compiler: Compiler;
|
|
25
|
-
worker: ResolvedWorker;
|
|
26
|
-
pluginOptions: CloudflarePluginOptions;
|
|
27
|
-
outputDir: string;
|
|
28
|
-
/** The module to bundle. */
|
|
29
|
-
entry: string;
|
|
30
|
-
/** Source for `entry` when it isn't a real file, like dev's wrapper around `main`. */
|
|
31
|
-
entrySource?: string;
|
|
32
|
-
mode: 'development' | 'production';
|
|
33
|
-
/** Builds in rspack's HMR runtime so dev can update the running Worker in place. */
|
|
34
|
-
hot?: boolean;
|
|
35
|
-
/** Where HMR imports update chunks from; workerd has no import.meta.url to derive it from. */
|
|
36
|
-
publicPath?: string;
|
|
37
|
-
}): {
|
|
38
|
-
config: RspackOptions;
|
|
39
|
-
virtualModules: VirtualModules;
|
|
40
|
-
additionalModules: AdditionalModulesPlugin;
|
|
41
|
-
};
|
|
42
|
-
export {};
|
package/dist/worker-config.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import { isBuiltin } from 'node:module';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { getModuleTypes } from './module-rules.js';
|
|
6
|
-
import { getNodeJsCompat } from './nodejs-compat.js';
|
|
7
|
-
const PLUGIN_NAME = 'rspack-plugin-cloudflare';
|
|
8
|
-
const TYPESCRIPT_RE = /\.[cm]?tsx?$/;
|
|
9
|
-
// the static asset types Vite also imports as URLs; .txt stays a Text module, as wrangler treats it
|
|
10
|
-
const ASSET_RE = /\.(?:apng|avif|bmp|cur|eot|flac|gif|ico|jfif|jpe?g|jxl|m4a|mov|mp3|mp4|ogg|opus|otf|pdf|pjp|pjpeg|png|svg|ttf|vtt|wav|webm|webmanifest|webp|woff2?|aac)$/i;
|
|
11
|
-
// `?url` imports any file as a URL, like Vite
|
|
12
|
-
const URL_QUERY_RE = /\?(?:[^#]*&)?url(?:[&=#]|$)/;
|
|
13
|
-
/** Output subdirectory for assets Worker code imports, laid out the way the assets directory serves them. */
|
|
14
|
-
export const IMPORTED_ASSETS_DIR = 'imported-assets';
|
|
15
|
-
/** Copies imported `.wasm`/`.bin` files next to the bundle, where workerd loads them as their own modules. */
|
|
16
|
-
export class AdditionalModulesPlugin {
|
|
17
|
-
#files = new Map();
|
|
18
|
-
/** Every file emitted so far; dev passes these to Miniflare, since rspack's incremental asset list can leave them out. */
|
|
19
|
-
get modules() {
|
|
20
|
-
return [...this.#files].map(([fileName, { type }]) => {
|
|
21
|
-
return { fileName, type };
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/** Records a file to emit and returns the specifier the bundle should import it by. */
|
|
25
|
-
add(sourcePath, type) {
|
|
26
|
-
const hash = createHash('sha1').update(fs.readFileSync(sourcePath)).digest('hex')
|
|
27
|
-
.slice(0, 16);
|
|
28
|
-
const fileName = `${hash}-${path.basename(sourcePath)}`;
|
|
29
|
-
this.#files.set(fileName, { sourcePath, type });
|
|
30
|
-
return `./${fileName}`;
|
|
31
|
-
}
|
|
32
|
-
apply(compiler) {
|
|
33
|
-
const { Compilation, sources } = compiler.rspack;
|
|
34
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
35
|
-
compilation.hooks.processAssets.tap({ name: PLUGIN_NAME, stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL }, () => {
|
|
36
|
-
for (const [fileName, { sourcePath }] of this.#files) {
|
|
37
|
-
compilation.emitAsset(fileName, new sources.RawSource(fs.readFileSync(sourcePath)));
|
|
38
|
-
compilation.fileDependencies.add(sourcePath);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function createExternals(nodeJsCompat, moduleTypes, additionalModules) {
|
|
45
|
-
return ({ request, context }, callback) => {
|
|
46
|
-
if (!request) {
|
|
47
|
-
callback();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (request.startsWith('cloudflare:')) {
|
|
51
|
-
callback(undefined, request);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (nodeJsCompat) {
|
|
55
|
-
const native = nodeJsCompat.externals.get(request);
|
|
56
|
-
if (native) {
|
|
57
|
-
callback(undefined, native);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// a builtin the preset doesn't know about yet; workerd only resolves the node: form
|
|
61
|
-
if (isBuiltin(request) && !nodeJsCompat.polyfills.has(request)) {
|
|
62
|
-
callback(undefined, request.startsWith('node:') ? request : `node:${request}`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const filePath = request.replace(/\?.*$/, '');
|
|
67
|
-
const type = moduleTypes.get(path.extname(filePath));
|
|
68
|
-
const isModule = type === 'CompiledWasm' || type === 'Data';
|
|
69
|
-
if (isModule && !URL_QUERY_RE.test(request) && context && (filePath.startsWith('.') || path.isAbsolute(filePath))) {
|
|
70
|
-
callback(undefined, additionalModules.add(path.resolve(context, filePath), type));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
callback();
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/** Text modules inline as strings; with an assets directory, static files and `?url` imports become URLs served from it. */
|
|
77
|
-
function getAssetRules(worker, textExtensions) {
|
|
78
|
-
const textRule = { test: (file) => textExtensions.has(path.extname(file)), type: 'asset/source' };
|
|
79
|
-
if (!worker.assets) {
|
|
80
|
-
return [textRule];
|
|
81
|
-
}
|
|
82
|
-
const generator = {
|
|
83
|
-
filename: 'assets/[name].[contenthash:8][ext]',
|
|
84
|
-
outputPath: IMPORTED_ASSETS_DIR,
|
|
85
|
-
// served from the root of the assets directory, not the Worker's own public path
|
|
86
|
-
publicPath: '/',
|
|
87
|
-
};
|
|
88
|
-
return [
|
|
89
|
-
{ resourceQuery: URL_QUERY_RE, type: 'asset/resource', generator },
|
|
90
|
-
textRule,
|
|
91
|
-
{ test: ASSET_RE, type: 'asset/resource', generator },
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
/** Builds the rspack config for the Worker bundle: a single ESM file workerd can load as-is. */
|
|
95
|
-
export function createWorkerConfig(options) {
|
|
96
|
-
const { compiler, worker, pluginOptions, outputDir, entry, entrySource, mode, hot = false, publicPath = '/' } = options;
|
|
97
|
-
const { rspack } = compiler;
|
|
98
|
-
const moduleTypes = getModuleTypes(worker);
|
|
99
|
-
const textExtensions = new Set([...moduleTypes].filter(([, type]) => type === 'Text').map(([extension]) => extension));
|
|
100
|
-
const additionalModules = new AdditionalModulesPlugin();
|
|
101
|
-
const nodeJsCompat = getNodeJsCompat(worker);
|
|
102
|
-
const virtualModules = {};
|
|
103
|
-
const entries = [entry];
|
|
104
|
-
if (entrySource !== undefined) {
|
|
105
|
-
virtualModules[entry] = entrySource;
|
|
106
|
-
}
|
|
107
|
-
if (nodeJsCompat?.injectSource) {
|
|
108
|
-
// runs before the Worker so injected globals like `process` exist while its modules evaluate
|
|
109
|
-
const injectPath = path.join(worker.rootDir, '.wrangler', 'tmp', `rspack-${worker.name}`, 'nodejs-compat-inject.js');
|
|
110
|
-
virtualModules[injectPath] = nodeJsCompat.injectSource;
|
|
111
|
-
entries.unshift(injectPath);
|
|
112
|
-
}
|
|
113
|
-
const plugins = [
|
|
114
|
-
new rspack.DefinePlugin(worker.config.define),
|
|
115
|
-
// workerd loads a single module here, so keep dynamic imports in the entry chunk
|
|
116
|
-
new rspack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
117
|
-
additionalModules,
|
|
118
|
-
];
|
|
119
|
-
const polyfills = nodeJsCompat?.polyfills;
|
|
120
|
-
if (polyfills && polyfills.size > 0) {
|
|
121
|
-
// rspack reads `node:` specifiers as a URL scheme that resolve.alias never sees, so swap polyfills in before resolving
|
|
122
|
-
plugins.push(new rspack.NormalModuleReplacementPlugin(/^(?:node:)?[a-z_]/, (resource) => {
|
|
123
|
-
const polyfill = polyfills.get(resource.request);
|
|
124
|
-
if (polyfill) {
|
|
125
|
-
resource.request = polyfill;
|
|
126
|
-
}
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
const virtualModulesPlugin = new rspack.experiments.VirtualModulesPlugin(virtualModules);
|
|
130
|
-
plugins.push(virtualModulesPlugin);
|
|
131
|
-
if (hot) {
|
|
132
|
-
plugins.push(new rspack.HotModuleReplacementPlugin());
|
|
133
|
-
}
|
|
134
|
-
let config = {
|
|
135
|
-
name: `cloudflare:${worker.name}`,
|
|
136
|
-
mode,
|
|
137
|
-
context: worker.rootDir,
|
|
138
|
-
target: ['webworker', 'es2024'],
|
|
139
|
-
entry: { index: entries },
|
|
140
|
-
output: {
|
|
141
|
-
path: outputDir,
|
|
142
|
-
filename: 'index.js',
|
|
143
|
-
module: true,
|
|
144
|
-
chunkFormat: 'module',
|
|
145
|
-
library: { type: 'module' },
|
|
146
|
-
clean: true,
|
|
147
|
-
publicPath,
|
|
148
|
-
},
|
|
149
|
-
externalsType: 'module-import',
|
|
150
|
-
externals: [createExternals(nodeJsCompat, moduleTypes, additionalModules)],
|
|
151
|
-
resolve: {
|
|
152
|
-
extensions: ['.ts', '.tsx', '.mts', '.cts', '.js', '.mjs', '.cjs', '.json'],
|
|
153
|
-
extensionAlias: { '.js': ['.ts', '.tsx', '.js'], '.mjs': ['.mts', '.mjs'] },
|
|
154
|
-
conditionNames: ['workerd', 'worker', 'browser', 'module', 'import', 'default'],
|
|
155
|
-
alias: worker.config.alias,
|
|
156
|
-
},
|
|
157
|
-
module: {
|
|
158
|
-
rules: [
|
|
159
|
-
{
|
|
160
|
-
test: TYPESCRIPT_RE,
|
|
161
|
-
loader: 'builtin:swc-loader',
|
|
162
|
-
options: {
|
|
163
|
-
jsc: {
|
|
164
|
-
parser: { syntax: 'typescript', tsx: true, decorators: true },
|
|
165
|
-
target: 'es2024',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
type: 'javascript/auto',
|
|
169
|
-
},
|
|
170
|
-
{ oneOf: getAssetRules(worker, textExtensions) },
|
|
171
|
-
],
|
|
172
|
-
},
|
|
173
|
-
devtool: 'source-map',
|
|
174
|
-
optimization: {
|
|
175
|
-
// wrangler doesn't minify by default either, and readable stack traces matter more on the server
|
|
176
|
-
minimize: false,
|
|
177
|
-
// a failed dev build must leave the last good bundle in place, since restarting another Worker reloads it from disk
|
|
178
|
-
emitOnErrors: false,
|
|
179
|
-
},
|
|
180
|
-
plugins,
|
|
181
|
-
performance: { hints: false },
|
|
182
|
-
watchOptions: {
|
|
183
|
-
// dev's generated entry is virtual and the bundle is written under .wrangler, so the watcher would see both as changes
|
|
184
|
-
ignored: /[/\\](?:\.git|node_modules|\.wrangler)[/\\]/,
|
|
185
|
-
},
|
|
186
|
-
stats: 'errors-warnings',
|
|
187
|
-
infrastructureLogging: compiler.options.infrastructureLogging,
|
|
188
|
-
};
|
|
189
|
-
if (pluginOptions.worker) {
|
|
190
|
-
config = pluginOptions.worker(config, { name: worker.name }) ?? config;
|
|
191
|
-
}
|
|
192
|
-
return { config, virtualModules: virtualModulesPlugin, additionalModules };
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=worker-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-config.js","sourceRoot":"","sources":["../src/worker-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAWrD,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAC/C,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,oGAAoG;AACpG,MAAM,QAAQ,GAAG,2JAA2J,CAAC;AAC7K,8CAA8C;AAC9C,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD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