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

[Feature]: support get import attributes in NormalModuleFactory resolve hook #8770

Open
9aoy opened this issue Dec 19, 2024 · 0 comments
Open
Labels
feat New feature or request pending triage The issue/PR is currently untouched. team The issue/pr is created by the member of Rspack.

Comments

@9aoy
Copy link
Collaborator

9aoy commented Dec 19, 2024

What problem does this feature solve?

In order to better support Import Attributes, we need to support attributes in NormalModuleFactory resolve hook.

export type ResolveData = {
	contextInfo: ContextInfo;
	context: string;
	request: string;
+       attributes?: Record<string, any>;
	fileDependencies: string[];
	missingDependencies: string[];
	contextDependencies: string[];
	createData?: CreateData;
};

By the way, this feature is already supported in webpack, but the key name is assertions.

https://github.com/webpack/webpack/blob/5e09d0e05f243d8d2c14c9fe140eba32b7aaeac7/types.d.ts#L12442

What does the proposed API of configuration look like?

compiler.hooks.compilation.tap(
  'MyPlugin',
  (compilation, { normalModuleFactory }) => {
    normalModuleFactory.hooks.resolve.tap('MyPlugin', resolveData => {
+      console.log(resolveData.attributes);
    });
  },
);
@9aoy 9aoy added feat New feature or request pending triage The issue/PR is currently untouched. labels Dec 19, 2024
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request pending triage The issue/PR is currently untouched. team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

1 participant