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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(module factory): add before_resolve hook #2940

Merged
merged 19 commits into from
May 6, 2023

Conversation

suxin2017
Copy link
Collaborator

@suxin2017 suxin2017 commented Apr 25, 2023

Related issue (if exists)

#2788

Summary

馃 Generated by Copilot at 22b4de9

Added a new plugin hook for normal module resolution in rspack_core. This hook allows plugins to modify or skip the default module resolution logic in NormalModuleFactory. The hook is implemented by the Plugin trait and the PluginDriver struct, and uses the NormalModuleBeforeResolveArgs struct to pass the relevant information.

Walkthrough

馃 Generated by Copilot at 22b4de9

  • Add before_resolve hook to Plugin trait and PluginDriver struct to allow plugins to intercept and modify module resolution (link, link)
  • Modify NormalModuleFactory to invoke before_resolve hook before resolving module dependency using ResolveArgs struct (link, link, link)
  • Define and export NormalModuleBeforeResolveArgs struct in plugin::args and plugin::api to hold information about module dependency and context for before_resolve hook (link, link)
  • Define and export PluginNormalModuleFactoryBeforeResolveOutput type alias in plugin::api to represent possible outcomes of before_resolve hook (link, link)

@changeset-bot
Copy link

changeset-bot bot commented Apr 25, 2023

鈿狅笍 No Changeset found

Latest commit: 51001e8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@suxin2017 suxin2017 marked this pull request as ready for review April 26, 2023 06:08
@IWANABETHATGUY
Copy link
Contributor

Please rebase the main branch.

@suxin2017
Copy link
Collaborator Author

suxin2017 commented Apr 26, 2023

Please rebase the main branch.

Why did I run pnpm run build:cli:debug after concatenation removed a lot of type definitions
image

@IWANABETHATGUY

@IWANABETHATGUY
Copy link
Contributor

Please rebase the main branch.

Why did I run pnpm run build:cli:debug after concatenation removed a lot of type definitions image

@IWANABETHATGUY

Sorry, I can't reproduce.

@IWANABETHATGUY
Copy link
Contributor

maybe you could try build:cli:release

@suxin2017
Copy link
Collaborator Author

I don't know why this only happened to me, I didn't reproduce it on gitpod.io.

@IWANABETHATGUY
Copy link
Contributor

Maybe related to #2912, I will investigate this issue when I have time.

@IWANABETHATGUY
Copy link
Contributor

Would you mind resolving conflicts? Overall, this pull request looks good to me.

# Conflicts:
#	crates/node_binding/binding.d.ts
@suxin2017
Copy link
Collaborator Author

sure

@suxin2017
Copy link
Collaborator Author

Would you mind resolving conflicts? Overall, this pull request looks good to me.

I'm done

packages/rspack/src/compiler.ts Show resolved Hide resolved
packages/rspack/tests/IgnorePlugin.test.ts Outdated Show resolved Hide resolved
packages/rspack/tests/IgnorePlugin.test.ts Outdated Show resolved Hide resolved
@IWANABETHATGUY
Copy link
Contributor

it looks ready to merge if you could address the rest of the two issues.

@suxin2017
Copy link
Collaborator Author

it looks ready to merge if you could address the rest of the two issues.

this.#updateDisableHooks() like this https://github.com/web-infra-dev/rspack/pull/2940/files#diff-65c9f2211aa3417321f820555fd1ec4a9647fdc6cba3c80c2b96587a4d4ad4fdR417

I don't quite understand the problem. Everything else has been solved

@IWANABETHATGUY
Copy link
Contributor

IWANABETHATGUY commented May 6, 2023

Any reason we need to downgrade the tracing crate?

What about this one?

@suxin2017
Copy link
Collaborator Author

Any reason we need to downgrade the tracing crate?

What about this one?

https://crates.io/crates/tracing/versions
This version 0.1.38 was removed

@IWANABETHATGUY
Copy link
Contributor

nice point, LGTM

@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue May 6, 2023
Merged via the queue into web-infra-dev:main with commit bfa16df May 6, 2023
10 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants