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
Why is the "getModules" function only available in DEV mode? #1254
Comments
Hi @doodlez79 - it's gated behind metro/packages/metro-runtime/src/polyfills/require.js Lines 530 to 539 in c3aec55
Even if we exposed Can I ask what your use case is for prod use? |
IIRC @EvanBacon was interested in this API (and forked the polyfill to get it) - happy to expose something but ideally we'll keep the API minimal to fit what folks need. |
Good afternoon, we are releasing a split application into small pieces using metro bundler. For security, we want to check the existence of a particular module by identifier. |
So in principle, If you're using |
Hi, I think hasModule would solve our problem. |
And what about the multiple async loading issue? Or is that not your use case? If we're exposing/creating a new public API here a bit more detail on why it's needed would be really helpful. |
We're building codeSpliting into existing large codebase applications where we've already built in full assembly file loading, but are gradually moving to dynamically loading smaller modules on demand. And we add a check for the existence of the module, so that when we have one bundle, it does not try to download anything, but immediately returns it to the user. For our application, we made a service that returns a list of modules and dependencies, if we have the same modules in our dependencies, then we really might have a problem. We create an object in which we store the key (moduleId), and the value is the loading state of this module (promise), and if two modules depend on the same module, then one will download it, and the other must wait for the end of its loading. And hasModule will allow you to check the existence of this module and prevent unnecessary trips to the network for modules! |
Good afternoon, we wanted to use “getModules” in the Production build of metro, but it’s not there. Tell me why it cannot be used in the Prod assembly? Is it possible to remove it from the DEV flag?
The text was updated successfully, but these errors were encountered: