@cloudflare/vite-plugin 0.0.0-c8a5a602b → 0.0.0-c91d3918c
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.
|
@@ -2476,7 +2476,7 @@ var ADDITIONAL_MODULE_TYPES = [
|
|
|
2476
2476
|
|
|
2477
2477
|
// src/shared.ts
|
|
2478
2478
|
var UNKNOWN_HOST = "http://localhost";
|
|
2479
|
-
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)
|
|
2479
|
+
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)__CLOUDFLARE_MODULE__`;
|
|
2480
2480
|
var additionalModuleRE = new RegExp(ADDITIONAL_MODULE_PATTERN);
|
|
2481
2481
|
var additionalModuleGlobalRE = new RegExp(
|
|
2482
2482
|
ADDITIONAL_MODULE_PATTERN,
|
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
|
|
@@ -1589,7 +1589,7 @@ function matchAdditionalModule(source) {
|
|
|
1589
1589
|
return null;
|
|
1590
1590
|
}
|
|
1591
1591
|
function createModuleReference(type, id) {
|
|
1592
|
-
return `__CLOUDFLARE_MODULE__${type}__${id}
|
|
1592
|
+
return `__CLOUDFLARE_MODULE__${type}__${id}__CLOUDFLARE_MODULE__`;
|
|
1593
1593
|
}
|
|
1594
1594
|
|
|
1595
1595
|
// src/asset-config.ts
|
|
@@ -12993,7 +12993,7 @@ var NodeJsCompatWarnings = class {
|
|
|
12993
12993
|
// src/shared.ts
|
|
12994
12994
|
var UNKNOWN_HOST = "http://localhost";
|
|
12995
12995
|
var INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
12996
|
-
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)
|
|
12996
|
+
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)__CLOUDFLARE_MODULE__`;
|
|
12997
12997
|
var additionalModuleRE = new RegExp(ADDITIONAL_MODULE_PATTERN);
|
|
12998
12998
|
var additionalModuleGlobalRE = new RegExp(
|
|
12999
12999
|
ADDITIONAL_MODULE_PATTERN,
|
|
@@ -13029,19 +13029,6 @@ function toMiniflareRequest(request) {
|
|
|
13029
13029
|
duplex: "half"
|
|
13030
13030
|
});
|
|
13031
13031
|
}
|
|
13032
|
-
function nodeHeadersToWebHeaders(nodeHeaders) {
|
|
13033
|
-
const headers = new Headers();
|
|
13034
|
-
for (const [key, value] of Object.entries(nodeHeaders)) {
|
|
13035
|
-
if (typeof value === "string") {
|
|
13036
|
-
headers.append(key, value);
|
|
13037
|
-
} else if (Array.isArray(value)) {
|
|
13038
|
-
for (const item of value) {
|
|
13039
|
-
headers.append(key, item);
|
|
13040
|
-
}
|
|
13041
|
-
}
|
|
13042
|
-
}
|
|
13043
|
-
return headers;
|
|
13044
|
-
}
|
|
13045
13032
|
var postfixRE = /[?#].*$/;
|
|
13046
13033
|
function cleanUrl(url) {
|
|
13047
13034
|
return url.replace(postfixRE, "");
|
|
@@ -13355,12 +13342,13 @@ import {
|
|
|
13355
13342
|
LogLevel,
|
|
13356
13343
|
Response as MiniflareResponse
|
|
13357
13344
|
} from "miniflare";
|
|
13345
|
+
import colors2 from "picocolors";
|
|
13358
13346
|
import { globSync } from "tinyglobby";
|
|
13359
13347
|
import "vite";
|
|
13360
13348
|
import { unstable_getMiniflareWorkerOptions } from "wrangler";
|
|
13361
|
-
function
|
|
13349
|
+
function getPersistenceRoot(root, persistState) {
|
|
13362
13350
|
if (persistState === false) {
|
|
13363
|
-
return
|
|
13351
|
+
return;
|
|
13364
13352
|
}
|
|
13365
13353
|
const defaultPersistPath = ".wrangler/state";
|
|
13366
13354
|
const persistPath = path6.resolve(
|
|
@@ -13368,14 +13356,7 @@ function getPersistence(root, persistState) {
|
|
|
13368
13356
|
typeof persistState === "object" ? persistState.path : defaultPersistPath,
|
|
13369
13357
|
"v3"
|
|
13370
13358
|
);
|
|
13371
|
-
return
|
|
13372
|
-
cachePersist: path6.join(persistPath, "cache"),
|
|
13373
|
-
d1Persist: path6.join(persistPath, "d1"),
|
|
13374
|
-
durableObjectsPersist: path6.join(persistPath, "do"),
|
|
13375
|
-
kvPersist: path6.join(persistPath, "kv"),
|
|
13376
|
-
r2Persist: path6.join(persistPath, "r2"),
|
|
13377
|
-
workflowsPersist: path6.join(persistPath, "workflows")
|
|
13378
|
-
};
|
|
13359
|
+
return persistPath;
|
|
13379
13360
|
}
|
|
13380
13361
|
function missingWorkerErrorMessage(workerName) {
|
|
13381
13362
|
return `${workerName} does not match a worker name.`;
|
|
@@ -13459,6 +13440,29 @@ function getEntryWorkerConfig(resolvedPluginConfig) {
|
|
|
13459
13440
|
}
|
|
13460
13441
|
return resolvedPluginConfig.workers[resolvedPluginConfig.entryWorkerEnvironmentName];
|
|
13461
13442
|
}
|
|
13443
|
+
function filterTails(tails, userWorkers, log) {
|
|
13444
|
+
return tails?.filter((tailService) => {
|
|
13445
|
+
let name;
|
|
13446
|
+
if (typeof tailService === "string") {
|
|
13447
|
+
name = tailService;
|
|
13448
|
+
} else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") {
|
|
13449
|
+
name = tailService.name;
|
|
13450
|
+
} else {
|
|
13451
|
+
return true;
|
|
13452
|
+
}
|
|
13453
|
+
const found = userWorkers.some((w) => w.name === name);
|
|
13454
|
+
if (!found) {
|
|
13455
|
+
log(
|
|
13456
|
+
colors2.dim(
|
|
13457
|
+
colors2.yellow(
|
|
13458
|
+
`Tail consumer "${name}" was not found in your config. Make sure you add it if you'd like to simulate receiving tail events locally.`
|
|
13459
|
+
)
|
|
13460
|
+
)
|
|
13461
|
+
);
|
|
13462
|
+
}
|
|
13463
|
+
return found;
|
|
13464
|
+
});
|
|
13465
|
+
}
|
|
13462
13466
|
function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
|
|
13463
13467
|
const resolvedViteConfig = viteDevServer.config;
|
|
13464
13468
|
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
@@ -13602,7 +13606,7 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13602
13606
|
(error) => logger.logWithLevel(LogLevel.ERROR, decoder.decode(error))
|
|
13603
13607
|
);
|
|
13604
13608
|
},
|
|
13605
|
-
|
|
13609
|
+
defaultPersistRoot: getPersistenceRoot(
|
|
13606
13610
|
resolvedViteConfig.root,
|
|
13607
13611
|
resolvedPluginConfig.persistState
|
|
13608
13612
|
),
|
|
@@ -13650,6 +13654,11 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13650
13654
|
}
|
|
13651
13655
|
return {
|
|
13652
13656
|
...workerOptions,
|
|
13657
|
+
tails: filterTails(
|
|
13658
|
+
workerOptions.tails,
|
|
13659
|
+
userWorkers,
|
|
13660
|
+
viteDevServer.config.logger.warn
|
|
13661
|
+
),
|
|
13653
13662
|
modules: [
|
|
13654
13663
|
{
|
|
13655
13664
|
type: "ESModule",
|
|
@@ -13740,6 +13749,11 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
|
|
|
13740
13749
|
return [
|
|
13741
13750
|
{
|
|
13742
13751
|
...workerOptions,
|
|
13752
|
+
tails: filterTails(
|
|
13753
|
+
workerOptions.tails,
|
|
13754
|
+
workerConfigs,
|
|
13755
|
+
vitePreviewServer.config.logger.warn
|
|
13756
|
+
),
|
|
13743
13757
|
name: workerOptions.name ?? config.name,
|
|
13744
13758
|
unsafeInspectorProxy: inspectorPort !== false,
|
|
13745
13759
|
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
|
|
@@ -13759,7 +13773,10 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
|
|
|
13759
13773
|
(error) => logger.logWithLevel(LogLevel.ERROR, decoder.decode(error))
|
|
13760
13774
|
);
|
|
13761
13775
|
},
|
|
13762
|
-
|
|
13776
|
+
defaultPersistRoot: getPersistenceRoot(
|
|
13777
|
+
resolvedViteConfig.root,
|
|
13778
|
+
persistState
|
|
13779
|
+
),
|
|
13763
13780
|
workers
|
|
13764
13781
|
};
|
|
13765
13782
|
}
|
|
@@ -14148,6 +14165,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14148
14165
|
}
|
|
14149
14166
|
|
|
14150
14167
|
// src/websockets.ts
|
|
14168
|
+
import { createHeaders } from "@mjackson/node-fetch-server";
|
|
14151
14169
|
import { coupleWebSocket } from "miniflare";
|
|
14152
14170
|
import { WebSocketServer } from "ws";
|
|
14153
14171
|
function handleWebSocket(httpServer, getFetcher) {
|
|
@@ -14159,7 +14177,7 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
14159
14177
|
if (request.headers["sec-websocket-protocol"]?.startsWith("vite")) {
|
|
14160
14178
|
return;
|
|
14161
14179
|
}
|
|
14162
|
-
const headers =
|
|
14180
|
+
const headers = createHeaders(request);
|
|
14163
14181
|
const fetcher = await getFetcher();
|
|
14164
14182
|
const response = await fetcher(url, {
|
|
14165
14183
|
headers,
|
|
@@ -14426,10 +14444,6 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14426
14444
|
}
|
|
14427
14445
|
},
|
|
14428
14446
|
async configureServer(viteDevServer) {
|
|
14429
|
-
assert10(
|
|
14430
|
-
viteDevServer.httpServer,
|
|
14431
|
-
"Unexpected error: No Vite HTTP server"
|
|
14432
|
-
);
|
|
14433
14447
|
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14434
14448
|
pluginConfig,
|
|
14435
14449
|
viteDevServer
|
|
@@ -14452,24 +14466,32 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14452
14466
|
);
|
|
14453
14467
|
}
|
|
14454
14468
|
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14455
|
-
|
|
14456
|
-
async (
|
|
14469
|
+
if (viteDevServer.httpServer) {
|
|
14470
|
+
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
14457
14471
|
assert10(miniflare, `Miniflare not defined`);
|
|
14458
14472
|
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
|
-
});
|
|
14473
|
+
return routerWorker.fetch;
|
|
14474
|
+
});
|
|
14475
|
+
}
|
|
14470
14476
|
return () => {
|
|
14471
|
-
viteDevServer.middlewares.use((req, res, next) => {
|
|
14472
|
-
|
|
14477
|
+
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
14478
|
+
try {
|
|
14479
|
+
assert10(miniflare, `Miniflare not defined`);
|
|
14480
|
+
const routerWorker = await getRouterWorker(miniflare);
|
|
14481
|
+
const request = createRequest(req, res);
|
|
14482
|
+
const response = await routerWorker.fetch(
|
|
14483
|
+
toMiniflareRequest(request),
|
|
14484
|
+
{
|
|
14485
|
+
redirect: "manual"
|
|
14486
|
+
}
|
|
14487
|
+
);
|
|
14488
|
+
if (req.httpVersionMajor === 2) {
|
|
14489
|
+
response.headers.delete("transfer-encoding");
|
|
14490
|
+
}
|
|
14491
|
+
await sendResponse(res, response);
|
|
14492
|
+
} catch (error) {
|
|
14493
|
+
next(error);
|
|
14494
|
+
}
|
|
14473
14495
|
});
|
|
14474
14496
|
};
|
|
14475
14497
|
},
|
|
@@ -14487,20 +14509,24 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14487
14509
|
inputInspectorPort
|
|
14488
14510
|
)
|
|
14489
14511
|
);
|
|
14490
|
-
const middleware = createMiddleware(
|
|
14491
|
-
({ request }) => {
|
|
14492
|
-
return miniflare2.dispatchFetch(toMiniflareRequest(request), {
|
|
14493
|
-
redirect: "manual"
|
|
14494
|
-
});
|
|
14495
|
-
},
|
|
14496
|
-
{ alwaysCallNext: false }
|
|
14497
|
-
);
|
|
14498
14512
|
handleWebSocket(
|
|
14499
14513
|
vitePreviewServer.httpServer,
|
|
14500
14514
|
() => miniflare2.dispatchFetch
|
|
14501
14515
|
);
|
|
14502
|
-
vitePreviewServer.middlewares.use((req, res, next) => {
|
|
14503
|
-
|
|
14516
|
+
vitePreviewServer.middlewares.use(async (req, res, next) => {
|
|
14517
|
+
try {
|
|
14518
|
+
const request = createRequest(req, res);
|
|
14519
|
+
const response = await miniflare2.dispatchFetch(
|
|
14520
|
+
toMiniflareRequest(request),
|
|
14521
|
+
{ redirect: "manual" }
|
|
14522
|
+
);
|
|
14523
|
+
if (req.httpVersionMajor === 2) {
|
|
14524
|
+
response.headers.delete("transfer-encoding");
|
|
14525
|
+
}
|
|
14526
|
+
await sendResponse(res, response);
|
|
14527
|
+
} catch (error) {
|
|
14528
|
+
next(error);
|
|
14529
|
+
}
|
|
14504
14530
|
});
|
|
14505
14531
|
}
|
|
14506
14532
|
},
|
|
@@ -14839,7 +14865,7 @@ async function getInputInspectorPortOption(pluginConfig, viteServer) {
|
|
|
14839
14865
|
const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
|
|
14840
14866
|
if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
|
|
14841
14867
|
viteServer.config.logger.warn(
|
|
14842
|
-
|
|
14868
|
+
colors3.dim(
|
|
14843
14869
|
`Default inspector port ${DEFAULT_INSPECTOR_PORT} not available, using ${inputInspectorPort} instead
|
|
14844
14870
|
`
|
|
14845
14871
|
)
|
|
@@ -15,7 +15,7 @@ var ADDITIONAL_MODULE_TYPES = [
|
|
|
15
15
|
// src/shared.ts
|
|
16
16
|
var UNKNOWN_HOST = "http://localhost";
|
|
17
17
|
var INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
18
|
-
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)
|
|
18
|
+
var ADDITIONAL_MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${ADDITIONAL_MODULE_TYPES.join("|")})__(.*?)__CLOUDFLARE_MODULE__`;
|
|
19
19
|
var additionalModuleRE = new RegExp(ADDITIONAL_MODULE_PATTERN);
|
|
20
20
|
var additionalModuleGlobalRE = new RegExp(
|
|
21
21
|
ADDITIONAL_MODULE_PATTERN,
|
|
@@ -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";
|
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-c91d3918c",
|
|
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-c8a5a602b"
|
|
44
|
+
"miniflare": "0.0.0-c91d3918c",
|
|
45
|
+
"wrangler": "0.0.0-c91d3918c"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250523.0",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
50
|
"@types/ws": "^8.5.13",
|
|
51
51
|
"magic-string": "^0.30.12",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"undici": "^5.28.5",
|
|
56
56
|
"vite": "^6.1.0",
|
|
57
57
|
"vitest": "~3.1.1",
|
|
58
|
-
"@cloudflare/workers-shared": "0.0.0-
|
|
58
|
+
"@cloudflare/workers-shared": "0.0.0-c91d3918c",
|
|
59
59
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
60
60
|
"@cloudflare/mock-npm-registry": "0.0.0"
|
|
61
61
|
},
|