Skip to content

Add resolve to this context #47

Open

Description

@sxzz

Activity

  1. calebeby commented on Jul 1, 2022

    @calebeby

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

  2. sxzz commented on Mar 15, 2023

    @sxzz
    MemberAuthor

    Yeah, I think we can have it.

  3. self-assigned this
    on Jun 3, 2023
  4. lxsmnsyc commented on Feb 13, 2024

    @lxsmnsyc

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

  5. tjx666 commented on Mar 22, 2024

    @tjx666

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions