"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sync = sync;
const node_path_1 = require("node:path");
const node_url_1 = require("node:url");
const possibleExtensions = [".ts", ".tsx", ".js", ".jsx"];
function sync(path, options) {
    const resolver = options.defaultResolver;
    if (process.env.TEST_ENV === "ci" && path.startsWith("@apollo/client")) {
        const result = import.meta.resolve(path, (0, node_url_1.pathToFileURL)((0, node_path_1.join)(options.rootDir, "../dist/index.js")));
        if (result.includes("__cjs")) {
            throw new Error("Resolved to CJS entry point, we want to test ESM entry points!");
        }
        if (!result.includes("dist")) {
            throw new Error("Did not resolve to build artifact!");
        }
        return (0, node_url_1.fileURLToPath)(result);
    }
    if (path.startsWith(".") && path.endsWith(".js")) {
        for (const extension of possibleExtensions) {
            try {
                return resolver(path.replace(/\.js$/i, extension), options);
            }
            catch { }
        }
    }
    if (path.startsWith("@apollo/client")) {
        return (0, node_url_1.fileURLToPath)(import.meta.resolve(path));
    }
    return resolver(path, options);
}
//# sourceMappingURL=resolver.cjs.map
