Skip to content

feat: default to enableOptionalDependencies: true in metro config - #1350

Merged
thymikee merged 3 commits into
react-native-community:masterfrom
brentvatne:@brent/allow-optonal-dependencies
Feb 4, 2021
Merged

thymikee merged 3 commits into
react-native-community:masterfrom
brentvatne:@brent/allow-optonal-dependencies

Conversation

@brentvatne

@brentvatne brentvatne commented Jan 21, 2021 •

Copy link
Copy Markdown
Contributor

Summary:

Motivation outlined in #1348

Test Plan:

I wasn't sure what to do for testing this because there isn't any precedent for testing loadMetroConfig or getDefaultConfig that I could find. I added a test for getDefaultConfig to ensure this option doesn't accidentally get disabled, although I understand that this is not the most useful test.

Note: the Context type is massive and difficult to construct, so I tried to narrow it to just what we use here by replacing ctx: Context with ctx: ConfigLoadingContext as defined here:

type ConfigLoadingContext = Pick<Config, 'root' | 'reactNativePath'> & {
  platforms: {
    [name: string]: {npmPackageName?: string};
  };
};

I tried to add a test for loadMetroConfig to ensure that if we override other transformer properties we still preserve the default allowOptionalDependencies value, but metro's config loading code via cosmiconfig didn't work out of the box with the the cli's existing fs mocking code so I shelved that idea for now.

Note:

As discussed in #1348 I'd love to see this backported to 4.x along with #1351

@thymikee thymikee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@brentvatne

Copy link
Copy Markdown
Contributor Author

azure pipeline test failure looks unrelated to this pr:

Screen Shot 2021-01-21 at 2 32 01 PM

@thymikee
thymikee merged commit 760708f into react-native-community:master Feb 4, 2021
thymikee added a commit that referenced this pull request Feb 4, 2021
)

* feat: default to enableOptionalDependencies: true in metro config

* feat: add test for getDefaultConfig

* simplify type

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
thymikee added a commit that referenced this pull request Feb 4, 2021
) (#1360)

* feat: default to enableOptionalDependencies: true in metro config

* feat: add test for getDefaultConfig

* simplify type

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>

Co-authored-by: Brent Vatne <brentvatne@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants