MCPcopy
hub / github.com/babel/babel / Client

Class Client

packages/babel-register/src/worker-client.ts:8–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import { markInRegisterWorker } from "./is-in-register-worker.ts";
7
8class Client implements IClient {
9 #send;
10
11 constructor(send: (action: ACTIONS, payload: any) => any) {
12 this.#send = send;
13 }
14
15 #eCache: string[] | undefined;
16 getDefaultExtensions(): string[] {
17 return (this.#eCache ??= this.#send(
18 ACTIONS.GET_DEFAULT_EXTENSIONS,
19 undefined,
20 ));
21 }
22
23 setOptions(options: Options): void {
24 return this.#send(ACTIONS.SET_OPTIONS, options);
25 }
26
27 transform(
28 code: string,
29 filename: string,
30 ): { code: string; map: object } | null {
31 return this.#send(ACTIONS.TRANSFORM, { code, filename });
32 }
33
34 isFileIgnored(filename: string): boolean {
35 return this.#send(ACTIONS.IS_FILE_IGNORED, filename);
36 }
37
38 close() {
39 this.#send(ACTIONS.CLOSE, undefined);
40 }
41}
42
43// We need to run Babel in a worker because require hooks must
44// run synchronously, but many steps of Babel's config loading

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…