@cloudflare/vite-plugin 0.0.0-ff0d9cd27 → 0.0.2
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 +0 -7
- package/dist/asset-workers/asset-worker.js +545 -550
- package/dist/asset-workers/router-worker.js +237 -249
- package/dist/index.js +18 -52
- package/dist/runner-worker/index.js +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1637,13 +1637,10 @@ 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
|
-
|
|
1644
|
-
},
|
|
1645
|
-
resolvedPluginConfig.cloudflareEnv
|
|
1646
|
-
);
|
|
1640
|
+
const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions({
|
|
1641
|
+
...workerConfig,
|
|
1642
|
+
assets: void 0
|
|
1643
|
+
});
|
|
1647
1644
|
const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
|
|
1648
1645
|
return {
|
|
1649
1646
|
...workerOptions,
|
|
@@ -2067,21 +2064,20 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2067
2064
|
const configPaths = /* @__PURE__ */ new Set();
|
|
2068
2065
|
const persistState = pluginConfig.persistState ?? true;
|
|
2069
2066
|
const root = userConfig.root ? path5.resolve(userConfig.root) : process.cwd();
|
|
2070
|
-
const { CLOUDFLARE_ENV
|
|
2071
|
-
viteEnv.mode,
|
|
2072
|
-
root,
|
|
2073
|
-
/* prefixes */
|
|
2074
|
-
""
|
|
2075
|
-
);
|
|
2067
|
+
const { CLOUDFLARE_ENV } = vite5.loadEnv(viteEnv.mode, root, "");
|
|
2076
2068
|
const configPath = pluginConfig.configPath ? path5.resolve(root, pluginConfig.configPath) : findWranglerConfig(root);
|
|
2077
2069
|
assert6(
|
|
2078
2070
|
configPath,
|
|
2079
2071
|
`Config not found. Have you created a wrangler.json(c) or wrangler.toml file?`
|
|
2080
2072
|
);
|
|
2081
|
-
const entryWorkerResolvedConfig = getWorkerConfig(
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2073
|
+
const entryWorkerResolvedConfig = getWorkerConfig(
|
|
2074
|
+
configPath,
|
|
2075
|
+
CLOUDFLARE_ENV,
|
|
2076
|
+
{
|
|
2077
|
+
visitedConfigPaths: configPaths,
|
|
2078
|
+
isEntryWorker: true
|
|
2079
|
+
}
|
|
2080
|
+
);
|
|
2085
2081
|
if (entryWorkerResolvedConfig.type === "assets-only") {
|
|
2086
2082
|
return {
|
|
2087
2083
|
type: "assets-only",
|
|
@@ -2090,8 +2086,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2090
2086
|
persistState,
|
|
2091
2087
|
rawConfigs: {
|
|
2092
2088
|
entryWorker: entryWorkerResolvedConfig
|
|
2093
|
-
}
|
|
2094
|
-
cloudflareEnv
|
|
2089
|
+
}
|
|
2095
2090
|
};
|
|
2096
2091
|
}
|
|
2097
2092
|
const entryWorkerConfig = entryWorkerResolvedConfig.config;
|
|
@@ -2103,7 +2098,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2103
2098
|
for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
|
|
2104
2099
|
const workerResolvedConfig = getWorkerConfig(
|
|
2105
2100
|
path5.resolve(root, auxiliaryWorker.configPath),
|
|
2106
|
-
|
|
2101
|
+
CLOUDFLARE_ENV,
|
|
2107
2102
|
{
|
|
2108
2103
|
visitedConfigPaths: configPaths
|
|
2109
2104
|
}
|
|
@@ -2131,8 +2126,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
2131
2126
|
rawConfigs: {
|
|
2132
2127
|
entryWorker: entryWorkerResolvedConfig,
|
|
2133
2128
|
auxiliaryWorkers: auxiliaryWorkersResolvedConfigs
|
|
2134
|
-
}
|
|
2135
|
-
cloudflareEnv
|
|
2129
|
+
}
|
|
2136
2130
|
};
|
|
2137
2131
|
}
|
|
2138
2132
|
|
|
@@ -2323,28 +2317,13 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2323
2317
|
);
|
|
2324
2318
|
}
|
|
2325
2319
|
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
|
-
}
|
|
2339
2320
|
} else if (this.environment.name === "client") {
|
|
2340
2321
|
const assetsOnlyConfig = resolvedPluginConfig.config;
|
|
2341
2322
|
assetsOnlyConfig.assets.directory = ".";
|
|
2342
|
-
const filesToAssetsIgnore = ["wrangler.json", ".dev.vars"];
|
|
2343
2323
|
this.emitFile({
|
|
2344
2324
|
type: "asset",
|
|
2345
2325
|
fileName: ".assetsignore",
|
|
2346
|
-
source:
|
|
2347
|
-
`
|
|
2326
|
+
source: "wrangler.json"
|
|
2348
2327
|
});
|
|
2349
2328
|
config = assetsOnlyConfig;
|
|
2350
2329
|
}
|
|
@@ -2353,9 +2332,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2353
2332
|
}
|
|
2354
2333
|
config.no_bundle = true;
|
|
2355
2334
|
config.rules = [{ type: "ESModule", globs: ["**/*.js"] }];
|
|
2356
|
-
|
|
2357
|
-
config.unsafe = void 0;
|
|
2358
|
-
}
|
|
2335
|
+
config.unsafe = void 0;
|
|
2359
2336
|
this.emitFile({
|
|
2360
2337
|
type: "asset",
|
|
2361
2338
|
fileName: "wrangler.json",
|
|
@@ -2424,17 +2401,6 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
2424
2401
|
}
|
|
2425
2402
|
};
|
|
2426
2403
|
}
|
|
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
|
-
}
|
|
2438
2404
|
export {
|
|
2439
2405
|
cloudflare2 as cloudflare
|
|
2440
2406
|
};
|
|
@@ -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.59_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.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -36,19 +36,19 @@
|
|
|
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": "
|
|
39
|
+
"miniflare": "3.20241230.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@cloudflare/workers-types": "^4.
|
|
42
|
+
"@cloudflare/workers-types": "^4.20241230.0",
|
|
43
43
|
"@types/node": "^22.10.1",
|
|
44
44
|
"@types/ws": "^8.5.13",
|
|
45
45
|
"magic-string": "^0.30.12",
|
|
46
46
|
"tsup": "8.3.0",
|
|
47
47
|
"typescript": "^5.7.2",
|
|
48
48
|
"vite": "^6.0.7",
|
|
49
|
+
"@cloudflare/workers-shared": "0.12.3",
|
|
49
50
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
50
|
-
"wrangler": "
|
|
51
|
-
"@cloudflare/workers-shared": "0.0.0-ff0d9cd27"
|
|
51
|
+
"wrangler": "3.105.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"vite": "^6.0.7",
|