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

How to use it? #3

Open
josephbuchma opened this issue Jan 14, 2020 · 1 comment
Open

How to use it? #3

josephbuchma opened this issue Jan 14, 2020 · 1 comment

Comments

@josephbuchma
Copy link

josephbuchma commented Jan 14, 2020

I'm trying to use it with ReactNative 0.61.3.
Adding babel-plugin-require-context-polyfill to babel plugins list does not work (require.context is undefined)

@ghost
Copy link

ghost commented Jan 14, 2020

This plugin was writed to enable isomorphism (same code in both world) between navigator bundled with Webpack and NodeJS. I use it in NodeJS environment to reproduce the native existing function (require.context) in webpack, that I use to bundle navigator and react-native code.
Use it with NodeJS only, for navigator or react-native I recommand you to use Webpack ;)
Not tested with react-native but if you still want to try it, it require babel 7 minimum, here is an example of a working .babelrc that I use:

{
  "presets": [
    "@babel/preset-env"
  ],
  "plugins": [
    [
      "module-resolver",
      {
        "root": [
          "."
        ],
        "alias": {
          "~": "./src"
        }
      }
    ],
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ],
    [
      "@babel/plugin-syntax-decorators",
      {
        "legacy": true
      }
    ],
    "@babel/plugin-transform-runtime",

    "babel-plugin-require-context-polyfill",

    "source-map-support",
  ],
  sourceMaps: true,
}

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

No branches or pull requests

1 participant