@cloudflare/vite-plugin 0.0.0-afd93b98d → 0.0.0-b0571fdc3
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.
|
@@ -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
|
@@ -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(),
|
|
@@ -5832,14 +5833,14 @@ var AssetConfigSchema = z.object({
|
|
|
5832
5833
|
});
|
|
5833
5834
|
|
|
5834
5835
|
// src/asset-config.ts
|
|
5835
|
-
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig,
|
|
5836
|
+
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig, changedFilePath) {
|
|
5836
5837
|
if (!resolvedPluginConfig.experimental?.headersAndRedirectsDevModeSupport) {
|
|
5837
5838
|
return false;
|
|
5838
5839
|
}
|
|
5839
5840
|
return [
|
|
5840
5841
|
getRedirectsConfigPath(resolvedViteConfig),
|
|
5841
5842
|
getHeadersConfigPath(resolvedViteConfig)
|
|
5842
|
-
].includes(
|
|
5843
|
+
].includes(changedFilePath);
|
|
5843
5844
|
}
|
|
5844
5845
|
function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig) {
|
|
5845
5846
|
const assetsConfig = resolvedPluginConfig.type === "assets-only" ? resolvedPluginConfig.config.assets : entryWorkerConfig?.assets;
|
|
@@ -12880,6 +12881,15 @@ function isNodeCompat(workerConfig) {
|
|
|
12880
12881
|
}
|
|
12881
12882
|
return false;
|
|
12882
12883
|
}
|
|
12884
|
+
function isNodeAls(workerConfig) {
|
|
12885
|
+
return workerConfig !== void 0 && getNodeCompat(
|
|
12886
|
+
workerConfig.compatibility_date,
|
|
12887
|
+
workerConfig.compatibility_flags ?? []
|
|
12888
|
+
).mode === "als";
|
|
12889
|
+
}
|
|
12890
|
+
function isNodeAlsModule(path10) {
|
|
12891
|
+
return /^(node:)?async_hooks$/.test(path10);
|
|
12892
|
+
}
|
|
12883
12893
|
function injectGlobalCode(id, code) {
|
|
12884
12894
|
const injectedCode = Object.entries(env.inject).map(([globalName, globalInject]) => {
|
|
12885
12895
|
if (typeof globalInject === "string") {
|
|
@@ -12910,7 +12920,7 @@ globalThis.${globalName} = var_${globalName}.${exportName};
|
|
|
12910
12920
|
}
|
|
12911
12921
|
function resolveNodeJSImport(source) {
|
|
12912
12922
|
const alias = env.alias[source];
|
|
12913
|
-
if (alias) {
|
|
12923
|
+
if (alias && !nodeCompatExternals.has(alias)) {
|
|
12914
12924
|
return {
|
|
12915
12925
|
unresolved: alias,
|
|
12916
12926
|
resolved: resolvePathSync(alias, { url: import.meta.url })
|
|
@@ -14181,12 +14191,15 @@ function validateWorkerEnvironmentsResolvedConfigs(resolvedPluginConfig, resolve
|
|
|
14181
14191
|
for (const envName of workersEnvironmentNames) {
|
|
14182
14192
|
const workerEnvConfig = resolvedViteConfig.environments[envName];
|
|
14183
14193
|
assert9(workerEnvConfig, `Missing environment config for "${envName}"`);
|
|
14184
|
-
const { optimizeDeps, resolve:
|
|
14194
|
+
const { optimizeDeps, resolve: resolve7 } = workerEnvConfig;
|
|
14185
14195
|
const disallowedConfig = {};
|
|
14186
14196
|
const disallowedOptimizeDepsExcludeEntries = (optimizeDeps.exclude ?? []).filter((entry) => {
|
|
14187
14197
|
if (cloudflareBuiltInModules.includes(entry)) {
|
|
14188
14198
|
return false;
|
|
14189
14199
|
}
|
|
14200
|
+
if (isNodeAlsModule(entry) && isNodeAls(resolvedPluginConfig.workers[envName])) {
|
|
14201
|
+
return false;
|
|
14202
|
+
}
|
|
14190
14203
|
if (NODEJS_MODULES_RE.test(entry) && isNodeCompat(resolvedPluginConfig.workers[envName])) {
|
|
14191
14204
|
return false;
|
|
14192
14205
|
}
|
|
@@ -14195,8 +14208,8 @@ function validateWorkerEnvironmentsResolvedConfigs(resolvedPluginConfig, resolve
|
|
|
14195
14208
|
if (disallowedOptimizeDepsExcludeEntries.length > 0) {
|
|
14196
14209
|
disallowedConfig.optimizeDepsExclude = disallowedOptimizeDepsExcludeEntries;
|
|
14197
14210
|
}
|
|
14198
|
-
if (
|
|
14199
|
-
disallowedConfig.resolveExternal =
|
|
14211
|
+
if (resolve7.external === true || resolve7.external.length > 0) {
|
|
14212
|
+
disallowedConfig.resolveExternal = resolve7.external;
|
|
14200
14213
|
}
|
|
14201
14214
|
if (Object.keys(disallowedConfig).length > 0) {
|
|
14202
14215
|
disallowedEnvsConfigs.set(envName, disallowedConfig);
|
|
@@ -14402,14 +14415,12 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14402
14415
|
}
|
|
14403
14416
|
},
|
|
14404
14417
|
hotUpdate(options) {
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
resolvedPluginConfig
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
)
|
|
14412
|
-
) {
|
|
14418
|
+
const changedFilePath = path9.resolve(options.file);
|
|
14419
|
+
if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
|
|
14420
|
+
resolvedPluginConfig,
|
|
14421
|
+
resolvedViteConfig,
|
|
14422
|
+
changedFilePath
|
|
14423
|
+
)) {
|
|
14413
14424
|
options.server.restart();
|
|
14414
14425
|
return [];
|
|
14415
14426
|
}
|
|
@@ -14419,11 +14430,11 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14419
14430
|
viteDevServer.httpServer,
|
|
14420
14431
|
"Unexpected error: No Vite HTTP server"
|
|
14421
14432
|
);
|
|
14433
|
+
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14434
|
+
pluginConfig,
|
|
14435
|
+
viteDevServer
|
|
14436
|
+
);
|
|
14422
14437
|
if (!miniflare) {
|
|
14423
|
-
const inputInspectorPort = await getInputInspectorPortOption(
|
|
14424
|
-
pluginConfig,
|
|
14425
|
-
viteDevServer
|
|
14426
|
-
);
|
|
14427
14438
|
miniflare = new Miniflare(
|
|
14428
14439
|
getDevMiniflareOptions(
|
|
14429
14440
|
resolvedPluginConfig,
|
|
@@ -14432,12 +14443,11 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14432
14443
|
)
|
|
14433
14444
|
);
|
|
14434
14445
|
} else {
|
|
14435
|
-
const resolvedInspectorPort = await getResolvedInspectorPort(pluginConfig);
|
|
14436
14446
|
await miniflare.setOptions(
|
|
14437
14447
|
getDevMiniflareOptions(
|
|
14438
14448
|
resolvedPluginConfig,
|
|
14439
14449
|
viteDevServer,
|
|
14440
|
-
|
|
14450
|
+
inputInspectorPort
|
|
14441
14451
|
)
|
|
14442
14452
|
);
|
|
14443
14453
|
}
|
|
@@ -14683,6 +14693,25 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14683
14693
|
);
|
|
14684
14694
|
}
|
|
14685
14695
|
},
|
|
14696
|
+
// Plugin that handles Node.js Async Local Storage (ALS) compatibility support for Vite Environments that are hosted in Cloudflare Workers.
|
|
14697
|
+
{
|
|
14698
|
+
name: "vite-plugin-cloudflare:nodejs-als",
|
|
14699
|
+
apply(_config, env2) {
|
|
14700
|
+
return !env2.isPreview;
|
|
14701
|
+
},
|
|
14702
|
+
configEnvironment(name, config) {
|
|
14703
|
+
if (isNodeAls(getWorkerConfig2(name))) {
|
|
14704
|
+
return {
|
|
14705
|
+
resolve: {
|
|
14706
|
+
builtins: ["async_hooks", "node:async_hooks"]
|
|
14707
|
+
},
|
|
14708
|
+
optimizeDeps: {
|
|
14709
|
+
exclude: ["async_hooks", "node:async_hooks"]
|
|
14710
|
+
}
|
|
14711
|
+
};
|
|
14712
|
+
}
|
|
14713
|
+
}
|
|
14714
|
+
},
|
|
14686
14715
|
// Plugin that provides an __debug path for debugging the Cloudflare Workers.
|
|
14687
14716
|
{
|
|
14688
14717
|
name: "vite-plugin-cloudflare:debug",
|
|
@@ -14748,6 +14777,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14748
14777
|
build.onResolve(
|
|
14749
14778
|
{ filter: NODEJS_MODULES_RE },
|
|
14750
14779
|
({ path: path10, importer }) => {
|
|
14780
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(path10)) {
|
|
14781
|
+
return;
|
|
14782
|
+
}
|
|
14751
14783
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
14752
14784
|
nodeJsCompatWarnings?.registerImport(path10, importer);
|
|
14753
14785
|
return { path: path10, external: true };
|
|
@@ -14777,6 +14809,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14777
14809
|
async resolveId(source, importer) {
|
|
14778
14810
|
const workerConfig = getWorkerConfig2(this.environment.name);
|
|
14779
14811
|
if (workerConfig && !isNodeCompat(workerConfig)) {
|
|
14812
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(source)) {
|
|
14813
|
+
return;
|
|
14814
|
+
}
|
|
14780
14815
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
14781
14816
|
if (nodejsBuiltins.has(source)) {
|
|
14782
14817
|
nodeJsCompatWarnings?.registerImport(source, importer);
|
|
@@ -14795,6 +14830,12 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14795
14830
|
}
|
|
14796
14831
|
}
|
|
14797
14832
|
async function getInputInspectorPortOption(pluginConfig, viteServer) {
|
|
14833
|
+
if (pluginConfig.inspectorPort === void 0 || pluginConfig.inspectorPort === 0) {
|
|
14834
|
+
const resolvedInspectorPort = await getResolvedInspectorPort(pluginConfig);
|
|
14835
|
+
if (resolvedInspectorPort !== null) {
|
|
14836
|
+
return resolvedInspectorPort;
|
|
14837
|
+
}
|
|
14838
|
+
}
|
|
14798
14839
|
const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
|
|
14799
14840
|
if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
|
|
14800
14841
|
viteServer.config.logger.warn(
|
|
@@ -14824,6 +14865,19 @@ function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
|
14824
14865
|
}
|
|
14825
14866
|
return null;
|
|
14826
14867
|
}
|
|
14868
|
+
function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
14869
|
+
return [...resolvedPluginConfig.configPaths].some((configPath) => {
|
|
14870
|
+
const dotDevDotVars = path9.join(path9.dirname(configPath), ".dev.vars");
|
|
14871
|
+
if (dotDevDotVars === changedFilePath) {
|
|
14872
|
+
return true;
|
|
14873
|
+
}
|
|
14874
|
+
if (resolvedPluginConfig.cloudflareEnv) {
|
|
14875
|
+
const dotDevDotVarsForEnv = `${dotDevDotVars}.${resolvedPluginConfig.cloudflareEnv}`;
|
|
14876
|
+
return dotDevDotVarsForEnv === changedFilePath;
|
|
14877
|
+
}
|
|
14878
|
+
return false;
|
|
14879
|
+
});
|
|
14880
|
+
}
|
|
14827
14881
|
export {
|
|
14828
14882
|
cloudflare2 as cloudflare
|
|
14829
14883
|
};
|
|
@@ -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-b0571fdc3",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
41
|
"unenv": "2.0.0-rc.15",
|
|
42
42
|
"ws": "8.18.0",
|
|
43
|
-
"@cloudflare/unenv-preset": "0.0.0-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
43
|
+
"@cloudflare/unenv-preset": "0.0.0-b0571fdc3",
|
|
44
|
+
"miniflare": "0.0.0-b0571fdc3",
|
|
45
|
+
"wrangler": "0.0.0-b0571fdc3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250424.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.
|
|
57
|
+
"vitest": "~3.1.1",
|
|
58
58
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
59
|
-
"@cloudflare/workers-
|
|
60
|
-
"@cloudflare/workers-
|
|
59
|
+
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
60
|
+
"@cloudflare/workers-shared": "0.0.0-b0571fdc3"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"vite": "^6.1.0",
|