Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit ca3272d

Browse files
committed
Add native support for Windows 🎉
As of cloudflare/workerd#452, `workerd` supports Windows' natively. This change upgrades `workerd`, then removes the WSL and Docker runtime shells. It also `Cherry`picks #509, to allow Miniflare development on Windows too.
1 parent dae7719 commit ca3272d

File tree

16 files changed

+134
-422
lines changed

16 files changed

+134
-422
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
os: [ubuntu-latest] # `windows-latest` not yet supported
21+
os: [ubuntu-latest, windows-latest]
2222
node: [16.13.0, latest]
2323
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2424

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"dev": "node scripts/build.mjs watch",
2424
"helpers:scaffold": "node scripts/scaffold.mjs",
2525
"helpers:version": "node scripts/version.mjs",
26-
"lint": "eslint 'packages/*/{src,test}/**/*.ts' 'scripts/**/*.{js,mjs}' 'types/**/*.ts'",
26+
"lint": "eslint \"packages/*/{src,test}/**/*.ts\" \"scripts/**/*.{js,mjs}\" \"types/**/*.ts\"",
2727
"lint:fix": "npm run lint -- --fix",
2828
"prepublishOnly": "npm run lint && npm run clean && npm run build && npm run types:bundle && npm run test",
2929
"test": "npm run build && ava && rimraf ./.tmp",
3030
"types:build": "tsc",
3131
"___$comment:types:bundle": "api-extractor doesn't know to load index.ts instead of index.d.ts when resolving imported types",
32-
"types:bundle": "cp node_modules/@cloudflare/workers-types/experimental/index.ts node_modules/@cloudflare/workers-types/experimental/index.d.ts && npm run types:build && node scripts/types.mjs"
32+
"types:bundle": "node scripts/copy.mjs node_modules/@cloudflare/workers-types/experimental/index.ts node_modules/@cloudflare/workers-types/experimental/index.d.ts && npm run types:build && node scripts/types.mjs"
3333
},
3434
"devDependencies": {
3535
"@ava/get-port": "^2.0.0",

packages/tre/lib/docker-restart.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/tre/lib/wsl-restart.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/tre/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"main": "./dist/src/index.js",
2424
"types": "./dist/src/index.d.ts",
2525
"files": [
26-
"dist/src",
27-
"lib"
26+
"dist/src"
2827
],
2928
"dependencies": {
3029
"acorn": "^8.8.0",
@@ -39,7 +38,7 @@
3938
"source-map-support": "0.5.21",
4039
"stoppable": "^1.1.0",
4140
"undici": "^5.13.0",
42-
"workerd": "^1.20230221.0",
41+
"workerd": "^1.20230404.0",
4342
"ws": "^8.11.0",
4443
"youch": "^3.2.2",
4544
"zod": "^3.20.6"

packages/tre/src/index.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ import {
5454
import {
5555
Config,
5656
Runtime,
57-
RuntimeConstructor,
5857
RuntimeOptions,
5958
Service,
6059
Socket,
6160
Worker_Binding,
6261
Worker_Module,
63-
getSupportedRuntime,
6462
serializeConfig,
6563
} from "./runtime";
6664
import {
@@ -232,7 +230,6 @@ export class Miniflare {
232230
#log: Log;
233231
readonly #clock: Clock;
234232

235-
readonly #runtimeConstructor: RuntimeConstructor;
236233
#runtime?: Runtime;
237234
#removeRuntimeExitHook?: () => void;
238235
#runtimeEntryURL?: URL;
@@ -286,12 +283,6 @@ export class Miniflare {
286283
this.#clock = this.#sharedOpts.core.clock ?? defaultClock;
287284
this.#initPlugins();
288285

289-
// Get supported shell for executing runtime binary
290-
// TODO: allow this to be configured if necessary
291-
this.#runtimeConstructor = getSupportedRuntime();
292-
const desc = this.#runtimeConstructor.description;
293-
this.#log.debug(`Running workerd ${desc}...`);
294-
295286
this.#liveReloadServer = new WebSocketServer({ noServer: true });
296287
this.#webSocketServer = new WebSocketServer({
297288
noServer: true,
@@ -386,12 +377,11 @@ export class Miniflare {
386377
inspectorPort: this.#sharedOpts.core.inspectorPort,
387378
verbose: this.#sharedOpts.core.verbose,
388379
};
389-
this.#runtime = new this.#runtimeConstructor(opts);
380+
this.#runtime = new Runtime(opts);
390381
this.#removeRuntimeExitHook = exitHook(() => void this.#runtime?.dispose());
391382

392383
const accessibleHost =
393-
this.#runtime.accessibleHostOverride ??
394-
(host === "*" || host === "0.0.0.0" ? "127.0.0.1" : host);
384+
host === "*" || host === "0.0.0.0" ? "127.0.0.1" : host;
395385
this.#runtimeEntryURL = new URL(`http://${accessibleHost}:${entryPort}`);
396386

397387
const config = await this.#assembleConfig();

packages/tre/src/plugins/shared/gateway.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ export const DEFAULT_PERSIST_ROOT = ".mf";
5050
export const PARAM_FILE_UNSANITISE = "unsanitise";
5151

5252
export function maybeParseURL(url: Persistence): URL | undefined {
53+
if (typeof url !== "string" || path.isAbsolute(url)) return;
5354
try {
54-
if (typeof url === "string") return new URL(url);
55+
return new URL(url);
5556
} catch {}
5657
}
5758

0 commit comments

Comments
 (0)