Skip to content

Commit 6f56cf7

Browse files
committed
Make esm support optional
1 parent 326beb6 commit 6f56cf7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface RunOptions {
1111
export interface ProjectConfig {
1212
ignore: string[];
1313
swc?: SwcConfig;
14+
esm?: boolean;
1415
extensions: string[];
1516
cacheDir: string;
1617
}

src/Supervisor.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ChildProcess, StdioOptions } from "child_process";
22
import { spawn } from "child_process";
33
import { EventEmitter, once } from "events";
4+
import { defaultTo } from "lodash";
45
import { setTimeout } from "timers/promises";
56
import type { RunOptions } from "./Options.js";
67
import type { Project } from "./Project.js";
@@ -66,6 +67,7 @@ export class Supervisor extends EventEmitter {
6667
...process.env,
6768
WDS_SOCKET_PATH: this.socketPath,
6869
WDS_EXTENSIONS: this.project.config.extensions.join(","),
70+
WDS_ESM_ENABLED: defaultTo(this.project.config.esm, true) ? "true" : "false",
6971
},
7072
stdio: stdio,
7173
detached: true,

src/hooks/child-process-register.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ process.setSourceMapsEnabled(true);
1515
// register the CJS hook to intercept require calls the old way
1616
import "./child-process-cjs-hook.cjs";
1717

18-
// register the ESM loader the new way
19-
register("./child-process-esm-loader.js", import.meta.url);
18+
if (process.env.WDS_ESM_ENABLED === "true") {
19+
// register the ESM loader the new way
20+
register("./child-process-esm-loader.js", import.meta.url);
21+
}

0 commit comments

Comments
 (0)