@cloudflare/vite-plugin 0.0.0-de209c235 → 0.0.0-de3764fa3
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/dist/asset-workers/asset-worker.js +678 -659
- package/dist/asset-workers/router-worker.js +1 -1
- package/dist/index.js +88 -52
- package/dist/runner-worker/index.js +10 -9
- package/package.json +10 -10
|
@@ -1985,7 +1985,7 @@ var we = class {
|
|
|
1985
1985
|
this.hasWritten || this.readyAnalytics && (this.hasWritten = true, this.readyAnalytics.logEvent({ version: 1, accountId: this.data.accountId, indexId: this.data.scriptId?.toString(), doubles: [this.data.requestTime ?? -1, this.data.coloId ?? -1, this.data.metalId ?? -1, this.data.coloTier ?? -1, this.data.userWorkerAhead === void 0 ? -1 : Number(this.data.userWorkerAhead)], blobs: [this.data.hostname?.substring(0, 256), this.data.dispatchtype, this.data.error?.substring(0, 256), this.data.version, this.data.coloRegion] }));
|
|
1986
1986
|
}
|
|
1987
1987
|
};
|
|
1988
|
-
var On = (t4) => ({ invoke_user_worker_ahead_of_assets: t4?.invoke_user_worker_ahead_of_assets ?? false, has_user_worker: t4?.has_user_worker ?? false, account_id: t4?.account_id ?? -1, script_id: t4?.script_id ?? -1 });
|
|
1988
|
+
var On = (t4) => ({ invoke_user_worker_ahead_of_assets: t4?.invoke_user_worker_ahead_of_assets ?? false, has_user_worker: t4?.has_user_worker ?? false, account_id: t4?.account_id ?? -1, script_id: t4?.script_id ?? -1, debug: t4?.debug ?? false });
|
|
1989
1989
|
var Bc = { async fetch(t4, e, n) {
|
|
1990
1990
|
let r, o = false, s = new we(e.ANALYTICS), i = new ue(e.UNSAFE_PERFORMANCE), a = i.now();
|
|
1991
1991
|
try {
|
package/dist/index.js
CHANGED
|
@@ -489,7 +489,7 @@ import assert10 from "node:assert";
|
|
|
489
489
|
import * as fs5 from "node:fs";
|
|
490
490
|
import * as fsp2 from "node:fs/promises";
|
|
491
491
|
import * as path9 from "node:path";
|
|
492
|
-
import {
|
|
492
|
+
import { createRequest, sendResponse } from "@mjackson/node-fetch-server";
|
|
493
493
|
import replace from "@rollup/plugin-replace";
|
|
494
494
|
|
|
495
495
|
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
@@ -1558,7 +1558,7 @@ var MagicString = class _MagicString {
|
|
|
1558
1558
|
|
|
1559
1559
|
// src/index.ts
|
|
1560
1560
|
import { Miniflare } from "miniflare";
|
|
1561
|
-
import
|
|
1561
|
+
import colors3 from "picocolors";
|
|
1562
1562
|
import * as vite7 from "vite";
|
|
1563
1563
|
|
|
1564
1564
|
// src/constants.ts
|
|
@@ -5784,7 +5784,8 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
5784
5784
|
// ../workers-shared/utils/types.ts
|
|
5785
5785
|
var InternalConfigSchema = z.object({
|
|
5786
5786
|
account_id: z.number().optional(),
|
|
5787
|
-
script_id: z.number().optional()
|
|
5787
|
+
script_id: z.number().optional(),
|
|
5788
|
+
debug: z.boolean().optional()
|
|
5788
5789
|
});
|
|
5789
5790
|
var RouterConfigSchema = z.object({
|
|
5790
5791
|
invoke_user_worker_ahead_of_assets: z.boolean().optional(),
|
|
@@ -13028,19 +13029,6 @@ function toMiniflareRequest(request) {
|
|
|
13028
13029
|
duplex: "half"
|
|
13029
13030
|
});
|
|
13030
13031
|
}
|
|
13031
|
-
function nodeHeadersToWebHeaders(nodeHeaders) {
|
|
13032
|
-
const headers = new Headers();
|
|
13033
|
-
for (const [key, value] of Object.entries(nodeHeaders)) {
|
|
13034
|
-
if (typeof value === "string") {
|
|
13035
|
-
headers.append(key, value);
|
|
13036
|
-
} else if (Array.isArray(value)) {
|
|
13037
|
-
for (const item of value) {
|
|
13038
|
-
headers.append(key, item);
|
|
13039
|
-
}
|
|
13040
|
-
}
|
|
13041
|
-
}
|
|
13042
|
-
return headers;
|
|
13043
|
-
}
|
|
13044
13032
|
var postfixRE = /[?#].*$/;
|
|
13045
13033
|
function cleanUrl(url) {
|
|
13046
13034
|
return url.replace(postfixRE, "");
|
|
@@ -13354,6 +13342,7 @@ import {
|
|
|
13354
13342
|
LogLevel,
|
|
13355
13343
|
Response as MiniflareResponse
|
|
13356
13344
|
} from "miniflare";
|
|
13345
|
+
import colors2 from "picocolors";
|
|
13357
13346
|
import { globSync } from "tinyglobby";
|
|
13358
13347
|
import "vite";
|
|
13359
13348
|
import { unstable_getMiniflareWorkerOptions } from "wrangler";
|
|
@@ -13458,6 +13447,29 @@ function getEntryWorkerConfig(resolvedPluginConfig) {
|
|
|
13458
13447
|
}
|
|
13459
13448
|
return resolvedPluginConfig.workers[resolvedPluginConfig.entryWorkerEnvironmentName];
|
|
13460
13449
|
}
|
|
13450
|
+
function filterTails(tails, userWorkers, log) {
|
|
13451
|
+
return tails?.filter((tailService) => {
|
|
13452
|
+
let name;
|
|
13453
|
+
if (typeof tailService === "string") {
|
|
13454
|
+
name = tailService;
|
|
13455
|
+
} else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") {
|
|
13456
|
+
name = tailService.name;
|
|
13457
|
+
} else {
|
|
13458
|
+
return true;
|
|
13459
|
+
}
|
|
13460
|
+
const found = userWorkers.some((w) => w.name === name);
|
|
13461
|
+
if (!found) {
|
|
13462
|
+
log(
|
|
13463
|
+
colors2.dim(
|
|
13464
|
+
colors2.yellow(
|
|
13465
|
+
`Tail consumer "${name}" was not found in your config. Make sure you add it if you'd like to simulate receiving tail events locally.`
|
|
13466
|
+
)
|
|
13467
|
+
)
|
|
13468
|
+
);
|
|
13469
|
+
}
|
|
13470
|
+
return found;
|
|
13471
|
+
});
|
|
13472
|
+
}
|
|
13461
13473
|
function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
|
|
13462
13474
|
const resolvedViteConfig = viteDevServer.config;
|
|
13463
13475
|
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
@@ -13649,6 +13661,11 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13649
13661
|
}
|
|
13650
13662
|
return {
|
|
13651
13663
|
...workerOptions,
|
|
13664
|
+
tails: filterTails(
|
|
13665
|
+
workerOptions.tails,
|
|
13666
|
+
userWorkers,
|
|
13667
|
+
viteDevServer.config.logger.warn
|
|
13668
|
+
),
|
|
13652
13669
|
modules: [
|
|
13653
13670
|
{
|
|
13654
13671
|
type: "ESModule",
|
|
@@ -13739,6 +13756,11 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
|
|
|
13739
13756
|
return [
|
|
13740
13757
|
{
|
|
13741
13758
|
...workerOptions,
|
|
13759
|
+
tails: filterTails(
|
|
13760
|
+
workerOptions.tails,
|
|
13761
|
+
workerConfigs,
|
|
13762
|
+
vitePreviewServer.config.logger.warn
|
|
13763
|
+
),
|
|
13742
13764
|
name: workerOptions.name ?? config.name,
|
|
13743
13765
|
unsafeInspectorProxy: inspectorPort !== false,
|
|
13744
13766
|
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
|
|
@@ -14147,6 +14169,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14147
14169
|
}
|
|
14148
14170
|
|
|
14149
14171
|
// src/websockets.ts
|
|
14172
|
+
import { createHeaders } from "@mjackson/node-fetch-server";
|
|
14150
14173
|
import { coupleWebSocket } from "miniflare";
|
|
14151
14174
|
import { WebSocketServer } from "ws";
|
|
14152
14175
|
function handleWebSocket(httpServer, getFetcher) {
|
|
@@ -14158,7 +14181,7 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
14158
14181
|
if (request.headers["sec-websocket-protocol"]?.startsWith("vite")) {
|
|
14159
14182
|
return;
|
|
14160
14183
|
}
|
|
14161
|
-
const headers =
|
|
14184
|
+
const headers = createHeaders(request);
|
|
14162
14185
|
const fetcher = await getFetcher();
|
|
14163
14186
|
const response = await fetcher(url, {
|
|
14164
14187
|
headers,
|
|
@@ -14425,15 +14448,11 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14425
14448
|
}
|
|
14426
14449
|
},
|
|
14427
14450
|
async configureServer(viteDevServer) {
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14451
|
+
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14452
|
+
pluginConfig,
|
|
14453
|
+
viteDevServer
|
|
14431
14454
|
);
|
|
14432
14455
|
if (!miniflare) {
|
|
14433
|
-
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14434
|
-
pluginConfig,
|
|
14435
|
-
viteDevServer
|
|
14436
|
-
);
|
|
14437
14456
|
miniflare = new Miniflare(
|
|
14438
14457
|
getDevMiniflareOptions(
|
|
14439
14458
|
resolvedPluginConfig,
|
|
@@ -14442,34 +14461,41 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14442
14461
|
)
|
|
14443
14462
|
);
|
|
14444
14463
|
} else {
|
|
14445
|
-
const resolvedInspectorPort = await getResolvedInspectorPort(pluginConfig);
|
|
14446
14464
|
await miniflare.setOptions(
|
|
14447
14465
|
getDevMiniflareOptions(
|
|
14448
14466
|
resolvedPluginConfig,
|
|
14449
14467
|
viteDevServer,
|
|
14450
|
-
|
|
14468
|
+
inputInspectorPort
|
|
14451
14469
|
)
|
|
14452
14470
|
);
|
|
14453
14471
|
}
|
|
14454
14472
|
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14455
|
-
|
|
14456
|
-
async (
|
|
14473
|
+
if (viteDevServer.httpServer) {
|
|
14474
|
+
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
14457
14475
|
assert10(miniflare, `Miniflare not defined`);
|
|
14458
14476
|
const routerWorker = await getRouterWorker(miniflare);
|
|
14459
|
-
return routerWorker.fetch
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
},
|
|
14463
|
-
{ alwaysCallNext: false }
|
|
14464
|
-
);
|
|
14465
|
-
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
14466
|
-
assert10(miniflare, `Miniflare not defined`);
|
|
14467
|
-
const routerWorker = await getRouterWorker(miniflare);
|
|
14468
|
-
return routerWorker.fetch;
|
|
14469
|
-
});
|
|
14477
|
+
return routerWorker.fetch;
|
|
14478
|
+
});
|
|
14479
|
+
}
|
|
14470
14480
|
return () => {
|
|
14471
|
-
viteDevServer.middlewares.use((req, res, next) => {
|
|
14472
|
-
|
|
14481
|
+
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
14482
|
+
try {
|
|
14483
|
+
assert10(miniflare, `Miniflare not defined`);
|
|
14484
|
+
const routerWorker = await getRouterWorker(miniflare);
|
|
14485
|
+
const request = createRequest(req, res);
|
|
14486
|
+
const response = await routerWorker.fetch(
|
|
14487
|
+
toMiniflareRequest(request),
|
|
14488
|
+
{
|
|
14489
|
+
redirect: "manual"
|
|
14490
|
+
}
|
|
14491
|
+
);
|
|
14492
|
+
if (req.httpVersionMajor === 2) {
|
|
14493
|
+
response.headers.delete("transfer-encoding");
|
|
14494
|
+
}
|
|
14495
|
+
await sendResponse(res, response);
|
|
14496
|
+
} catch (error) {
|
|
14497
|
+
next(error);
|
|
14498
|
+
}
|
|
14473
14499
|
});
|
|
14474
14500
|
};
|
|
14475
14501
|
},
|
|
@@ -14487,20 +14513,24 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14487
14513
|
inputInspectorPort
|
|
14488
14514
|
)
|
|
14489
14515
|
);
|
|
14490
|
-
const middleware = createMiddleware(
|
|
14491
|
-
({ request }) => {
|
|
14492
|
-
return miniflare2.dispatchFetch(toMiniflareRequest(request), {
|
|
14493
|
-
redirect: "manual"
|
|
14494
|
-
});
|
|
14495
|
-
},
|
|
14496
|
-
{ alwaysCallNext: false }
|
|
14497
|
-
);
|
|
14498
14516
|
handleWebSocket(
|
|
14499
14517
|
vitePreviewServer.httpServer,
|
|
14500
14518
|
() => miniflare2.dispatchFetch
|
|
14501
14519
|
);
|
|
14502
|
-
vitePreviewServer.middlewares.use((req, res, next) => {
|
|
14503
|
-
|
|
14520
|
+
vitePreviewServer.middlewares.use(async (req, res, next) => {
|
|
14521
|
+
try {
|
|
14522
|
+
const request = createRequest(req, res);
|
|
14523
|
+
const response = await miniflare2.dispatchFetch(
|
|
14524
|
+
toMiniflareRequest(request),
|
|
14525
|
+
{ redirect: "manual" }
|
|
14526
|
+
);
|
|
14527
|
+
if (req.httpVersionMajor === 2) {
|
|
14528
|
+
response.headers.delete("transfer-encoding");
|
|
14529
|
+
}
|
|
14530
|
+
await sendResponse(res, response);
|
|
14531
|
+
} catch (error) {
|
|
14532
|
+
next(error);
|
|
14533
|
+
}
|
|
14504
14534
|
});
|
|
14505
14535
|
}
|
|
14506
14536
|
},
|
|
@@ -14830,10 +14860,16 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14830
14860
|
}
|
|
14831
14861
|
}
|
|
14832
14862
|
async function getInputInspectorPortOption(pluginConfig, viteServer) {
|
|
14863
|
+
if (pluginConfig.inspectorPort === void 0 || pluginConfig.inspectorPort === 0) {
|
|
14864
|
+
const resolvedInspectorPort = await getResolvedInspectorPort(pluginConfig);
|
|
14865
|
+
if (resolvedInspectorPort !== null) {
|
|
14866
|
+
return resolvedInspectorPort;
|
|
14867
|
+
}
|
|
14868
|
+
}
|
|
14833
14869
|
const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
|
|
14834
14870
|
if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
|
|
14835
14871
|
viteServer.config.logger.warn(
|
|
14836
|
-
|
|
14872
|
+
colors3.dim(
|
|
14837
14873
|
`Default inspector port ${DEFAULT_INSPECTOR_PORT} not available, using ${inputInspectorPort} instead
|
|
14838
14874
|
`
|
|
14839
14875
|
)
|
|
@@ -29,7 +29,7 @@ function stripInternalEnv(internalEnv) {
|
|
|
29
29
|
return userEnv;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// ../../node_modules/.pnpm/vite@6.1.0_@types+node@
|
|
32
|
+
// ../../node_modules/.pnpm/vite@6.1.0_@types+node@20.17.32_jiti@2.4.2_lightningcss@1.29.2/node_modules/vite/dist/node/module-runner.js
|
|
33
33
|
var VALID_ID_PREFIX = "/@id/";
|
|
34
34
|
var NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
35
35
|
var SOURCEMAPPING_URL = "sourceMa";
|
|
@@ -1435,20 +1435,21 @@ async function getWorkerEntryExport(path, entrypoint) {
|
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
1437
|
// src/runner-worker/index.ts
|
|
1438
|
+
var IGNORED_KEYS = ["self", "tailStream"];
|
|
1438
1439
|
var WORKER_ENTRYPOINT_KEYS = [
|
|
1439
1440
|
"fetch",
|
|
1441
|
+
"queue",
|
|
1440
1442
|
"tail",
|
|
1443
|
+
"test",
|
|
1441
1444
|
"trace",
|
|
1442
|
-
"scheduled"
|
|
1443
|
-
"queue",
|
|
1444
|
-
"test"
|
|
1445
|
+
"scheduled"
|
|
1445
1446
|
];
|
|
1446
1447
|
var DURABLE_OBJECT_KEYS = [
|
|
1447
|
-
"fetch",
|
|
1448
1448
|
"alarm",
|
|
1449
|
-
"
|
|
1449
|
+
"fetch",
|
|
1450
1450
|
"webSocketClose",
|
|
1451
|
-
"webSocketError"
|
|
1451
|
+
"webSocketError",
|
|
1452
|
+
"webSocketMessage"
|
|
1452
1453
|
];
|
|
1453
1454
|
var WORKFLOW_ENTRYPOINT_KEYS = ["run"];
|
|
1454
1455
|
var entryPath = "";
|
|
@@ -1513,7 +1514,7 @@ function createWorkerEntrypointWrapper(entrypoint) {
|
|
|
1513
1514
|
if (value !== void 0) {
|
|
1514
1515
|
return value;
|
|
1515
1516
|
}
|
|
1516
|
-
if (key === "
|
|
1517
|
+
if (typeof key === "symbol" || IGNORED_KEYS.includes(key) || DURABLE_OBJECT_KEYS.includes(key)) {
|
|
1517
1518
|
return;
|
|
1518
1519
|
}
|
|
1519
1520
|
const property = getWorkerEntrypointRpcProperty.call(
|
|
@@ -1611,7 +1612,7 @@ function createDurableObjectWrapper(className) {
|
|
|
1611
1612
|
if (value !== void 0) {
|
|
1612
1613
|
return value;
|
|
1613
1614
|
}
|
|
1614
|
-
if (key === "
|
|
1615
|
+
if (typeof key === "symbol" || IGNORED_KEYS.includes(key) || WORKER_ENTRYPOINT_KEYS.includes(key)) {
|
|
1615
1616
|
return;
|
|
1616
1617
|
}
|
|
1617
1618
|
const property = getDurableObjectRpcProperty.call(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-de3764fa3",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@
|
|
36
|
+
"@cloudflare/unenv-preset": "2.3.2",
|
|
37
|
+
"@mjackson/node-fetch-server": "^0.6.1",
|
|
37
38
|
"@rollup/plugin-replace": "^6.0.1",
|
|
38
39
|
"get-port": "^7.1.0",
|
|
39
40
|
"picocolors": "^1.1.1",
|
|
40
41
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"unenv": "2.0.0-rc.
|
|
42
|
+
"unenv": "2.0.0-rc.17",
|
|
42
43
|
"ws": "8.18.0",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"wrangler": "0.0.0-de209c235"
|
|
44
|
+
"miniflare": "0.0.0-de3764fa3",
|
|
45
|
+
"wrangler": "0.0.0-de3764fa3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250508.0",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
50
|
"@types/ws": "^8.5.13",
|
|
51
51
|
"magic-string": "^0.30.12",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"typescript": "^5.7.2",
|
|
55
55
|
"undici": "^5.28.5",
|
|
56
56
|
"vite": "^6.1.0",
|
|
57
|
-
"vitest": "~3.
|
|
58
|
-
"@cloudflare/
|
|
57
|
+
"vitest": "~3.1.1",
|
|
58
|
+
"@cloudflare/workers-shared": "0.0.0-de3764fa3",
|
|
59
59
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
60
|
-
"@cloudflare/
|
|
60
|
+
"@cloudflare/mock-npm-registry": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"vite": "^6.1.0",
|