@cloudflare/vite-plugin 1.3.0 → 1.4.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 +5502 -1977
- package/dist/asset-workers/router-worker.js +4277 -1611
- package/dist/index.d.ts +2 -0
- package/dist/index.js +166 -106
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface PluginConfig extends EntryWorkerConfig {
|
|
|
21
21
|
experimental?: {
|
|
22
22
|
/** Experimental support for handling the _headers and _redirects files during Vite dev mode. */
|
|
23
23
|
headersAndRedirectsDevModeSupport?: boolean;
|
|
24
|
+
/** Experimental support for mixed mode (where bindings configured with `remote: true` access remote resources). */
|
|
25
|
+
mixedMode?: boolean;
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
|
package/dist/index.js
CHANGED
|
@@ -13257,7 +13257,7 @@ import { unstable_readConfig } from "wrangler";
|
|
|
13257
13257
|
function getDeployConfigPath(root) {
|
|
13258
13258
|
return path5.resolve(root, ".wrangler", "deploy", "config.json");
|
|
13259
13259
|
}
|
|
13260
|
-
function getWorkerConfigs(root) {
|
|
13260
|
+
function getWorkerConfigs(root, mixedModeEnabled) {
|
|
13261
13261
|
const deployConfigPath = getDeployConfigPath(root);
|
|
13262
13262
|
const deployConfig = JSON.parse(
|
|
13263
13263
|
fs2.readFileSync(deployConfigPath, "utf-8")
|
|
@@ -13270,7 +13270,10 @@ function getWorkerConfigs(root) {
|
|
|
13270
13270
|
path5.dirname(deployConfigPath),
|
|
13271
13271
|
configPath
|
|
13272
13272
|
);
|
|
13273
|
-
return unstable_readConfig(
|
|
13273
|
+
return unstable_readConfig(
|
|
13274
|
+
{ config: resolvedConfigPath },
|
|
13275
|
+
{ experimental: { mixedModeEnabled } }
|
|
13276
|
+
);
|
|
13274
13277
|
});
|
|
13275
13278
|
}
|
|
13276
13279
|
function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirectory) {
|
|
@@ -13337,6 +13340,7 @@ import * as fsp from "node:fs/promises";
|
|
|
13337
13340
|
import * as path6 from "node:path";
|
|
13338
13341
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13339
13342
|
import {
|
|
13343
|
+
getDefaultDevRegistryPath,
|
|
13340
13344
|
kCurrentWorker,
|
|
13341
13345
|
Log,
|
|
13342
13346
|
LogLevel,
|
|
@@ -13345,7 +13349,12 @@ import {
|
|
|
13345
13349
|
import colors2 from "picocolors";
|
|
13346
13350
|
import { globSync } from "tinyglobby";
|
|
13347
13351
|
import "vite";
|
|
13348
|
-
import {
|
|
13352
|
+
import {
|
|
13353
|
+
experimental_pickRemoteBindings,
|
|
13354
|
+
experimental_startMixedModeSession,
|
|
13355
|
+
unstable_convertConfigBindingsToStartWorkerBindings,
|
|
13356
|
+
unstable_getMiniflareWorkerOptions
|
|
13357
|
+
} from "wrangler";
|
|
13349
13358
|
function getPersistenceRoot(root, persistState) {
|
|
13350
13359
|
if (persistState === false) {
|
|
13351
13360
|
return;
|
|
@@ -13440,30 +13449,29 @@ function getEntryWorkerConfig(resolvedPluginConfig) {
|
|
|
13440
13449
|
}
|
|
13441
13450
|
return resolvedPluginConfig.workers[resolvedPluginConfig.entryWorkerEnvironmentName];
|
|
13442
13451
|
}
|
|
13443
|
-
function
|
|
13444
|
-
|
|
13452
|
+
function logUnknownTails(tails, userWorkers, log) {
|
|
13453
|
+
for (const tailService of tails ?? []) {
|
|
13445
13454
|
let name;
|
|
13446
13455
|
if (typeof tailService === "string") {
|
|
13447
13456
|
name = tailService;
|
|
13448
13457
|
} else if (typeof tailService === "object" && "name" in tailService && typeof tailService.name === "string") {
|
|
13449
13458
|
name = tailService.name;
|
|
13450
13459
|
} else {
|
|
13451
|
-
|
|
13460
|
+
continue;
|
|
13452
13461
|
}
|
|
13453
13462
|
const found = userWorkers.some((w) => w.name === name);
|
|
13454
13463
|
if (!found) {
|
|
13455
13464
|
log(
|
|
13456
13465
|
colors2.dim(
|
|
13457
13466
|
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.`
|
|
13467
|
+
`Tail consumer "${name}" was not found in your config. Make sure you add it to the config or run it in another dev session if you'd like to simulate receiving tail events locally.`
|
|
13459
13468
|
)
|
|
13460
13469
|
)
|
|
13461
13470
|
);
|
|
13462
13471
|
}
|
|
13463
|
-
|
|
13464
|
-
});
|
|
13472
|
+
}
|
|
13465
13473
|
}
|
|
13466
|
-
function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
|
|
13474
|
+
async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPort) {
|
|
13467
13475
|
const resolvedViteConfig = viteDevServer.config;
|
|
13468
13476
|
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
13469
13477
|
const assetsConfig = getAssetsConfig(
|
|
@@ -13539,53 +13547,64 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13539
13547
|
}
|
|
13540
13548
|
}
|
|
13541
13549
|
];
|
|
13542
|
-
const workersFromConfig = resolvedPluginConfig.type === "workers" ?
|
|
13543
|
-
(
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
...workerOptions
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13550
|
+
const workersFromConfig = resolvedPluginConfig.type === "workers" ? await Promise.all(
|
|
13551
|
+
Object.entries(resolvedPluginConfig.workers).map(
|
|
13552
|
+
async ([environmentName, workerConfig]) => {
|
|
13553
|
+
const mixedModeSession = resolvedPluginConfig.experimental.mixedMode ? await maybeStartOrUpdateMixedModeSession(workerConfig) : void 0;
|
|
13554
|
+
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
|
|
13555
|
+
{
|
|
13556
|
+
...workerConfig,
|
|
13557
|
+
assets: void 0
|
|
13558
|
+
},
|
|
13559
|
+
resolvedPluginConfig.cloudflareEnv,
|
|
13560
|
+
{
|
|
13561
|
+
mixedModeConnectionString: mixedModeSession?.mixedModeConnectionString,
|
|
13562
|
+
mixedModeEnabled: resolvedPluginConfig.experimental.mixedMode
|
|
13563
|
+
}
|
|
13564
|
+
);
|
|
13565
|
+
const { externalWorkers: externalWorkers2 } = miniflareWorkerOptions;
|
|
13566
|
+
const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
13567
|
+
return {
|
|
13568
|
+
externalWorkers: externalWorkers2,
|
|
13569
|
+
worker: {
|
|
13570
|
+
...workerOptions,
|
|
13571
|
+
name: workerOptions.name ?? workerConfig.name,
|
|
13572
|
+
unsafeInspectorProxy: inspectorPort !== false,
|
|
13573
|
+
unsafeDirectSockets: environmentName === resolvedPluginConfig.entryWorkerEnvironmentName ? (
|
|
13574
|
+
// Expose the default entrypoint of the entry worker on the dev registry
|
|
13575
|
+
[{ entrypoint: void 0, proxy: true }]
|
|
13576
|
+
) : [],
|
|
13577
|
+
modulesRoot: miniflareModulesRoot,
|
|
13578
|
+
unsafeEvalBinding: "__VITE_UNSAFE_EVAL__",
|
|
13579
|
+
serviceBindings: {
|
|
13580
|
+
...workerOptions.serviceBindings,
|
|
13581
|
+
...environmentName === resolvedPluginConfig.entryWorkerEnvironmentName && workerConfig.assets?.binding ? {
|
|
13582
|
+
[workerConfig.assets.binding]: ASSET_WORKER_NAME
|
|
13583
|
+
} : {},
|
|
13584
|
+
__VITE_INVOKE_MODULE__: async (request) => {
|
|
13585
|
+
const payload = await request.json();
|
|
13586
|
+
const invokePayloadData = payload.data;
|
|
13587
|
+
assert6(
|
|
13588
|
+
invokePayloadData.name === "fetchModule",
|
|
13589
|
+
`Invalid invoke event: ${invokePayloadData.name}`
|
|
13590
|
+
);
|
|
13591
|
+
const [moduleId] = invokePayloadData.data;
|
|
13592
|
+
if (additionalModuleRE.test(moduleId)) {
|
|
13593
|
+
const result2 = {
|
|
13594
|
+
externalize: moduleId,
|
|
13595
|
+
type: "module"
|
|
13596
|
+
};
|
|
13597
|
+
return MiniflareResponse.json({ result: result2 });
|
|
13598
|
+
}
|
|
13599
|
+
const devEnvironment = viteDevServer.environments[environmentName];
|
|
13600
|
+
const result = await devEnvironment.hot.handleInvoke(payload);
|
|
13601
|
+
return MiniflareResponse.json(result);
|
|
13580
13602
|
}
|
|
13581
|
-
const devEnvironment = viteDevServer.environments[environmentName];
|
|
13582
|
-
const result = await devEnvironment.hot.handleInvoke(payload);
|
|
13583
|
-
return MiniflareResponse.json(result);
|
|
13584
13603
|
}
|
|
13585
13604
|
}
|
|
13586
|
-
}
|
|
13587
|
-
}
|
|
13588
|
-
|
|
13605
|
+
};
|
|
13606
|
+
}
|
|
13607
|
+
)
|
|
13589
13608
|
) : [];
|
|
13590
13609
|
const userWorkers = workersFromConfig.map((options) => options.worker);
|
|
13591
13610
|
const externalWorkers = workersFromConfig.flatMap(
|
|
@@ -13597,8 +13616,10 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13597
13616
|
const logger = new ViteMiniflareLogger(resolvedViteConfig);
|
|
13598
13617
|
return {
|
|
13599
13618
|
log: logger,
|
|
13619
|
+
logRequests: false,
|
|
13600
13620
|
inspectorPort: inspectorPort === false ? void 0 : inspectorPort,
|
|
13601
13621
|
unsafeInspectorProxy: inspectorPort !== false,
|
|
13622
|
+
unsafeDevRegistryPath: getDefaultDevRegistryPath(),
|
|
13602
13623
|
handleRuntimeStdio(stdout, stderr) {
|
|
13603
13624
|
const decoder = new TextDecoder();
|
|
13604
13625
|
stdout.forEach((data2) => logger.info(decoder.decode(data2)));
|
|
@@ -13652,13 +13673,13 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspectorPo
|
|
|
13652
13673
|
`export const ${className} = createWorkflowEntrypointWrapper('${className}');`
|
|
13653
13674
|
);
|
|
13654
13675
|
}
|
|
13676
|
+
logUnknownTails(
|
|
13677
|
+
workerOptions.tails,
|
|
13678
|
+
userWorkers,
|
|
13679
|
+
viteDevServer.config.logger.warn
|
|
13680
|
+
);
|
|
13655
13681
|
return {
|
|
13656
13682
|
...workerOptions,
|
|
13657
|
-
tails: filterTails(
|
|
13658
|
-
workerOptions.tails,
|
|
13659
|
-
userWorkers,
|
|
13660
|
-
viteDevServer.config.logger.warn
|
|
13661
|
-
),
|
|
13662
13683
|
modules: [
|
|
13663
13684
|
{
|
|
13664
13685
|
type: "ESModule",
|
|
@@ -13740,32 +13761,48 @@ function getPreviewModules(main, modulesRules) {
|
|
|
13740
13761
|
]
|
|
13741
13762
|
};
|
|
13742
13763
|
}
|
|
13743
|
-
function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistState, inspectorPort) {
|
|
13764
|
+
async function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistState, mixedModeEnabled, inspectorPort) {
|
|
13744
13765
|
const resolvedViteConfig = vitePreviewServer.config;
|
|
13745
|
-
const workers =
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13766
|
+
const workers = (await Promise.all(
|
|
13767
|
+
workerConfigs.map(async (workerConfig, i) => {
|
|
13768
|
+
const mixedModeSession = mixedModeEnabled ? await maybeStartOrUpdateMixedModeSession(workerConfig) : void 0;
|
|
13769
|
+
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
|
|
13770
|
+
workerConfig,
|
|
13771
|
+
void 0,
|
|
13772
|
+
{
|
|
13773
|
+
mixedModeConnectionString: mixedModeSession?.mixedModeConnectionString,
|
|
13774
|
+
mixedModeEnabled
|
|
13775
|
+
}
|
|
13776
|
+
);
|
|
13777
|
+
const { externalWorkers } = miniflareWorkerOptions;
|
|
13778
|
+
const { ratelimits, modulesRules, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
13779
|
+
logUnknownTails(
|
|
13780
|
+
workerOptions.tails,
|
|
13781
|
+
workerConfigs,
|
|
13782
|
+
vitePreviewServer.config.logger.warn
|
|
13783
|
+
);
|
|
13784
|
+
return [
|
|
13785
|
+
{
|
|
13786
|
+
...workerOptions,
|
|
13787
|
+
name: workerOptions.name ?? workerConfig.name,
|
|
13788
|
+
unsafeInspectorProxy: inspectorPort !== false,
|
|
13789
|
+
unsafeDirectSockets: (
|
|
13790
|
+
// This exposes the default entrypoint of the entry worker on the dev registry
|
|
13791
|
+
// Assuming that the first worker config to be the entry worker.
|
|
13792
|
+
i === 0 ? [{ entrypoint: void 0, proxy: true }] : []
|
|
13793
|
+
),
|
|
13794
|
+
...miniflareWorkerOptions.main ? getPreviewModules(miniflareWorkerOptions.main, modulesRules) : { modules: true, script: "" }
|
|
13795
|
+
},
|
|
13796
|
+
...externalWorkers
|
|
13797
|
+
];
|
|
13798
|
+
})
|
|
13799
|
+
)).flat();
|
|
13764
13800
|
const logger = new ViteMiniflareLogger(resolvedViteConfig);
|
|
13765
13801
|
return {
|
|
13766
13802
|
log: logger,
|
|
13767
13803
|
inspectorPort: inspectorPort === false ? void 0 : inspectorPort,
|
|
13768
13804
|
unsafeInspectorProxy: inspectorPort !== false,
|
|
13805
|
+
unsafeDevRegistryPath: getDefaultDevRegistryPath(),
|
|
13769
13806
|
handleRuntimeStdio(stdout, stderr) {
|
|
13770
13807
|
const decoder = new TextDecoder();
|
|
13771
13808
|
stdout.forEach((data2) => logger.info(decoder.decode(data2)));
|
|
@@ -13780,7 +13817,6 @@ function getPreviewMiniflareOptions(vitePreviewServer, workerConfigs, persistSta
|
|
|
13780
13817
|
workers
|
|
13781
13818
|
};
|
|
13782
13819
|
}
|
|
13783
|
-
var removedMessages = [/^Ready on http/, /^Updated and ready on http/];
|
|
13784
13820
|
var ViteMiniflareLogger = class extends Log {
|
|
13785
13821
|
logger;
|
|
13786
13822
|
constructor(config) {
|
|
@@ -13788,11 +13824,6 @@ var ViteMiniflareLogger = class extends Log {
|
|
|
13788
13824
|
this.logger = config.logger;
|
|
13789
13825
|
}
|
|
13790
13826
|
logWithLevel(level, message) {
|
|
13791
|
-
for (const removedMessage of removedMessages) {
|
|
13792
|
-
if (removedMessage.test(message)) {
|
|
13793
|
-
return;
|
|
13794
|
-
}
|
|
13795
|
-
}
|
|
13796
13827
|
switch (level) {
|
|
13797
13828
|
case LogLevel.ERROR:
|
|
13798
13829
|
return this.logger.error(message);
|
|
@@ -13802,6 +13833,8 @@ var ViteMiniflareLogger = class extends Log {
|
|
|
13802
13833
|
return this.logger.info(message);
|
|
13803
13834
|
}
|
|
13804
13835
|
}
|
|
13836
|
+
logReady() {
|
|
13837
|
+
}
|
|
13805
13838
|
};
|
|
13806
13839
|
function miniflareLogLevelFromViteLogLevel(level = "info") {
|
|
13807
13840
|
switch (level) {
|
|
@@ -13815,6 +13848,24 @@ function miniflareLogLevelFromViteLogLevel(level = "info") {
|
|
|
13815
13848
|
return LogLevel.NONE;
|
|
13816
13849
|
}
|
|
13817
13850
|
}
|
|
13851
|
+
var mixedModeSessionsMap = /* @__PURE__ */ new Map();
|
|
13852
|
+
async function maybeStartOrUpdateMixedModeSession(workerConfig) {
|
|
13853
|
+
const workerRemoteBindings = experimental_pickRemoteBindings(
|
|
13854
|
+
unstable_convertConfigBindingsToStartWorkerBindings(workerConfig) ?? {}
|
|
13855
|
+
);
|
|
13856
|
+
assert6(workerConfig.name, "Found workerConfig without a name");
|
|
13857
|
+
let mixedModeSession = mixedModeSessionsMap.get(workerConfig.name);
|
|
13858
|
+
if (mixedModeSession === void 0) {
|
|
13859
|
+
if (Object.keys(workerRemoteBindings).length > 0) {
|
|
13860
|
+
mixedModeSession = await experimental_startMixedModeSession(workerRemoteBindings);
|
|
13861
|
+
mixedModeSessionsMap.set(workerConfig.name, mixedModeSession);
|
|
13862
|
+
}
|
|
13863
|
+
} else {
|
|
13864
|
+
await mixedModeSession.updateBindings(workerRemoteBindings);
|
|
13865
|
+
}
|
|
13866
|
+
await mixedModeSession?.ready;
|
|
13867
|
+
return mixedModeSession;
|
|
13868
|
+
}
|
|
13818
13869
|
|
|
13819
13870
|
// src/plugin-config.ts
|
|
13820
13871
|
import assert8 from "node:assert";
|
|
@@ -13869,12 +13920,15 @@ var nullableNonApplicable = [
|
|
|
13869
13920
|
"site",
|
|
13870
13921
|
"tsconfig"
|
|
13871
13922
|
];
|
|
13872
|
-
function readWorkerConfig(configPath, env2) {
|
|
13923
|
+
function readWorkerConfig(configPath, env2, mixedModeEnabled) {
|
|
13873
13924
|
const nonApplicable = {
|
|
13874
13925
|
replacedByVite: /* @__PURE__ */ new Set(),
|
|
13875
13926
|
notRelevant: /* @__PURE__ */ new Set()
|
|
13876
13927
|
};
|
|
13877
|
-
const config = unstable_readConfig2(
|
|
13928
|
+
const config = unstable_readConfig2(
|
|
13929
|
+
{ config: configPath, env: env2 },
|
|
13930
|
+
{ experimental: { mixedModeEnabled } }
|
|
13931
|
+
);
|
|
13878
13932
|
const raw = structuredClone(config);
|
|
13879
13933
|
nullableNonApplicable.forEach((prop) => {
|
|
13880
13934
|
if (config[prop] !== void 0) {
|
|
@@ -13969,11 +14023,15 @@ function isNotRelevant(configName) {
|
|
|
13969
14023
|
function missingFieldErrorMessage(field, configPath, env2) {
|
|
13970
14024
|
return `No ${field} field provided in '${configPath}'${env2 ? ` for '${env2}' environment` : ""}`;
|
|
13971
14025
|
}
|
|
13972
|
-
function getWorkerConfig(configPath, env2, opts) {
|
|
14026
|
+
function getWorkerConfig(configPath, env2, mixedModeEnabled, opts) {
|
|
13973
14027
|
if (opts?.visitedConfigPaths?.has(configPath)) {
|
|
13974
14028
|
throw new Error(`Duplicate Wrangler config path found: ${configPath}`);
|
|
13975
14029
|
}
|
|
13976
|
-
const { raw, config, nonApplicable } = readWorkerConfig(
|
|
14030
|
+
const { raw, config, nonApplicable } = readWorkerConfig(
|
|
14031
|
+
configPath,
|
|
14032
|
+
env2,
|
|
14033
|
+
mixedModeEnabled
|
|
14034
|
+
);
|
|
13977
14035
|
opts?.visitedConfigPaths?.add(configPath);
|
|
13978
14036
|
if (!config.name) {
|
|
13979
14037
|
throw new Error(missingFieldErrorMessage(`'name'`, configPath, env2));
|
|
@@ -14098,6 +14156,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14098
14156
|
const entryWorkerResolvedConfig = getWorkerConfig(
|
|
14099
14157
|
entryWorkerConfigPath,
|
|
14100
14158
|
cloudflareEnv,
|
|
14159
|
+
pluginConfig.experimental?.mixedMode ?? false,
|
|
14101
14160
|
{
|
|
14102
14161
|
visitedConfigPaths: configPaths,
|
|
14103
14162
|
isEntryWorker: true
|
|
@@ -14131,6 +14190,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14131
14190
|
const workerResolvedConfig = getWorkerConfig(
|
|
14132
14191
|
workerConfigPath,
|
|
14133
14192
|
cloudflareEnv,
|
|
14193
|
+
pluginConfig.experimental?.mixedMode ?? false,
|
|
14134
14194
|
{
|
|
14135
14195
|
visitedConfigPaths: configPaths
|
|
14136
14196
|
}
|
|
@@ -14448,22 +14508,15 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14448
14508
|
pluginConfig,
|
|
14449
14509
|
viteDevServer
|
|
14450
14510
|
);
|
|
14511
|
+
const miniflareDevOptions = await getDevMiniflareOptions(
|
|
14512
|
+
resolvedPluginConfig,
|
|
14513
|
+
viteDevServer,
|
|
14514
|
+
inputInspectorPort
|
|
14515
|
+
);
|
|
14451
14516
|
if (!miniflare) {
|
|
14452
|
-
miniflare = new Miniflare(
|
|
14453
|
-
getDevMiniflareOptions(
|
|
14454
|
-
resolvedPluginConfig,
|
|
14455
|
-
viteDevServer,
|
|
14456
|
-
inputInspectorPort
|
|
14457
|
-
)
|
|
14458
|
-
);
|
|
14517
|
+
miniflare = new Miniflare(miniflareDevOptions);
|
|
14459
14518
|
} else {
|
|
14460
|
-
await miniflare.setOptions(
|
|
14461
|
-
getDevMiniflareOptions(
|
|
14462
|
-
resolvedPluginConfig,
|
|
14463
|
-
viteDevServer,
|
|
14464
|
-
inputInspectorPort
|
|
14465
|
-
)
|
|
14466
|
-
);
|
|
14519
|
+
await miniflare.setOptions(miniflareDevOptions);
|
|
14467
14520
|
}
|
|
14468
14521
|
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14469
14522
|
if (viteDevServer.httpServer) {
|
|
@@ -14496,16 +14549,20 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14496
14549
|
};
|
|
14497
14550
|
},
|
|
14498
14551
|
async configurePreviewServer(vitePreviewServer) {
|
|
14499
|
-
const workerConfigs = getWorkerConfigs(
|
|
14552
|
+
const workerConfigs = getWorkerConfigs(
|
|
14553
|
+
vitePreviewServer.config.root,
|
|
14554
|
+
pluginConfig.experimental?.mixedMode ?? false
|
|
14555
|
+
);
|
|
14500
14556
|
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14501
14557
|
pluginConfig,
|
|
14502
14558
|
vitePreviewServer
|
|
14503
14559
|
);
|
|
14504
14560
|
const miniflare2 = new Miniflare(
|
|
14505
|
-
getPreviewMiniflareOptions(
|
|
14561
|
+
await getPreviewMiniflareOptions(
|
|
14506
14562
|
vitePreviewServer,
|
|
14507
14563
|
workerConfigs,
|
|
14508
14564
|
pluginConfig.persistState ?? true,
|
|
14565
|
+
!!pluginConfig.experimental?.mixedMode,
|
|
14509
14566
|
inputInspectorPort
|
|
14510
14567
|
)
|
|
14511
14568
|
);
|
|
@@ -14762,7 +14819,10 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14762
14819
|
});
|
|
14763
14820
|
},
|
|
14764
14821
|
async configurePreviewServer(vitePreviewServer) {
|
|
14765
|
-
const workerConfigs = getWorkerConfigs(
|
|
14822
|
+
const workerConfigs = getWorkerConfigs(
|
|
14823
|
+
vitePreviewServer.config.root,
|
|
14824
|
+
pluginConfig.experimental?.mixedMode ?? false
|
|
14825
|
+
);
|
|
14766
14826
|
if (workerConfigs.length >= 1 && pluginConfig.inspectorPort !== false) {
|
|
14767
14827
|
addDebugToVitePrintUrls(vitePreviewServer);
|
|
14768
14828
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"tinyglobby": "^0.2.12",
|
|
42
42
|
"unenv": "2.0.0-rc.17",
|
|
43
43
|
"ws": "8.18.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
44
|
+
"wrangler": "4.19.0",
|
|
45
|
+
"miniflare": "4.20250525.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250525.0",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
50
|
"@types/ws": "^8.5.13",
|
|
51
51
|
"magic-string": "^0.30.12",
|