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

Add resolve to this context #47

Open
sxzz opened this issue Jan 19, 2022 · 4 comments
Open

Add resolve to this context #47

sxzz opened this issue Jan 19, 2022 · 4 comments
Assignees

Comments

@sxzz
Copy link
Member

sxzz commented Jan 19, 2022

ESBuild: https://esbuild.github.io/plugins/#resolve
Rollup: https://rollupjs.org/guide/en/#thisresolve
Rspack: wait PR web-infra-dev/rspack#2080

@calebeby
Copy link

calebeby commented Jul 1, 2022

@antfu Would you accept a PR adding this for everything but webpack?

@sxzz
Copy link
Member Author

sxzz commented Mar 15, 2023

Yeah, I think we can have it.

@sxzz sxzz self-assigned this Jun 3, 2023
@lxsmnsyc
Copy link

Any updates to this? would have been a great addition.

@sxzz sxzz added the pr welcome label Mar 3, 2024
@tjx666
Copy link

tjx666 commented Mar 22, 2024

So, what'is the best practice getting get the resolved id in webpack now?
Following is chatgpt answer:

webpack(compiler) {
    compiler.hooks.normalModuleFactory.tap(
        `${name}.normalModuleFactory`,
        (normalModuleFactory) => {
            normalModuleFactory.hooks.afterResolve.tapAsync(
                `${name}.normalModuleFactory.afterResolve`,
                (data, callback) => {
                    const importer = data.contextInfo.issuer;
                    const resolvedId = data.createData.resource;
                    if (importer && resolvedId) {
                        parseModule(resolvedId, importer).then(() => {
                            // eslint-disable-next-line promise/no-callback-in-promise
                            callback(null);
                        });
                    } else {
                        callback(null);
                    }
                },
            );
        },
    );
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants