Skip to content

Commit a22724f

Browse files
committed
Step 2 - Hooks for module loading.
1 parent 58f0681 commit a22724f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Context, DefaultLoad, NextResolve } from './types';
2+
3+
4+
export async function initialize({ port }: { port: MessagePort }) {
5+
port.onmessage = async (event) => {};
6+
}
7+
8+
export async function resolve(
9+
specifierInput: string,
10+
context: Context,
11+
nextResolve: NextResolve
12+
) {
13+
nextResolve(specifierInput, context, nextResolve);
14+
}
15+
16+
export async function load(
17+
url: string,
18+
context: Context,
19+
defaultLoad: DefaultLoad
20+
) {
21+
return defaultLoad(url, context, defaultLoad);
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export type Context = {
2+
parentURL?: string;
3+
};
4+
5+
export type NextResolve = (
6+
specifier: string,
7+
context: Context,
8+
nextResolve: NextResolve
9+
) => Promise<string | unknown>;
10+
11+
export type DefaultLoad = (
12+
specifier: string,
13+
context: Context,
14+
defaultLoad: DefaultLoad
15+
) => Promise<string | unknown>;

0 commit comments

Comments
 (0)