@cloudflare/vite-plugin 1.0.12 → 1.1.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/dist/asset-workers/asset-worker.js +635 -625
- package/dist/index.js +43 -11
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -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
|
|
@@ -13355,6 +13355,7 @@ import {
|
|
|
13355
13355
|
LogLevel,
|
|
13356
13356
|
Response as MiniflareResponse
|
|
13357
13357
|
} from "miniflare";
|
|
13358
|
+
import colors2 from "picocolors";
|
|
13358
13359
|
import { globSync } from "tinyglobby";
|
|
13359
13360
|
import "vite";
|
|
13360
13361
|
import { unstable_getMiniflareWorkerOptions } from "wrangler";
|
|
@@ -13459,6 +13460,29 @@ function getEntryWorkerConfig(resolvedPluginConfig) {
|
|
|
13459
13460
|
}
|
|
13460
13461
|
return resolvedPluginConfig.workers[resolvedPluginConfig.entryWorkerEnvironmentName];
|
|
13461
13462
|
}
|
|
13463
|
+
function filterTails(tails, userWorkers, log) {
|
|
13464
|
+
return tails?.filter((tailService) => {
|
|
13465
|
+
let name;
|
|
13466
|
+
if (typeof tailService === "string") {
|
|
13467
|
+
name = tailService;
|
|
13468
|
+
} else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") {
|
|
13469
|
+
name = tailService.name;
|
|
13470
|
+
} else {
|
|
13471
|
+
return true;
|
|
13472
|
+
}
|
|
13473
|
+
const found = userWorkers.some((w) => w.name === name);
|
|
13474
|
+
if (!found) {
|
|
13475
|
+
log(
|
|
13476
|
+
colors2.dim(
|
|
13477
|
+
colors2.yellow(
|
|
13478
|
+
`Tail consumer "${name}" was not found in your config. Make sure you add it if you'd like to simulate receiving tail events locally.`
|
|
13479
|
+
)
|
|
13480
|
+
)
|
|
13481
|
+
);
|
|
13482
|
+
}
|
|
13483
|
+
return found;
|
|
13484
|
+
});
|
|
13485
|
+
}
|
|
13462
13486
|
function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
|
|
13463
13487
|
const resolvedViteConfig = viteDevServer.config;
|
|
13464
13488
|
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
@@ -13650,6 +13674,11 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13650
13674
|
}
|
|
13651
13675
|
return {
|
|
13652
13676
|
...workerOptions,
|
|
13677
|
+
tails: filterTails(
|
|
13678
|
+
workerOptions.tails,
|
|
13679
|
+
userWorkers,
|
|
13680
|
+
viteDevServer.config.logger.warn
|
|
13681
|
+
),
|
|
13653
13682
|
modules: [
|
|
13654
13683
|
{
|
|
13655
13684
|
type: "ESModule",
|
|
@@ -13740,6 +13769,11 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
|
|
|
13740
13769
|
return [
|
|
13741
13770
|
{
|
|
13742
13771
|
...workerOptions,
|
|
13772
|
+
tails: filterTails(
|
|
13773
|
+
workerOptions.tails,
|
|
13774
|
+
workerConfigs,
|
|
13775
|
+
vitePreviewServer.config.logger.warn
|
|
13776
|
+
),
|
|
13743
13777
|
name: workerOptions.name ?? config.name,
|
|
13744
13778
|
unsafeInspectorProxy: inspectorPort !== false,
|
|
13745
13779
|
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
|
|
@@ -14426,10 +14460,6 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14426
14460
|
}
|
|
14427
14461
|
},
|
|
14428
14462
|
async configureServer(viteDevServer) {
|
|
14429
|
-
assert10(
|
|
14430
|
-
viteDevServer.httpServer,
|
|
14431
|
-
"Unexpected error: No Vite HTTP server"
|
|
14432
|
-
);
|
|
14433
14463
|
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14434
14464
|
pluginConfig,
|
|
14435
14465
|
viteDevServer
|
|
@@ -14462,11 +14492,13 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14462
14492
|
},
|
|
14463
14493
|
{ alwaysCallNext: false }
|
|
14464
14494
|
);
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14495
|
+
if (viteDevServer.httpServer) {
|
|
14496
|
+
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
14497
|
+
assert10(miniflare, `Miniflare not defined`);
|
|
14498
|
+
const routerWorker = await getRouterWorker(miniflare);
|
|
14499
|
+
return routerWorker.fetch;
|
|
14500
|
+
});
|
|
14501
|
+
}
|
|
14470
14502
|
return () => {
|
|
14471
14503
|
viteDevServer.middlewares.use((req, res, next) => {
|
|
14472
14504
|
middleware(req, res, next);
|
|
@@ -14839,7 +14871,7 @@ async function getInputInspectorPortOption(pluginConfig, viteServer) {
|
|
|
14839
14871
|
const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
|
|
14840
14872
|
if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
|
|
14841
14873
|
viteServer.config.logger.warn(
|
|
14842
|
-
|
|
14874
|
+
colors3.dim(
|
|
14843
14875
|
`Default inspector port ${DEFAULT_INSPECTOR_PORT} not available, using ${inputInspectorPort} instead
|
|
14844
14876
|
`
|
|
14845
14877
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"unenv": "2.0.0-rc.15",
|
|
42
42
|
"ws": "8.18.0",
|
|
43
43
|
"@cloudflare/unenv-preset": "2.3.1",
|
|
44
|
-
"miniflare": "4.
|
|
45
|
-
"wrangler": "4.
|
|
44
|
+
"miniflare": "4.20250428.1",
|
|
45
|
+
"wrangler": "4.14.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250428.0",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
50
|
"@types/ws": "^8.5.13",
|
|
51
51
|
"magic-string": "^0.30.12",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vite": "^6.1.0",
|
|
57
57
|
"vitest": "~3.1.1",
|
|
58
58
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
59
|
-
"@cloudflare/workers-shared": "0.17.
|
|
59
|
+
"@cloudflare/workers-shared": "0.17.5",
|
|
60
60
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|