@cloudflare/vite-plugin 0.0.0-39933740e → 0.0.0-3b60131ca
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/README.md +15 -540
- package/dist/asset-workers/asset-worker.js +678 -659
- package/dist/asset-workers/router-worker.js +1 -1
- package/dist/index.js +152 -30
- package/dist/runner-worker/index.js +9 -22
- package/package.json +8 -7
|
@@ -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
|
@@ -485,11 +485,12 @@ var require_mime = __commonJS({
|
|
|
485
485
|
});
|
|
486
486
|
|
|
487
487
|
// src/index.ts
|
|
488
|
-
import
|
|
488
|
+
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
492
|
import { createMiddleware } from "@hattip/adapter-node";
|
|
493
|
+
import replace from "@rollup/plugin-replace";
|
|
493
494
|
|
|
494
495
|
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
495
496
|
var comma = ",".charCodeAt(0);
|
|
@@ -5783,7 +5784,8 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
5783
5784
|
// ../workers-shared/utils/types.ts
|
|
5784
5785
|
var InternalConfigSchema = z.object({
|
|
5785
5786
|
account_id: z.number().optional(),
|
|
5786
|
-
script_id: z.number().optional()
|
|
5787
|
+
script_id: z.number().optional(),
|
|
5788
|
+
debug: z.boolean().optional()
|
|
5787
5789
|
});
|
|
5788
5790
|
var RouterConfigSchema = z.object({
|
|
5789
5791
|
invoke_user_worker_ahead_of_assets: z.boolean().optional(),
|
|
@@ -5831,14 +5833,14 @@ var AssetConfigSchema = z.object({
|
|
|
5831
5833
|
});
|
|
5832
5834
|
|
|
5833
5835
|
// src/asset-config.ts
|
|
5834
|
-
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig,
|
|
5836
|
+
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig, changedFilePath) {
|
|
5835
5837
|
if (!resolvedPluginConfig.experimental?.headersAndRedirectsDevModeSupport) {
|
|
5836
5838
|
return false;
|
|
5837
5839
|
}
|
|
5838
5840
|
return [
|
|
5839
5841
|
getRedirectsConfigPath(resolvedViteConfig),
|
|
5840
5842
|
getHeadersConfigPath(resolvedViteConfig)
|
|
5841
|
-
].includes(
|
|
5843
|
+
].includes(changedFilePath);
|
|
5842
5844
|
}
|
|
5843
5845
|
function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig) {
|
|
5844
5846
|
const assetsConfig = resolvedPluginConfig.type === "assets-only" ? resolvedPluginConfig.config.assets : entryWorkerConfig?.assets;
|
|
@@ -12879,6 +12881,15 @@ function isNodeCompat(workerConfig) {
|
|
|
12879
12881
|
}
|
|
12880
12882
|
return false;
|
|
12881
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
|
+
}
|
|
12882
12893
|
function injectGlobalCode(id, code) {
|
|
12883
12894
|
const injectedCode = Object.entries(env.inject).map(([globalName, globalInject]) => {
|
|
12884
12895
|
if (typeof globalInject === "string") {
|
|
@@ -12909,7 +12920,7 @@ globalThis.${globalName} = var_${globalName}.${exportName};
|
|
|
12909
12920
|
}
|
|
12910
12921
|
function resolveNodeJSImport(source) {
|
|
12911
12922
|
const alias = env.alias[source];
|
|
12912
|
-
if (alias) {
|
|
12923
|
+
if (alias && !nodeCompatExternals.has(alias)) {
|
|
12913
12924
|
return {
|
|
12914
12925
|
unresolved: alias,
|
|
12915
12926
|
resolved: resolvePathSync(alias, { url: import.meta.url })
|
|
@@ -13828,8 +13839,7 @@ var nonApplicableWorkerConfigs = {
|
|
|
13828
13839
|
"preserve_file_names",
|
|
13829
13840
|
"rules",
|
|
13830
13841
|
"site",
|
|
13831
|
-
"tsconfig"
|
|
13832
|
-
"upload_source_maps"
|
|
13842
|
+
"tsconfig"
|
|
13833
13843
|
]
|
|
13834
13844
|
};
|
|
13835
13845
|
var nullableNonApplicable = [
|
|
@@ -13840,8 +13850,7 @@ var nullableNonApplicable = [
|
|
|
13840
13850
|
"no_bundle",
|
|
13841
13851
|
"preserve_file_names",
|
|
13842
13852
|
"site",
|
|
13843
|
-
"tsconfig"
|
|
13844
|
-
"upload_source_maps"
|
|
13853
|
+
"tsconfig"
|
|
13845
13854
|
];
|
|
13846
13855
|
function readWorkerConfig(configPath, env2) {
|
|
13847
13856
|
const nonApplicable = {
|
|
@@ -14174,6 +14183,57 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
14174
14183
|
);
|
|
14175
14184
|
}
|
|
14176
14185
|
|
|
14186
|
+
// src/worker-environments-validation.ts
|
|
14187
|
+
import assert9 from "node:assert";
|
|
14188
|
+
function validateWorkerEnvironmentsResolvedConfigs(resolvedPluginConfig, resolvedViteConfig) {
|
|
14189
|
+
const workersEnvironmentNames = Object.keys(resolvedPluginConfig.workers);
|
|
14190
|
+
const disallowedEnvsConfigs = /* @__PURE__ */ new Map();
|
|
14191
|
+
for (const envName of workersEnvironmentNames) {
|
|
14192
|
+
const workerEnvConfig = resolvedViteConfig.environments[envName];
|
|
14193
|
+
assert9(workerEnvConfig, `Missing environment config for "${envName}"`);
|
|
14194
|
+
const { optimizeDeps, resolve: resolve7 } = workerEnvConfig;
|
|
14195
|
+
const disallowedConfig = {};
|
|
14196
|
+
const disallowedOptimizeDepsExcludeEntries = (optimizeDeps.exclude ?? []).filter((entry) => {
|
|
14197
|
+
if (cloudflareBuiltInModules.includes(entry)) {
|
|
14198
|
+
return false;
|
|
14199
|
+
}
|
|
14200
|
+
if (isNodeAlsModule(entry) && isNodeAls(resolvedPluginConfig.workers[envName])) {
|
|
14201
|
+
return false;
|
|
14202
|
+
}
|
|
14203
|
+
if (NODEJS_MODULES_RE.test(entry) && isNodeCompat(resolvedPluginConfig.workers[envName])) {
|
|
14204
|
+
return false;
|
|
14205
|
+
}
|
|
14206
|
+
return true;
|
|
14207
|
+
});
|
|
14208
|
+
if (disallowedOptimizeDepsExcludeEntries.length > 0) {
|
|
14209
|
+
disallowedConfig.optimizeDepsExclude = disallowedOptimizeDepsExcludeEntries;
|
|
14210
|
+
}
|
|
14211
|
+
if (resolve7.external === true || resolve7.external.length > 0) {
|
|
14212
|
+
disallowedConfig.resolveExternal = resolve7.external;
|
|
14213
|
+
}
|
|
14214
|
+
if (Object.keys(disallowedConfig).length > 0) {
|
|
14215
|
+
disallowedEnvsConfigs.set(envName, disallowedConfig);
|
|
14216
|
+
}
|
|
14217
|
+
}
|
|
14218
|
+
if (disallowedEnvsConfigs.size > 0) {
|
|
14219
|
+
const errorMessage = `The following environment configurations are incompatible with the Cloudflare Vite plugin:
|
|
14220
|
+
${[
|
|
14221
|
+
...disallowedEnvsConfigs
|
|
14222
|
+
].map(
|
|
14223
|
+
([envName, disallowedConfig]) => [
|
|
14224
|
+
disallowedConfig.optimizeDepsExclude ? ` - "${envName}" environment: \`optimizeDeps.exclude\`: ${JSON.stringify(disallowedConfig.optimizeDepsExclude)}
|
|
14225
|
+
` : null,
|
|
14226
|
+
disallowedConfig.resolveExternal ? ` - "${envName}" environment: \`resolve.external\`: ${JSON.stringify(disallowedConfig.resolveExternal)}
|
|
14227
|
+
` : null
|
|
14228
|
+
].join("")
|
|
14229
|
+
).join(
|
|
14230
|
+
""
|
|
14231
|
+
)}To resolve this issue, avoid setting \`optimizeDeps.exclude\` and \`resolve.external\` in your Cloudflare Worker environments.
|
|
14232
|
+
`;
|
|
14233
|
+
throw new Error(errorMessage);
|
|
14234
|
+
}
|
|
14235
|
+
}
|
|
14236
|
+
|
|
14177
14237
|
// src/index.ts
|
|
14178
14238
|
var workersConfigsWarningShown = false;
|
|
14179
14239
|
var miniflare;
|
|
@@ -14244,7 +14304,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14244
14304
|
resolvedPluginConfig.workers
|
|
14245
14305
|
).map((environmentName) => {
|
|
14246
14306
|
const environment = builder.environments[environmentName];
|
|
14247
|
-
|
|
14307
|
+
assert10(
|
|
14248
14308
|
environment,
|
|
14249
14309
|
`${environmentName} environment not found`
|
|
14250
14310
|
);
|
|
@@ -14265,6 +14325,12 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14265
14325
|
},
|
|
14266
14326
|
configResolved(config) {
|
|
14267
14327
|
resolvedViteConfig = config;
|
|
14328
|
+
if (resolvedPluginConfig?.type === "workers") {
|
|
14329
|
+
validateWorkerEnvironmentsResolvedConfigs(
|
|
14330
|
+
resolvedPluginConfig,
|
|
14331
|
+
resolvedViteConfig
|
|
14332
|
+
);
|
|
14333
|
+
}
|
|
14268
14334
|
},
|
|
14269
14335
|
generateBundle(_, bundle) {
|
|
14270
14336
|
let config;
|
|
@@ -14285,7 +14351,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14285
14351
|
if (isEntryWorker && hasClientBuild) {
|
|
14286
14352
|
const workerOutputDirectory = this.environment.config.build.outDir;
|
|
14287
14353
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
14288
|
-
|
|
14354
|
+
assert10(
|
|
14289
14355
|
clientOutputDirectory,
|
|
14290
14356
|
"Unexpected error: client output directory is undefined"
|
|
14291
14357
|
);
|
|
@@ -14349,20 +14415,18 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14349
14415
|
}
|
|
14350
14416
|
},
|
|
14351
14417
|
hotUpdate(options) {
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
resolvedPluginConfig
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
)
|
|
14359
|
-
) {
|
|
14418
|
+
const changedFilePath = path9.resolve(options.file);
|
|
14419
|
+
if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
|
|
14420
|
+
resolvedPluginConfig,
|
|
14421
|
+
resolvedViteConfig,
|
|
14422
|
+
changedFilePath
|
|
14423
|
+
)) {
|
|
14360
14424
|
options.server.restart();
|
|
14361
14425
|
return [];
|
|
14362
14426
|
}
|
|
14363
14427
|
},
|
|
14364
14428
|
async configureServer(viteDevServer) {
|
|
14365
|
-
|
|
14429
|
+
assert10(
|
|
14366
14430
|
viteDevServer.httpServer,
|
|
14367
14431
|
"Unexpected error: No Vite HTTP server"
|
|
14368
14432
|
);
|
|
@@ -14370,8 +14434,8 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14370
14434
|
pluginConfig,
|
|
14371
14435
|
viteDevServer
|
|
14372
14436
|
);
|
|
14373
|
-
if (miniflare) {
|
|
14374
|
-
|
|
14437
|
+
if (!miniflare) {
|
|
14438
|
+
miniflare = new Miniflare(
|
|
14375
14439
|
getDevMiniflareOptions(
|
|
14376
14440
|
resolvedPluginConfig,
|
|
14377
14441
|
viteDevServer,
|
|
@@ -14379,7 +14443,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14379
14443
|
)
|
|
14380
14444
|
);
|
|
14381
14445
|
} else {
|
|
14382
|
-
miniflare
|
|
14446
|
+
await miniflare.setOptions(
|
|
14383
14447
|
getDevMiniflareOptions(
|
|
14384
14448
|
resolvedPluginConfig,
|
|
14385
14449
|
viteDevServer,
|
|
@@ -14390,7 +14454,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14390
14454
|
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14391
14455
|
const middleware = createMiddleware(
|
|
14392
14456
|
async ({ request }) => {
|
|
14393
|
-
|
|
14457
|
+
assert10(miniflare, `Miniflare not defined`);
|
|
14394
14458
|
const routerWorker = await getRouterWorker(miniflare);
|
|
14395
14459
|
return routerWorker.fetch(toMiniflareRequest(request), {
|
|
14396
14460
|
redirect: "manual"
|
|
@@ -14399,7 +14463,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14399
14463
|
{ alwaysCallNext: false }
|
|
14400
14464
|
);
|
|
14401
14465
|
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
14402
|
-
|
|
14466
|
+
assert10(miniflare, `Miniflare not defined`);
|
|
14403
14467
|
const routerWorker = await getRouterWorker(miniflare);
|
|
14404
14468
|
return routerWorker.fetch;
|
|
14405
14469
|
});
|
|
@@ -14499,7 +14563,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14499
14563
|
for (const match of matches) {
|
|
14500
14564
|
magicString ??= new MagicString(code);
|
|
14501
14565
|
const [full, _, modulePath] = match;
|
|
14502
|
-
|
|
14566
|
+
assert10(
|
|
14503
14567
|
modulePath,
|
|
14504
14568
|
`Unexpected error: module path not found in reference ${full}.`
|
|
14505
14569
|
);
|
|
@@ -14545,6 +14609,18 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14545
14609
|
configEnvironment(name) {
|
|
14546
14610
|
if (isNodeCompat(getWorkerConfig2(name))) {
|
|
14547
14611
|
return {
|
|
14612
|
+
build: {
|
|
14613
|
+
rollupOptions: {
|
|
14614
|
+
plugins: [
|
|
14615
|
+
replace({
|
|
14616
|
+
"process.env.NODE_ENV": JSON.stringify(
|
|
14617
|
+
process.env.NODE_ENV ?? "production"
|
|
14618
|
+
),
|
|
14619
|
+
preventAssignment: true
|
|
14620
|
+
})
|
|
14621
|
+
]
|
|
14622
|
+
}
|
|
14623
|
+
},
|
|
14548
14624
|
resolve: {
|
|
14549
14625
|
builtins: [...nodeCompatExternals]
|
|
14550
14626
|
},
|
|
@@ -14572,7 +14648,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14572
14648
|
return this.resolve(source, importer, options);
|
|
14573
14649
|
}
|
|
14574
14650
|
if (this.environment.mode === "dev") {
|
|
14575
|
-
|
|
14651
|
+
assert10(
|
|
14576
14652
|
this.environment.depsOptimizer,
|
|
14577
14653
|
"depsOptimizer is required in dev mode"
|
|
14578
14654
|
);
|
|
@@ -14586,7 +14662,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14586
14662
|
},
|
|
14587
14663
|
async transform(code, id) {
|
|
14588
14664
|
const workerConfig = getWorkerConfig2(this.environment.name);
|
|
14589
|
-
|
|
14665
|
+
if (!workerConfig) {
|
|
14666
|
+
return;
|
|
14667
|
+
}
|
|
14590
14668
|
const resolvedId = await this.resolve(workerConfig.main);
|
|
14591
14669
|
if (id === resolvedId?.id) {
|
|
14592
14670
|
return injectGlobalCode(id, code);
|
|
@@ -14615,6 +14693,25 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14615
14693
|
);
|
|
14616
14694
|
}
|
|
14617
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
|
+
},
|
|
14618
14715
|
// Plugin that provides an __debug path for debugging the Cloudflare Workers.
|
|
14619
14716
|
{
|
|
14620
14717
|
name: "vite-plugin-cloudflare:debug",
|
|
@@ -14644,7 +14741,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14644
14741
|
addDebugToVitePrintUrls(vitePreviewServer);
|
|
14645
14742
|
}
|
|
14646
14743
|
const workerNames = workerConfigs.map((worker) => {
|
|
14647
|
-
|
|
14744
|
+
assert10(worker.name, "Expected the Worker to have a name");
|
|
14648
14745
|
return worker.name;
|
|
14649
14746
|
});
|
|
14650
14747
|
vitePreviewServer.middlewares.use(async (req, res, next) => {
|
|
@@ -14680,6 +14777,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14680
14777
|
build.onResolve(
|
|
14681
14778
|
{ filter: NODEJS_MODULES_RE },
|
|
14682
14779
|
({ path: path10, importer }) => {
|
|
14780
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(path10)) {
|
|
14781
|
+
return;
|
|
14782
|
+
}
|
|
14683
14783
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
14684
14784
|
nodeJsCompatWarnings?.registerImport(path10, importer);
|
|
14685
14785
|
return { path: path10, external: true };
|
|
@@ -14709,6 +14809,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14709
14809
|
async resolveId(source, importer) {
|
|
14710
14810
|
const workerConfig = getWorkerConfig2(this.environment.name);
|
|
14711
14811
|
if (workerConfig && !isNodeCompat(workerConfig)) {
|
|
14812
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(source)) {
|
|
14813
|
+
return;
|
|
14814
|
+
}
|
|
14712
14815
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
14713
14816
|
if (nodejsBuiltins.has(source)) {
|
|
14714
14817
|
nodeJsCompatWarnings?.registerImport(source, importer);
|
|
@@ -14722,11 +14825,17 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14722
14825
|
}
|
|
14723
14826
|
];
|
|
14724
14827
|
function getWorkerConfig2(environmentName) {
|
|
14725
|
-
|
|
14828
|
+
assert10(resolvedPluginConfig, "Expected resolvedPluginConfig to be defined");
|
|
14726
14829
|
return resolvedPluginConfig.type !== "assets-only" ? resolvedPluginConfig.workers[environmentName] : void 0;
|
|
14727
14830
|
}
|
|
14728
14831
|
}
|
|
14729
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
|
+
}
|
|
14730
14839
|
const inputInspectorPort = pluginConfig.inspectorPort ?? await getFirstAvailablePort(DEFAULT_INSPECTOR_PORT);
|
|
14731
14840
|
if (pluginConfig.inspectorPort === void 0 && inputInspectorPort !== DEFAULT_INSPECTOR_PORT) {
|
|
14732
14841
|
viteServer.config.logger.warn(
|
|
@@ -14756,6 +14865,19 @@ function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
|
14756
14865
|
}
|
|
14757
14866
|
return null;
|
|
14758
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
|
+
}
|
|
14759
14881
|
export {
|
|
14760
14882
|
cloudflare2 as cloudflare
|
|
14761
14883
|
};
|
|
@@ -1394,13 +1394,6 @@ async function createModuleRunner(env, webSocket, viteRoot) {
|
|
|
1394
1394
|
},
|
|
1395
1395
|
{
|
|
1396
1396
|
async runInlinedModule(context, transformed, module) {
|
|
1397
|
-
if (module.file.includes("/node_modules") && !module.file.includes("/node_modules/.vite")) {
|
|
1398
|
-
throw new Error(
|
|
1399
|
-
`[Error] Trying to import non-prebundled module (only prebundled modules are allowed): ${module.id}
|
|
1400
|
-
|
|
1401
|
-
(have you excluded the module via \`optimizeDeps.exclude\`?)`
|
|
1402
|
-
);
|
|
1403
|
-
}
|
|
1404
1397
|
const codeDefinition = `'use strict';async (${Object.keys(context).join(
|
|
1405
1398
|
","
|
|
1406
1399
|
)})=>{{`;
|
|
@@ -1426,13 +1419,6 @@ async function createModuleRunner(env, webSocket, viteRoot) {
|
|
|
1426
1419
|
)
|
|
1427
1420
|
});
|
|
1428
1421
|
}
|
|
1429
|
-
if (!additionalModuleRE.test(filepath) && filepath.includes("/node_modules") && !filepath.includes("/node_modules/.vite")) {
|
|
1430
|
-
throw new Error(
|
|
1431
|
-
`[Error] Trying to import non-prebundled module (only prebundled modules are allowed): ${filepath}
|
|
1432
|
-
|
|
1433
|
-
(have you externalized the module via \`resolve.external\`?)`
|
|
1434
|
-
);
|
|
1435
|
-
}
|
|
1436
1422
|
filepath = filepath.replace(/^file:\/\//, "");
|
|
1437
1423
|
return import(filepath);
|
|
1438
1424
|
}
|
|
@@ -1449,20 +1435,21 @@ async function getWorkerEntryExport(path, entrypoint) {
|
|
|
1449
1435
|
}
|
|
1450
1436
|
|
|
1451
1437
|
// src/runner-worker/index.ts
|
|
1438
|
+
var IGNORED_KEYS = ["self", "tailStream"];
|
|
1452
1439
|
var WORKER_ENTRYPOINT_KEYS = [
|
|
1453
1440
|
"fetch",
|
|
1441
|
+
"queue",
|
|
1454
1442
|
"tail",
|
|
1443
|
+
"test",
|
|
1455
1444
|
"trace",
|
|
1456
|
-
"scheduled"
|
|
1457
|
-
"queue",
|
|
1458
|
-
"test"
|
|
1445
|
+
"scheduled"
|
|
1459
1446
|
];
|
|
1460
1447
|
var DURABLE_OBJECT_KEYS = [
|
|
1461
|
-
"fetch",
|
|
1462
1448
|
"alarm",
|
|
1463
|
-
"
|
|
1449
|
+
"fetch",
|
|
1464
1450
|
"webSocketClose",
|
|
1465
|
-
"webSocketError"
|
|
1451
|
+
"webSocketError",
|
|
1452
|
+
"webSocketMessage"
|
|
1466
1453
|
];
|
|
1467
1454
|
var WORKFLOW_ENTRYPOINT_KEYS = ["run"];
|
|
1468
1455
|
var entryPath = "";
|
|
@@ -1527,7 +1514,7 @@ function createWorkerEntrypointWrapper(entrypoint) {
|
|
|
1527
1514
|
if (value !== void 0) {
|
|
1528
1515
|
return value;
|
|
1529
1516
|
}
|
|
1530
|
-
if (key === "
|
|
1517
|
+
if (typeof key === "symbol" || IGNORED_KEYS.includes(key) || DURABLE_OBJECT_KEYS.includes(key)) {
|
|
1531
1518
|
return;
|
|
1532
1519
|
}
|
|
1533
1520
|
const property = getWorkerEntrypointRpcProperty.call(
|
|
@@ -1625,7 +1612,7 @@ function createDurableObjectWrapper(className) {
|
|
|
1625
1612
|
if (value !== void 0) {
|
|
1626
1613
|
return value;
|
|
1627
1614
|
}
|
|
1628
|
-
if (key === "
|
|
1615
|
+
if (typeof key === "symbol" || IGNORED_KEYS.includes(key) || WORKER_ENTRYPOINT_KEYS.includes(key)) {
|
|
1629
1616
|
return;
|
|
1630
1617
|
}
|
|
1631
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-3b60131ca",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hattip/adapter-node": "^0.0.49",
|
|
37
|
+
"@rollup/plugin-replace": "^6.0.1",
|
|
37
38
|
"get-port": "^7.1.0",
|
|
38
39
|
"picocolors": "^1.1.1",
|
|
39
40
|
"tinyglobby": "^0.2.12",
|
|
40
41
|
"unenv": "2.0.0-rc.15",
|
|
41
42
|
"ws": "8.18.0",
|
|
42
|
-
"@cloudflare/unenv-preset": "0.0.0-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"@cloudflare/unenv-preset": "0.0.0-3b60131ca",
|
|
44
|
+
"wrangler": "0.0.0-3b60131ca",
|
|
45
|
+
"miniflare": "0.0.0-3b60131ca"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250424.0",
|
|
48
49
|
"@types/node": "^22.10.1",
|
|
49
50
|
"@types/ws": "^8.5.13",
|
|
50
51
|
"magic-string": "^0.30.12",
|
|
@@ -53,9 +54,9 @@
|
|
|
53
54
|
"typescript": "^5.7.2",
|
|
54
55
|
"undici": "^5.28.5",
|
|
55
56
|
"vite": "^6.1.0",
|
|
56
|
-
"vitest": "~3.
|
|
57
|
-
"@cloudflare/workers-shared": "0.0.0-39933740e",
|
|
57
|
+
"vitest": "~3.1.1",
|
|
58
58
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
59
|
+
"@cloudflare/workers-shared": "0.0.0-3b60131ca",
|
|
59
60
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|