I’m generating multiple bundles with Metro to load later from the native side.
The problem is that the bundles aren’t isolated. Metro injects variables at the top of each bundle, and those variables get hoisted when the bundles are loaded, potentially overwriting each other. For example, the globalPrefix option in the Metro transformer is supposed to differentiate global symbols per bundle, but it itself gets hoisted and pollutes the global scope, so all bundles end up sharing the same globalPrefix.
Is there a way to force Metro to isolate bundles—for example, by wrapping each bundle in an IIFE? I tried post-processing the bundles manually, but that breaks the sourcemaps.
I’m generating multiple bundles with Metro to load later from the native side.
The problem is that the bundles aren’t isolated. Metro injects variables at the top of each bundle, and those variables get hoisted when the bundles are loaded, potentially overwriting each other. For example, the globalPrefix option in the Metro transformer is supposed to differentiate global symbols per bundle, but it itself gets hoisted and pollutes the global scope, so all bundles end up sharing the same globalPrefix.
Is there a way to force Metro to isolate bundles—for example, by wrapping each bundle in an IIFE? I tried post-processing the bundles manually, but that breaks the sourcemaps.