Skip to content

Commit

Permalink
Add native support for Windows 🎉
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrbbot committed Nov 1, 2023
1 parent 20015c7 commit 02877e9
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 376 deletions.
41 changes: 0 additions & 41 deletions packages/miniflare/lib/docker-restart.sh

This file was deleted.

27 changes: 0 additions & 27 deletions packages/miniflare/lib/wsl-restart.sh

This file was deleted.

5 changes: 2 additions & 3 deletions packages/miniflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"files": [
"dist/src",
"lib"
"dist/src"
],
"dependencies": {
"acorn": "^8.8.0",
Expand All @@ -39,7 +38,7 @@
"source-map-support": "0.5.21",
"stoppable": "^1.1.0",
"undici": "^5.13.0",
"workerd": "^1.20230221.0",
"workerd": "^1.20230404.0",
"ws": "^8.11.0",
"youch": "^3.2.2",
"zod": "^3.20.6"
Expand Down
14 changes: 2 additions & 12 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ import {
import {
Config,
Runtime,
RuntimeConstructor,
RuntimeOptions,
Service,
Socket,
Worker_Binding,
Worker_Module,
getSupportedRuntime,
serializeConfig,
} from "./runtime";
import {
Expand Down Expand Up @@ -232,7 +230,6 @@ export class Miniflare {
#log: Log;
readonly #clock: Clock;

readonly #runtimeConstructor: RuntimeConstructor;
#runtime?: Runtime;
#removeRuntimeExitHook?: () => void;
#runtimeEntryURL?: URL;
Expand Down Expand Up @@ -286,12 +283,6 @@ export class Miniflare {
this.#clock = this.#sharedOpts.core.clock ?? defaultClock;
this.#initPlugins();

// Get supported shell for executing runtime binary
// TODO: allow this to be configured if necessary
this.#runtimeConstructor = getSupportedRuntime();
const desc = this.#runtimeConstructor.description;
this.#log.debug(`Running workerd ${desc}...`);

this.#liveReloadServer = new WebSocketServer({ noServer: true });
this.#webSocketServer = new WebSocketServer({
noServer: true,
Expand Down Expand Up @@ -386,12 +377,11 @@ export class Miniflare {
inspectorPort: this.#sharedOpts.core.inspectorPort,
verbose: this.#sharedOpts.core.verbose,
};
this.#runtime = new this.#runtimeConstructor(opts);
this.#runtime = new Runtime(opts);
this.#removeRuntimeExitHook = exitHook(() => void this.#runtime?.dispose());

const accessibleHost =
this.#runtime.accessibleHostOverride ??
(host === "*" || host === "0.0.0.0" ? "127.0.0.1" : host);
host === "*" || host === "0.0.0.0" ? "127.0.0.1" : host;
this.#runtimeEntryURL = new URL(`http://${accessibleHost}:${entryPort}`);

const config = await this.#assembleConfig();
Expand Down
3 changes: 2 additions & 1 deletion packages/miniflare/src/plugins/shared/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ export const DEFAULT_PERSIST_ROOT = ".mf";
export const PARAM_FILE_UNSANITISE = "unsanitise";

export function maybeParseURL(url: Persistence): URL | undefined {
if (typeof url !== "string" || path.isAbsolute(url)) return;
try {
if (typeof url === "string") return new URL(url);
return new URL(url);
} catch {}
}

Expand Down
Loading

0 comments on commit 02877e9

Please sign in to comment.