rnx-kit icon indicating copy to clipboard operation
rnx-kit copied to clipboard

Develop a bundle-splitting engineering plan

Open afoxman opened this issue 2 years ago • 1 comments

Develop a detailed engineering plan for bundle-splitting.

Use the bundle-splitting scenarios from #1282 as a starting point, along with code from internal Office repos. Cover both bundle production and bundle consumption. Include expectations regarding bundle size increase compared to equivalent single-bundle runs.

Output is a plan and a task list.

afoxman avatar Mar 20 '22 22:03 afoxman

Notes on one possible solution

A split bundle exports a collection of packages, each under a unique name. The split bundle author specifies this mapping as kit configuration.

For example, it might look like this:

"rnx-kit": {
    "splitBundle": {
        "interface": {
            "MyKitGlobal.Telemetry": "telemetryjs",
            "MyKitGlobal.StringResources": "string-resources",
            "MyKitGlobal.ReactNative.Components": "react-native"
        }
    }
}

The bundler will take this configuration, and use it to generate a programmatically-consumable, type-safe API. Something along the lines of a typescript .d.ts file.

Other packages which depend on this kit will naturally gain access to the type-safe API, and benefit from it in IDEs like VSCode and at lint/build time.

afoxman avatar Mar 20 '22 22:03 afoxman