Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote dependency analysis is inconsistent #403

Open
ZengTianShengZ opened this issue Jan 8, 2025 · 0 comments
Open

Remote dependency analysis is inconsistent #403

ZengTianShengZ opened this issue Jan 8, 2025 · 0 comments

Comments

@ZengTianShengZ
Copy link

I implemented Custom providers myself . but when I executed the same importmap generation multiple times, I found that the dependency packages returned by theresolveLatestTarget callback method were different.

    async function resolveLatestTarget(target, layer, parentUrl) {
        var _a;
        let version = null;
        let registry = null;
        const range = String(target.range);
        const pkg = dependencies.find((dep) => dep.name === target.name);
        const overridesPkg = overridesVersion(target, { ...overrides, ...resolutions }, dependencies);

        console.log('--parentUrl---', parentUrl);
        console.log('--target.name--', target.name);

        if (overridesPkg === null || overridesPkg === void 0 ? void 0 : overridesPkg.version) {
            // 如果是覆盖包
            version = overridesPkg.version;
            console.log('--version--1--', version);

        }
        else if (pkg && !parentUrl.startsWith(CDN_URL)) {
            // 如果不是远程包,返回本地包版本
            version = pkg.version;
            registry = 'local';
            console.log('--version--2--', version);

        }
        else {
            registry = 'cdn';
            // 当远程包版本为*时,返回本地包版本
            if (range === '*') {
                const localPkg = await parseDependencies(target.name, parentUrl, mapUrl);
                version = localPkg.version;
                console.log('--version--3--', version);

            }
            else {
                // 当远程包版本不为*时,返回远程包版本
                version = (_a = semver.minVersion(range)) === null || _a === void 0 ? void 0 : _a.version;
                console.log('--version--4--', version);

            }
        }



        const depPkg = {
            registry: registry,
            name: target.name,
            version: version,
        };
        await ensureBuild(depPkg);
        return depPkg;
    }

First Execution:
@gaoding/axios-adapters returned 5 dependencies, as expected

www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- @gaoding/cache
www postinstall: --version--4-- 1.1.0
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- await-to-js
www postinstall: --version--4-- 2.1.1
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- axios
www postinstall: --version--1-- 0.27.2
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- is-buffer
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- path-to-regexp
www postinstall: --version--4-- 3.1.0

Second execution:
@gaoding/axios-adapters returned 3 dependencies, not meeting expectations. Missing @gaoding/cache, axios related dependencies

www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- await-to-js
www postinstall: --version--4-- 2.1.1
www postinstall: ---pkgUrl-------------- https://esm.dancf.com/npm:[email protected]
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- is-buffer
www postinstall: --parentUrl--- https://esm.dancf.com/npm:@gaoding/[email protected]/dist/index.es.js
www postinstall: --target.name-- path-to-regexp
www postinstall: --version--4-- 3.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant