Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update resolverMainFields for vanilla React Native #256

Merged
merged 2 commits into from
Aug 19, 2021

Conversation

jd20
Copy link
Contributor

@jd20 jd20 commented Aug 19, 2021

Issue: #255

What I did

Add "browser" to the mainResolverFields, so as not to break polyfills that depend on it.

An alternative approach would be to override the default config's mainResolverFields, but this requires a much bigger change, that I assume some teams may not be comfortable with. Since the default for pretty much all React Native apps should be the same, I think just adding "browser" is a much less invasive change. If a team has customized their mainResolverFields already, then it should be pretty clear what they need to do, when updating their metro.config.js. Just for reference, below is the altnerative solution:

const {getDefaultConfig} = require('metro-config');

module.exports = (async () => {
  const {
    resolver: {resolverMainFields},
  } = await getDefaultConfig();
  return {
    transformer: {
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: false,
        },
      }),
    },
    resolver: {
      resolverMainFields: ['sbmodern', ...resolverMainFields],
    },
  };
})();

How to test

Run through the v6 instructions, everything should still work same as before.

  • Does this need a new example in examples/native? no, I did update the existing example though.
  • Does this need an update to the documentation? included

Copy link
Member

@dannyhw dannyhw left a comment

Choose a reason for hiding this comment

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

After checking the metro config packages these are the default values anyway and I think its the easier way with fewer changes for the user so I'm ok with this. Maybe we can provide the alternative in the docs somewhere if it becomes necessary.

Thanks for your contribution 🙇

@dannyhw dannyhw merged commit 8382bb4 into storybookjs:next-6.0 Aug 19, 2021
@dannyhw
Copy link
Member

dannyhw commented Aug 19, 2021

gist with the script in has now been updated also

dannyhw pushed a commit to raychanks/react-native that referenced this pull request Feb 7, 2022
…#256)

* docs: Update resolverMainFields for vanilla React Native

* Update the example as well
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.

None yet

2 participants