runloopable / web /scripts /test-esm-loader.mjs
fsanyoto's picture
Deploy AIOS web (React glide grid + FastAPI slice)
c1fc133 verified
Raw History Blame Contribute Delete
542 Bytes
// 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;
}
}