-
Notifications
You must be signed in to change notification settings - Fork 192
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
feat: monomorphic ResolveRequest object #445
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 20 changed files in this pull request and generated 1 comment.
Files not reviewed (15)
- lib/ResolverFactory.js: Evaluated as low risk
- lib/ModulesInHierarchicalDirectoriesPlugin.js: Evaluated as low risk
- lib/SymlinkPlugin.js: Evaluated as low risk
- lib/ModulesInRootPlugin.js: Evaluated as low risk
- lib/AppendPlugin.js: Evaluated as low risk
- lib/DescriptionFilePlugin.js: Evaluated as low risk
- lib/JoinRequestPartPlugin.js: Evaluated as low risk
- lib/ExportsFieldPlugin.js: Evaluated as low risk
- lib/AliasFieldPlugin.js: Evaluated as low risk
- lib/ResultPlugin.js: Evaluated as low risk
- lib/AliasPlugin.js: Evaluated as low risk
- lib/RootsPlugin.js: Evaluated as low risk
- lib/ImportsFieldPlugin.js: Evaluated as low risk
- lib/CloneBasenamePlugin.js: Evaluated as low risk
- lib/JoinRequestPlugin.js: Evaluated as low risk
Comments suppressed due to low confidence (1)
lib/ParsePlugin.js:55
- The logic for setting the 'fragment' property might not correctly handle cases where both 'parsed.fragment' and 'request.fragment' are falsy. Consider using 'parsed.fragment ?? request.fragment' to handle these cases correctly.
fragment: parsed.fragment || request.fragment || parsed.fragment,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmichon-msft Yeah, I am afraid it is a breaking change...
In webpack we have such things - https://github.com/webpack/webpack/blob/main/lib/cache/ResolverCachePlugin.js#L147 and https://github.com/webpack/webpack/blob/main/lib/cache/ResolverCachePlugin.js#L150
Technically we can solve this and add a special place to store such things.
I have only remembered one place where we use it, maybe somewhere else, but it is quite possible that this is the only place
So let's try to solve it step by step
- Implement special place to store custom values for authors (maybe just Map?)
- Make internal helper for request generation and implement an option to back compat
- Rewrite it in webpack and test it
Alternative solution, maybe even better, but need to check perf
- Check request in factory (we can use Symbol
isPure
) - if no unknown properties it is pure (we known them), otherwisefalse
- Make internal helper for creating request - if it
isPure
request we can use your logic and get perf improvement, if no just use olg logic - (Optional) And also provide a place to store custom values for authors, because to bring such improvements to webpack
So we will keep old behaviour and have perf improvement for some places
The |
I have some thoughts on ways to make this behavior be a resolver option, will refactor. |
Improves performance all-up (especially in
ParsePlugin
,JoinRequestPlugin
,JoinRequestPartPlugin
) by ensuring that theResolveRequest
object always has a constant shape.Note that this is technically a breaking change to plugin authors, if they took a dependency on the ability to attach arbitrary properties to the
ResolveRequest
object to pass them between plugins and out of the resolver, instead of using thecontext
property.Additionally, creating the object via a direct object literal is significantly faster than creating it via object spread.
Testing on NodeJS 18.19.1, this had the following impact for a local webpack build.
![image](https://private-user-images.githubusercontent.com/26827560/401783459-57daefe8-25c8-43c9-b9a7-0e1b30cc29f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDIyNjAsIm5iZiI6MTczODk0MTk2MCwicGF0aCI6Ii8yNjgyNzU2MC80MDE3ODM0NTktNTdkYWVmZTgtMjVjOC00M2M5LWI5YTctMGUxYjMwY2MyOWYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE1MjYwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIyZDZhOGM4NDhhMzgxYWMxNmM4ZjBmNzgzNTVkY2VjZmI0NmZjZWZlMmUzMWZiNThmOGEzMTgwOTI5NmVlM2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.B0RgcEdisypihRgzStc0Xjtpr9m4vkb6TTfYqca4p80)
![image](https://private-user-images.githubusercontent.com/26827560/401784647-6ff4ce67-ff90-4c12-877d-7bfe6d7a22be.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDIyNjAsIm5iZiI6MTczODk0MTk2MCwicGF0aCI6Ii8yNjgyNzU2MC80MDE3ODQ2NDctNmZmNGNlNjctZmY5MC00YzEyLTg3N2QtN2JmZTZkN2EyMmJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE1MjYwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhZmI4ZDNjNDEwNTAzOTg5NGJiZTlhOTBlMWY0NTg0OWRiMjYyMGQ2MTM4M2ZiZDkzYmJmMDIyZGNiZTY3NDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DSAqhp-y_yCCIWR8OLC8yd5qgFZ-PzSkGy-LyeUJOjw)
Before:
After:
![image](https://private-user-images.githubusercontent.com/26827560/401783532-ea41898e-d11a-41e5-bced-39c83e852f2b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDIyNjAsIm5iZiI6MTczODk0MTk2MCwicGF0aCI6Ii8yNjgyNzU2MC80MDE3ODM1MzItZWE0MTg5OGUtZDExYS00MWU1LWJjZWQtMzljODNlODUyZjJiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE1MjYwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU0ZjdjMmUzNjAyMTBmYmRhNzE1OWVmOWFkOGU1ZGQzN2RkZTJhY2EwN2FhMDAyM2U4YzQwZmZkZjc5MmM2MDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qbcnY01-mHQztn7TV3cNf8-q4bca7qSjzDzwUE4OToQ)
![image](https://private-user-images.githubusercontent.com/26827560/401784723-bff96b87-64aa-4392-b4da-42a46e349b09.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NDIyNjAsIm5iZiI6MTczODk0MTk2MCwicGF0aCI6Ii8yNjgyNzU2MC80MDE3ODQ3MjMtYmZmOTZiODctNjRhYS00MzkyLWI0ZGEtNDJhNDZlMzQ5YjA5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE1MjYwMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTczNDU1MGY1Zjc4OTAwYzU5ZTg3OGIxMWJkYjI1MjBmYjRhYzI1ZWVhZjdjMmFjNDRjOTcyYzA3ODI2ZjM0YWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.17ow5sB9K0oHme9qI4tNd80FZ9SkFMnjbBxXRQoonE0)