@cloudflare/vite-plugin 0.0.0-dc31c365d → 0.0.0-dcce2ecf2
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/index.js +41 -15
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -490,6 +490,7 @@ 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);
|
|
@@ -5831,14 +5832,14 @@ var AssetConfigSchema = z.object({
|
|
|
5831
5832
|
});
|
|
5832
5833
|
|
|
5833
5834
|
// src/asset-config.ts
|
|
5834
|
-
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig,
|
|
5835
|
+
function hasAssetsConfigChanged(resolvedPluginConfig, resolvedViteConfig, changedFilePath) {
|
|
5835
5836
|
if (!resolvedPluginConfig.experimental?.headersAndRedirectsDevModeSupport) {
|
|
5836
5837
|
return false;
|
|
5837
5838
|
}
|
|
5838
5839
|
return [
|
|
5839
5840
|
getRedirectsConfigPath(resolvedViteConfig),
|
|
5840
5841
|
getHeadersConfigPath(resolvedViteConfig)
|
|
5841
|
-
].includes(
|
|
5842
|
+
].includes(changedFilePath);
|
|
5842
5843
|
}
|
|
5843
5844
|
function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig) {
|
|
5844
5845
|
const assetsConfig = resolvedPluginConfig.type === "assets-only" ? resolvedPluginConfig.config.assets : entryWorkerConfig?.assets;
|
|
@@ -12909,7 +12910,7 @@ globalThis.${globalName} = var_${globalName}.${exportName};
|
|
|
12909
12910
|
}
|
|
12910
12911
|
function resolveNodeJSImport(source) {
|
|
12911
12912
|
const alias = env.alias[source];
|
|
12912
|
-
if (alias) {
|
|
12913
|
+
if (alias && !nodeCompatExternals.has(alias)) {
|
|
12913
12914
|
return {
|
|
12914
12915
|
unresolved: alias,
|
|
12915
12916
|
resolved: resolvePathSync(alias, { url: import.meta.url })
|
|
@@ -14180,7 +14181,7 @@ function validateWorkerEnvironmentsResolvedConfigs(resolvedPluginConfig, resolve
|
|
|
14180
14181
|
for (const envName of workersEnvironmentNames) {
|
|
14181
14182
|
const workerEnvConfig = resolvedViteConfig.environments[envName];
|
|
14182
14183
|
assert9(workerEnvConfig, `Missing environment config for "${envName}"`);
|
|
14183
|
-
const { optimizeDeps, resolve:
|
|
14184
|
+
const { optimizeDeps, resolve: resolve7 } = workerEnvConfig;
|
|
14184
14185
|
const disallowedConfig = {};
|
|
14185
14186
|
const disallowedOptimizeDepsExcludeEntries = (optimizeDeps.exclude ?? []).filter((entry) => {
|
|
14186
14187
|
if (cloudflareBuiltInModules.includes(entry)) {
|
|
@@ -14194,8 +14195,8 @@ function validateWorkerEnvironmentsResolvedConfigs(resolvedPluginConfig, resolve
|
|
|
14194
14195
|
if (disallowedOptimizeDepsExcludeEntries.length > 0) {
|
|
14195
14196
|
disallowedConfig.optimizeDepsExclude = disallowedOptimizeDepsExcludeEntries;
|
|
14196
14197
|
}
|
|
14197
|
-
if (
|
|
14198
|
-
disallowedConfig.resolveExternal =
|
|
14198
|
+
if (resolve7.external === true || resolve7.external.length > 0) {
|
|
14199
|
+
disallowedConfig.resolveExternal = resolve7.external;
|
|
14199
14200
|
}
|
|
14200
14201
|
if (Object.keys(disallowedConfig).length > 0) {
|
|
14201
14202
|
disallowedEnvsConfigs.set(envName, disallowedConfig);
|
|
@@ -14401,14 +14402,12 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14401
14402
|
}
|
|
14402
14403
|
},
|
|
14403
14404
|
hotUpdate(options) {
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
resolvedPluginConfig
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
)
|
|
14411
|
-
) {
|
|
14405
|
+
const changedFilePath = path9.resolve(options.file);
|
|
14406
|
+
if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
|
|
14407
|
+
resolvedPluginConfig,
|
|
14408
|
+
resolvedViteConfig,
|
|
14409
|
+
changedFilePath
|
|
14410
|
+
)) {
|
|
14412
14411
|
options.server.restart();
|
|
14413
14412
|
return [];
|
|
14414
14413
|
}
|
|
@@ -14598,6 +14597,18 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14598
14597
|
configEnvironment(name) {
|
|
14599
14598
|
if (isNodeCompat(getWorkerConfig2(name))) {
|
|
14600
14599
|
return {
|
|
14600
|
+
build: {
|
|
14601
|
+
rollupOptions: {
|
|
14602
|
+
plugins: [
|
|
14603
|
+
replace({
|
|
14604
|
+
"process.env.NODE_ENV": JSON.stringify(
|
|
14605
|
+
process.env.NODE_ENV ?? "production"
|
|
14606
|
+
),
|
|
14607
|
+
preventAssignment: true
|
|
14608
|
+
})
|
|
14609
|
+
]
|
|
14610
|
+
}
|
|
14611
|
+
},
|
|
14601
14612
|
resolve: {
|
|
14602
14613
|
builtins: [...nodeCompatExternals]
|
|
14603
14614
|
},
|
|
@@ -14639,7 +14650,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14639
14650
|
},
|
|
14640
14651
|
async transform(code, id) {
|
|
14641
14652
|
const workerConfig = getWorkerConfig2(this.environment.name);
|
|
14642
|
-
|
|
14653
|
+
if (!workerConfig) {
|
|
14654
|
+
return;
|
|
14655
|
+
}
|
|
14643
14656
|
const resolvedId = await this.resolve(workerConfig.main);
|
|
14644
14657
|
if (id === resolvedId?.id) {
|
|
14645
14658
|
return injectGlobalCode(id, code);
|
|
@@ -14809,6 +14822,19 @@ function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
|
14809
14822
|
}
|
|
14810
14823
|
return null;
|
|
14811
14824
|
}
|
|
14825
|
+
function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
14826
|
+
return [...resolvedPluginConfig.configPaths].some((configPath) => {
|
|
14827
|
+
const dotDevDotVars = path9.join(path9.dirname(configPath), ".dev.vars");
|
|
14828
|
+
if (dotDevDotVars === changedFilePath) {
|
|
14829
|
+
return true;
|
|
14830
|
+
}
|
|
14831
|
+
if (resolvedPluginConfig.cloudflareEnv) {
|
|
14832
|
+
const dotDevDotVarsForEnv = `${dotDevDotVars}.${resolvedPluginConfig.cloudflareEnv}`;
|
|
14833
|
+
return dotDevDotVarsForEnv === changedFilePath;
|
|
14834
|
+
}
|
|
14835
|
+
return false;
|
|
14836
|
+
});
|
|
14837
|
+
}
|
|
14812
14838
|
export {
|
|
14813
14839
|
cloudflare2 as cloudflare
|
|
14814
14840
|
};
|
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-dcce2ecf2",
|
|
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
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"miniflare": "0.0.0-
|
|
43
|
+
"@cloudflare/unenv-preset": "0.0.0-dcce2ecf2",
|
|
44
|
+
"wrangler": "0.0.0-dcce2ecf2",
|
|
45
|
+
"miniflare": "0.0.0-dcce2ecf2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250409.0",
|
|
48
49
|
"@types/node": "^22.10.1",
|
|
49
50
|
"@types/ws": "^8.5.13",
|
|
50
51
|
"magic-string": "^0.30.12",
|
|
@@ -54,9 +55,9 @@
|
|
|
54
55
|
"undici": "^5.28.5",
|
|
55
56
|
"vite": "^6.1.0",
|
|
56
57
|
"vitest": "~3.0.8",
|
|
57
|
-
"@cloudflare/workers-shared": "0.0.0-
|
|
58
|
-
"@cloudflare/
|
|
59
|
-
"@cloudflare/
|
|
58
|
+
"@cloudflare/workers-shared": "0.0.0-dcce2ecf2",
|
|
59
|
+
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
60
|
+
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"vite": "^6.1.0",
|