Skip to content

Commit 336cc48

Browse files
authored
Bundle & pin Wrangler dependencies (#7737)
* bundle chokidar * Harden up more deps * Add path-to-regexp
1 parent 8e9aa40 commit 336cc48

File tree

4 files changed

+64
-52
lines changed

4 files changed

+64
-52
lines changed

packages/wrangler/package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,18 @@
6969
"type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
7070
},
7171
"dependencies": {
72-
"@aws-sdk/client-s3": "^3.721.0",
7372
"@cloudflare/kv-asset-handler": "workspace:*",
74-
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
75-
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
76-
"blake3-wasm": "^2.1.5",
77-
"chokidar": "^4.0.1",
78-
"date-fns": "^4.1.0",
73+
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
74+
"@esbuild-plugins/node-modules-polyfill": "0.2.2",
75+
"blake3-wasm": "2.1.5",
7976
"esbuild": "0.17.19",
80-
"itty-time": "^1.0.6",
8177
"miniflare": "workspace:*",
82-
"nanoid": "^3.3.3",
83-
"path-to-regexp": "^6.3.0",
84-
"resolve": "^1.22.8",
85-
"selfsigned": "^2.0.1",
86-
"source-map": "^0.6.1",
78+
"path-to-regexp": "6.3.0",
8779
"unenv": "npm:[email protected]",
88-
"workerd": "1.20241230.0",
89-
"xxhash-wasm": "^1.0.1"
80+
"workerd": "1.20241230.0"
9081
},
9182
"devDependencies": {
83+
"@aws-sdk/client-s3": "^3.721.0",
9284
"@cloudflare/cli": "workspace:*",
9385
"@cloudflare/eslint-config-worker": "workspace:*",
9486
"@cloudflare/pages-shared": "workspace:^",
@@ -118,10 +110,12 @@
118110
"@vitest/ui": "catalog:default",
119111
"@webcontainer/env": "^1.1.0",
120112
"chalk": "^5.2.0",
113+
"chokidar": "^4.0.1",
121114
"cli-table3": "^0.6.3",
122115
"cmd-shim": "^4.1.0",
123116
"command-exists": "^1.2.9",
124117
"concurrently": "^8.2.2",
118+
"date-fns": "^4.1.0",
125119
"devtools-protocol": "^0.0.1182435",
126120
"dotenv": "^16.3.1",
127121
"execa": "^6.1.0",
@@ -131,6 +125,7 @@
131125
"https-proxy-agent": "7.0.2",
132126
"ignore": "^5.2.0",
133127
"is-ci": "^3.0.1",
128+
"itty-time": "^1.0.6",
134129
"javascript-time-ago": "^2.5.4",
135130
"md5-file": "5.0.0",
136131
"mime": "^3.0.0",
@@ -142,10 +137,13 @@
142137
"patch-console": "^1.0.0",
143138
"pretty-bytes": "^6.0.0",
144139
"prompts": "^2.4.2",
140+
"resolve": "^1.22.8",
145141
"rimraf": "catalog:default",
142+
"selfsigned": "^2.0.1",
146143
"semiver": "^1.1.0",
147144
"shell-quote": "^1.8.1",
148145
"signal-exit": "^3.0.7",
146+
"source-map": "^0.6.1",
149147
"strip-ansi": "^7.1.0",
150148
"supports-color": "^9.2.2",
151149
"timeago.js": "^4.0.2",
@@ -157,6 +155,7 @@
157155
"vitest-websocket-mock": "^0.4.0",
158156
"ws": "^8.18.0",
159157
"xdg-app-paths": "^8.3.0",
158+
"xxhash-wasm": "^1.0.1",
160159
"yargs": "^17.7.2"
161160
},
162161
"peerDependencies": {

packages/wrangler/scripts/deps.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,38 @@ import path from "node:path";
55
* Dependencies that _are not_ bundled along with wrangler
66
*/
77
export const EXTERNAL_DEPENDENCIES = [
8-
"fsevents",
8+
// Wrangler depends on a pinned version of esbuild.
99
"esbuild",
10+
11+
// This blows up when bundled, and has WASM dependencies. Wrangler depends on a pinned version.
1012
"blake3-wasm",
13+
14+
// Wrangler depends on a pinned version of Miniflare.
1115
"miniflare",
12-
// todo - bundle miniflare too
13-
"selfsigned",
14-
"source-map",
16+
17+
// Pending deletion in v4...
1518
"@esbuild-plugins/node-globals-polyfill",
1619
"@esbuild-plugins/node-modules-polyfill",
17-
"chokidar",
20+
1821
// @cloudflare/workers-types is an optional peer dependency of wrangler, so users can
1922
// get the types by installing the package (to what version they prefer) themselves
2023
"@cloudflare/workers-types",
24+
2125
// unenv must be external because it contains unenv/runtime code which needs to be resolved
2226
// and read when we are bundling the worker application
2327
"unenv",
28+
29+
// path-to-regexp must be external because it contains runtime code which needs to be resolved
30+
// and read when we are bundling the worker application.
31+
// See `templates/pages-template-workers`
32+
"path-to-regexp",
33+
34+
// @cloudflare/kv-asset-handler must be external because it contains runtime code which needs to be resolved
35+
// and read when we are bundling the worker application
36+
// Pending deletion in v4...
37+
"@cloudflare/kv-asset-handler",
38+
39+
// workerd contains a native binary, so must be external. Wrangler depends on a pinned version.
2440
"workerd",
2541
];
2642

packages/wrangler/src/pages/functions/buildWorker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import crypto from "node:crypto";
12
import { access, cp, lstat, rm } from "node:fs/promises";
23
import { join, resolve } from "node:path";
34
import { build as esBuild } from "esbuild";
4-
import { nanoid } from "nanoid";
55
import { bundleWorker } from "../../deployment-bundle/bundle";
66
import { findAdditionalModules } from "../../deployment-bundle/find-additional-modules";
77
import {
@@ -404,7 +404,7 @@ function assetsPlugin(buildOutputDirectory: string | undefined): Plugin {
404404
}
405405

406406
// TODO: Consider hashing the contents rather than using a unique identifier every time?
407-
identifiers.set(directory, nanoid());
407+
identifiers.set(directory, crypto.randomUUID());
408408
if (!buildOutputDirectory) {
409409
console.warn(
410410
"You're attempting to import static assets as part of your Pages Functions, but have not specified a directory in which to put them. You must use 'wrangler pages dev <directory>' rather than 'wrangler pages dev -- <command>' to import static assets in Functions."

pnpm-lock.yaml

Lines changed: 28 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)