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
refactor(Webpack): Immediate finds using waitFor #2409
base: dev
Are you sure you want to change the base?
Conversation
Documented the changes |
9a1a7b3
to
329bc68
Compare
@CodiumAI-Agent /review |
@CodiumAI-Agent /improve |
PR Code Suggestions ✨
|
d936604
to
090a3bc
Compare
Completely deprecates the
lazy
way that we currently do Webpack finds. Instead, now the default will be a unified way which is a combination of the plaincacheFind
for already loaded modules, and usage ofwaitFor
for when modules were not yet loaded.The way this works is:
waitFor
alternative. By using waitFor, everytime a new module is loaded, Vencord will check if that module matches any of the finds requested, and if it does, it sets the result of that find to the module. This avoids having to iterate through the module cache for every find.By having the unified way, we no longer need a lazy alternative of the methods, so the following changes to the API occurred:
find
->cacheFind
find
(wrapper aroundwaitFor
andcacheFind
)findLazy
->find
(the wrapper)findByProps
,findByPropsLazy
->findByProps
findByCode
,findByCodeLazy
->findByCode
findStore
,findStoreLazy
->findStore
findComponent
,findComponentLazy
->findComponent
findExportedComponent
,findExportedComponentLazy
->findExportedComponent
findComponentByCode
,findComponentByCodeLazy
->findComponentByCode
The following were changed for more appropriate names:
findAll
->cacheFindAll
findBulk
->cacheFindBulk
The following were changed for less weird names:
proxyLazyWebpack
->webpackDependantLazy
LazyComponentWebpack
->webpackDependantLazyComponent
The following were not changed:
findModuleId
findModuleFactory
cacheFindAll
andfilters
internally, so it doesn't rely on the way the old methods worked.Additional:
Warning
These are the files that the most changes were introduced: webpack.tsx, patchWebpack.ts, lazy.ts, lazyReact.tsx, proxyInner.ts, generateReport.ts and the commons in webpack
The rest is mainly just changing to use the new methods instead of the deprecated ones
Important
This change is fully backwards compatible for now, as the old methods were kept and just point to the new APIs now.
The plan is to remove them in the future.