react / react/metro

feat: add support for multiple app entry files

Open
#850 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

Do you want to request a feature or report a bug?

feature

What is the current behavior?

  • serializer.getPolyfills sits outside of the module system, meaning any import cannot require other modules.
  • serializer.getModulesRunBeforeMainModule only includes the module if the application code also includes the module, effectively meaning it's used for sorting the import position rather than pure injection. This method also does not allow for optionally including based on platforms which can be limiting for cases where you wish to inject platform compatibility code.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

I'd like some mechanism for injecting polyfill modules based on the platform that is being bundled for. The polyfill module should sit within the module system (allowing for import/export) and should not have to be imported by other modules inside of the user's code.

The main benefit of this behavior is that we can inject Metro specific code that Webpack users will never encounter.
Webpack has a similar mechanism called entry points.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the serializer.getPolyfills and serializer.getModulesRunBeforeMainModule entry points mentioned in the issue, then compare the linked repro repository's behavior. Define how platform-specific injected modules should participate in Metro's module system and how multiple app entry files should be configured; done means the behavior works without user imports and is covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.