File size: 542 Bytes
c1fc133
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Resolve TypeScript's extensionless ESM output for source-level Node gates.
// Production is bundled by Vite; this loader gives the gate the same ESM semantics without
// pretending the valid `import.meta.url` worker code is CommonJS.
export async function resolve(specifier, context, nextResolve) {
  try {
    return await nextResolve(specifier, context);
  } catch (error) {
    if (specifier.startsWith(".") && !/\.[cm]?js(?:[?#]|$)/.test(specifier)) {
      return nextResolve(`${specifier}.js`, context);
    }
    throw error;
  }
}