Skip to content

creating isolated bundles #1618

@Niryo

Description

@Niryo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions