@cloudflare/vite-plugin 0.1.1 → 0.1.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/dist/asset-workers/asset-worker.js +1234 -1655
- package/dist/asset-workers/router-worker.js +1182 -1566
- package/dist/index.js +17 -14
- package/dist/runner-worker/index.js +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1074,7 +1074,6 @@ import * as vite6 from "vite";
|
|
|
1074
1074
|
|
|
1075
1075
|
// src/cloudflare-environment.ts
|
|
1076
1076
|
import assert from "node:assert";
|
|
1077
|
-
import { builtinModules } from "node:module";
|
|
1078
1077
|
import * as vite2 from "vite";
|
|
1079
1078
|
|
|
1080
1079
|
// src/constants.ts
|
|
@@ -1089,9 +1088,13 @@ var INIT_PATH = "/__vite_plugin_cloudflare_init__";
|
|
|
1089
1088
|
var MODULE_PATTERN = `__CLOUDFLARE_MODULE__(${MODULE_TYPES.join("|")})__(.*?)__`;
|
|
1090
1089
|
|
|
1091
1090
|
// src/utils.ts
|
|
1091
|
+
import { builtinModules } from "node:module";
|
|
1092
1092
|
import * as path from "node:path";
|
|
1093
1093
|
import { Request as MiniflareRequest } from "miniflare";
|
|
1094
1094
|
import "vite";
|
|
1095
|
+
var nodeBuiltInModules = new Set(
|
|
1096
|
+
builtinModules.concat(builtinModules.map((m) => `node:${m}`))
|
|
1097
|
+
);
|
|
1095
1098
|
function getOutputDirectory(userConfig, environmentName) {
|
|
1096
1099
|
const rootOutputDirectory = userConfig.build?.outDir ?? "dist";
|
|
1097
1100
|
return userConfig.environments?.[environmentName]?.build?.outDir ?? path.join(rootOutputDirectory, environmentName);
|
|
@@ -1207,7 +1210,11 @@ function createCloudflareEnvironmentOptions(workerConfig, userConfig, environmen
|
|
|
1207
1210
|
// dependencies as not external
|
|
1208
1211
|
noExternal: true,
|
|
1209
1212
|
// We want to use `workerd` package exports if available (e.g. for postgres).
|
|
1210
|
-
conditions: [...defaultConditions, "development|production"]
|
|
1213
|
+
conditions: [...defaultConditions, "development|production"],
|
|
1214
|
+
// The Cloudflare ones are proper builtins in the environment
|
|
1215
|
+
builtins: [...cloudflareBuiltInModules],
|
|
1216
|
+
// The Node.js ones are no proper builtins in the environment since we also polyfill them using unenv
|
|
1217
|
+
external: [...nodeBuiltInModules]
|
|
1211
1218
|
},
|
|
1212
1219
|
dev: {
|
|
1213
1220
|
createEnvironment(name2, config) {
|
|
@@ -1229,8 +1236,7 @@ function createCloudflareEnvironmentOptions(workerConfig, userConfig, environmen
|
|
|
1229
1236
|
// so the input value here serves both as the build input as well as the starting point for
|
|
1230
1237
|
// dev pre-bundling crawling (were we not to set this input field we'd have to appropriately set
|
|
1231
1238
|
// optimizeDeps.entries in the dev config)
|
|
1232
|
-
input: workerConfig.main
|
|
1233
|
-
external: [...cloudflareBuiltInModules]
|
|
1239
|
+
input: workerConfig.main
|
|
1234
1240
|
}
|
|
1235
1241
|
},
|
|
1236
1242
|
optimizeDeps: {
|
|
@@ -1238,9 +1244,8 @@ function createCloudflareEnvironmentOptions(workerConfig, userConfig, environmen
|
|
|
1238
1244
|
noDiscovery: false,
|
|
1239
1245
|
entries: workerConfig.main,
|
|
1240
1246
|
exclude: [
|
|
1241
|
-
...cloudflareBuiltInModules,
|
|
1242
1247
|
// we have to exclude all node modules to work in dev-mode not just the unenv externals...
|
|
1243
|
-
...
|
|
1248
|
+
...nodeBuiltInModules
|
|
1244
1249
|
],
|
|
1245
1250
|
esbuildOptions: {
|
|
1246
1251
|
platform: "neutral",
|
|
@@ -1585,20 +1590,18 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
|
|
|
1585
1590
|
);
|
|
1586
1591
|
const [moduleId] = invokePayloadData.data;
|
|
1587
1592
|
const moduleRE = new RegExp(MODULE_PATTERN);
|
|
1588
|
-
|
|
1593
|
+
const shouldExternalize = (
|
|
1594
|
+
// Worker modules (CompiledWasm, Text, Data)
|
|
1595
|
+
moduleRE.test(moduleId) || // Node.js builtin node modules (they will be resolved to unenv aliases)
|
|
1596
|
+
nodeBuiltInModules.has(moduleId)
|
|
1597
|
+
);
|
|
1598
|
+
if (shouldExternalize) {
|
|
1589
1599
|
const result2 = {
|
|
1590
1600
|
externalize: moduleId,
|
|
1591
1601
|
type: "module"
|
|
1592
1602
|
};
|
|
1593
1603
|
return MiniflareResponse.json({ result: result2 });
|
|
1594
1604
|
}
|
|
1595
|
-
if (moduleId.startsWith("cloudflare:")) {
|
|
1596
|
-
const result2 = {
|
|
1597
|
-
externalize: moduleId,
|
|
1598
|
-
type: "builtin"
|
|
1599
|
-
};
|
|
1600
|
-
return MiniflareResponse.json({ result: result2 });
|
|
1601
|
-
}
|
|
1602
1605
|
const devEnvironment = viteDevServer.environments[environmentName];
|
|
1603
1606
|
const result = await devEnvironment.hot.handleInvoke(payload);
|
|
1604
1607
|
return MiniflareResponse.json(result);
|
|
@@ -25,7 +25,7 @@ function stripInternalEnv(internalEnv) {
|
|
|
25
25
|
return userEnv;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// ../../node_modules/.pnpm/vite@6.1.0_@types+node@18.19.
|
|
28
|
+
// ../../node_modules/.pnpm/vite@6.1.0_@types+node@18.19.76_jiti@2.4.2/node_modules/vite/dist/node/module-runner.js
|
|
29
29
|
var VALID_ID_PREFIX = "/@id/";
|
|
30
30
|
var NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
31
31
|
var SOURCEMAPPING_URL = "sourceMa";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"@hattip/adapter-node": "^0.0.49",
|
|
38
38
|
"unenv": "2.0.0-rc.1",
|
|
39
39
|
"ws": "^8.18.0",
|
|
40
|
-
"miniflare": "3.
|
|
40
|
+
"miniflare": "3.20250214.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@cloudflare/workers-types": "^4.
|
|
43
|
+
"@cloudflare/workers-types": "^4.20250214.0",
|
|
44
44
|
"@types/node": "^22.10.1",
|
|
45
45
|
"@types/ws": "^8.5.13",
|
|
46
46
|
"magic-string": "^0.30.12",
|
|
47
47
|
"mlly": "^1.7.4",
|
|
48
48
|
"tsup": "8.3.0",
|
|
49
49
|
"typescript": "^5.7.2",
|
|
50
|
-
"undici": "^5.28.
|
|
50
|
+
"undici": "^5.28.5",
|
|
51
51
|
"vite": "^6.1.0",
|
|
52
|
-
"vitest": "~
|
|
53
|
-
"@cloudflare/workers-shared": "0.14.1",
|
|
52
|
+
"vitest": "~3.0.5",
|
|
54
53
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
54
|
+
"@cloudflare/workers-shared": "0.14.3",
|
|
55
55
|
"@cloudflare/workers-tsconfig": "0.0.0",
|
|
56
|
-
"wrangler": "3.109.
|
|
56
|
+
"wrangler": "3.109.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"vite": "^6.1.0",
|