@cloudflare/vite-plugin 0.0.0-bdc7958f2 → 0.0.0-c412a3198
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 +7 -0
- package/dist/asset-workers/asset-worker.js +558 -549
- package/dist/asset-workers/router-worker.js +249 -237
- package/dist/index.js +52 -18
- package/dist/runner-worker/index.js +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1637,10 +1637,13 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
|
|
|
1637
1637
|
];
|
|
1638
1638
|
const userWorkers = resolvedPluginConfig.type === "workers" ? Object.entries(resolvedPluginConfig.workers).map(
|
|
1639
1639
|
([environmentName, workerConfig]) => {
|
|
1640
|
-
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1640
|
+
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
|
|
1641
|
+
{
|
|
1642
|
+
...workerConfig,
|
|
1643
|
+
assets: void 0
|
|
1644
|
+
},
|
|
1645
|
+
resolvedPluginConfig.cloudflareEnv
|
|
1646
|
+
);
|
|
1644
1647
|
const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
1645
1648
|
return {
|
|
1646
1649
|
...workerOptions,
|
|
@@ -2064,20 +2067,21 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2064
2067
|
const configPaths = /* @__PURE__ */ new Set();
|
|
2065
2068
|
const persistState = pluginConfig.persistState ?? true;
|
|
2066
2069
|
const root = userConfig.root ? path5.resolve(userConfig.root) : process.cwd();
|
|
2067
|
-
const { CLOUDFLARE_ENV } = vite5.loadEnv(
|
|
2070
|
+
const { CLOUDFLARE_ENV: cloudflareEnv } = vite5.loadEnv(
|
|
2071
|
+
viteEnv.mode,
|
|
2072
|
+
root,
|
|
2073
|
+
/* prefixes */
|
|
2074
|
+
""
|
|
2075
|
+
);
|
|
2068
2076
|
const configPath = pluginConfig.configPath ? path5.resolve(root, pluginConfig.configPath) : findWranglerConfig(root);
|
|
2069
2077
|
assert6(
|
|
2070
2078
|
configPath,
|
|
2071
2079
|
`Config not found. Have you created a wrangler.json(c) or wrangler.toml file?`
|
|
2072
2080
|
);
|
|
2073
|
-
const entryWorkerResolvedConfig = getWorkerConfig(
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
visitedConfigPaths: configPaths,
|
|
2078
|
-
isEntryWorker: true
|
|
2079
|
-
}
|
|
2080
|
-
);
|
|
2081
|
+
const entryWorkerResolvedConfig = getWorkerConfig(configPath, cloudflareEnv, {
|
|
2082
|
+
visitedConfigPaths: configPaths,
|
|
2083
|
+
isEntryWorker: true
|
|
2084
|
+
});
|
|
2081
2085
|
if (entryWorkerResolvedConfig.type === "assets-only") {
|
|
2082
2086
|
return {
|
|
2083
2087
|
type: "assets-only",
|
|
@@ -2086,7 +2090,8 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2086
2090
|
persistState,
|
|
2087
2091
|
rawConfigs: {
|
|
2088
2092
|
entryWorker: entryWorkerResolvedConfig
|
|
2089
|
-
}
|
|
2093
|
+
},
|
|
2094
|
+
cloudflareEnv
|
|
2090
2095
|
};
|
|
2091
2096
|
}
|
|
2092
2097
|
const entryWorkerConfig = entryWorkerResolvedConfig.config;
|
|
@@ -2098,7 +2103,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2098
2103
|
for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
|
|
2099
2104
|
const workerResolvedConfig = getWorkerConfig(
|
|
2100
2105
|
path5.resolve(root, auxiliaryWorker.configPath),
|
|
2101
|
-
|
|
2106
|
+
cloudflareEnv,
|
|
2102
2107
|
{
|
|
2103
2108
|
visitedConfigPaths: configPaths
|
|
2104
2109
|
}
|
|
@@ -2126,7 +2131,8 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2126
2131
|
rawConfigs: {
|
|
2127
2132
|
entryWorker: entryWorkerResolvedConfig,
|
|
2128
2133
|
auxiliaryWorkers: auxiliaryWorkersResolvedConfigs
|
|
2129
|
-
}
|
|
2134
|
+
},
|
|
2135
|
+
cloudflareEnv
|
|
2130
2136
|
};
|
|
2131
2137
|
}
|
|
2132
2138
|
|
|
@@ -2317,13 +2323,28 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2317
2323
|
);
|
|
2318
2324
|
}
|
|
2319
2325
|
config = workerConfig;
|
|
2326
|
+
if (workerConfig.configPath) {
|
|
2327
|
+
const dotDevDotVarsContent = getDotDevDotVarsContent(
|
|
2328
|
+
workerConfig.configPath,
|
|
2329
|
+
resolvedPluginConfig.cloudflareEnv
|
|
2330
|
+
);
|
|
2331
|
+
if (dotDevDotVarsContent) {
|
|
2332
|
+
this.emitFile({
|
|
2333
|
+
type: "asset",
|
|
2334
|
+
fileName: ".dev.vars",
|
|
2335
|
+
source: dotDevDotVarsContent
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2320
2339
|
} else if (this.environment.name === "client") {
|
|
2321
2340
|
const assetsOnlyConfig = resolvedPluginConfig.config;
|
|
2322
2341
|
assetsOnlyConfig.assets.directory = ".";
|
|
2342
|
+
const filesToAssetsIgnore = ["wrangler.json", ".dev.vars"];
|
|
2323
2343
|
this.emitFile({
|
|
2324
2344
|
type: "asset",
|
|
2325
2345
|
fileName: ".assetsignore",
|
|
2326
|
-
source:
|
|
2346
|
+
source: `${filesToAssetsIgnore.join("\n")}
|
|
2347
|
+
`
|
|
2327
2348
|
});
|
|
2328
2349
|
config = assetsOnlyConfig;
|
|
2329
2350
|
}
|
|
@@ -2332,7 +2353,9 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2332
2353
|
}
|
|
2333
2354
|
config.no_bundle = true;
|
|
2334
2355
|
config.rules = [{ type: "ESModule", globs: ["**/*.js"] }];
|
|
2335
|
-
config.unsafe
|
|
2356
|
+
if (config.unsafe && Object.keys(config.unsafe).length === 0) {
|
|
2357
|
+
config.unsafe = void 0;
|
|
2358
|
+
}
|
|
2336
2359
|
this.emitFile({
|
|
2337
2360
|
type: "asset",
|
|
2338
2361
|
fileName: "wrangler.json",
|
|
@@ -2401,6 +2424,17 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2401
2424
|
}
|
|
2402
2425
|
};
|
|
2403
2426
|
}
|
|
2427
|
+
function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
2428
|
+
const configDir = path6.dirname(configPath);
|
|
2429
|
+
const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
|
|
2430
|
+
const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
|
|
2431
|
+
const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
|
|
2432
|
+
if (targetPath) {
|
|
2433
|
+
const dotDevDotVarsContent = fs4.readFileSync(targetPath);
|
|
2434
|
+
return dotDevDotVarsContent;
|
|
2435
|
+
}
|
|
2436
|
+
return null;
|
|
2437
|
+
}
|
|
2404
2438
|
export {
|
|
2405
2439
|
cloudflare2 as cloudflare
|
|
2406
2440
|
};
|
|
@@ -21,7 +21,7 @@ function stripInternalEnv(internalEnv) {
|
|
|
21
21
|
return userEnv;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// ../../node_modules/.pnpm/vite@6.0.7_@types+node@18.19.
|
|
24
|
+
// ../../node_modules/.pnpm/vite@6.0.7_@types+node@18.19.74_jiti@2.4.2/node_modules/vite/dist/node/module-runner.js
|
|
25
25
|
var VALID_ID_PREFIX = "/@id/";
|
|
26
26
|
var NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
27
27
|
var SOURCEMAPPING_URL = "sourceMa";
|
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-c412a3198",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@hattip/adapter-node": "^0.0.49",
|
|
37
37
|
"unenv": "npm:unenv-nightly@2.0.0-20241218-183400-5d6aec3",
|
|
38
38
|
"ws": "^8.18.0",
|
|
39
|
-
"miniflare": "0.0.0-
|
|
39
|
+
"miniflare": "0.0.0-c412a3198"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@cloudflare/workers-types": "^4.
|
|
42
|
+
"@cloudflare/workers-types": "^4.20250129.0",
|
|
43
43
|
"@types/node": "^22.10.1",
|
|
44
44
|
"@types/ws": "^8.5.13",
|
|
45
45
|
"magic-string": "^0.30.12",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"typescript": "^5.7.2",
|
|
48
48
|
"vite": "^6.0.7",
|
|
49
49
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
50
|
-
"wrangler": "0.0.0-
|
|
51
|
-
"@cloudflare/workers-shared": "0.0.0-
|
|
50
|
+
"wrangler": "0.0.0-c412a3198",
|
|
51
|
+
"@cloudflare/workers-shared": "0.0.0-c412a3198"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"vite": "^6.0.7",
|