Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

673 B
Raw Blame
// Resolves root-relative imports (/src/*, /bench/*, /packages/*) from the repository root so Node can load reference scenes directly.
const REPOSITORY_ROOT_URL = new URL('../../', import.meta.url);
const ROOT_PREFIXES = ['/src/', '/bench/', '/packages/', '/scripts/'];

function hasRepositoryRootPrefix(specifier) {
  return ROOT_PREFIXES.some((prefix) => specifier.startsWith(prefix));
}

export async function resolve(specifier, context, nextResolve) {
  if (hasRepositoryRootPrefix(specifier)) {
    const resolvedUrl = new URL(specifier.slice(1), REPOSITORY_ROOT_URL).href;
    return nextResolve(resolvedUrl, context);
  }
  return nextResolve(specifier, context);
}