7

according to a previously asked question How to blacklist specific node_modules of my package's dependencies in react-native's packager?

I created such a file in my project root directory. Name: rn-cli.config.js

My file content:

var blacklist = require('react-native/packager/blacklist');

var config = {
  getBlacklistRE(platform) {
    return blacklist(platform, [
      /node_modules\/react\/lib\/TouchHistoryMath.js/
    ]);
  }
};

module.exports = config;

I am trying to target the Module directly since it's the only one causing an error where two modules have the same name.

Now when I try to re-run my project (start with xCode) i still get the same duplicate error for the same module.

Do I need to do something else than just simply creating that file?

Community
  • 1
  • 1
noa-dev
  • 3,561
  • 9
  • 34
  • 72
  • 1
    A bit late, but in case others stumble on this; the `platform` parameter is no longer used. Removing it from the call to the `blacklist` fn should fix it. – Vegard Feb 09 '17 at 10:41
  • Any update here, I removed platform but it still doesnt works – sunny Jul 17 '18 at 11:54
  • Try this https://stackoverflow.com/questions/41813211/how-to-make-react-native-packager-ignore-certain-directories/41963217#41963217 – Arun Jul 17 '18 at 12:14
  • @Arun Already tried that. Its not working. Seems like whatever regex I am providing, it gets silently ignored. I am working with latest version of react-native. – sunny Jul 17 '18 at 12:38
  • @sunny I don't remember the solution that I had and if I had any. It was a testproject 2 years ago. Hope you will find something – noa-dev Jul 18 '18 at 05:49

1 Answers1

0

Have you tried using something like this:

    const modulePaths = require('./modulePaths');
    const resolve = require('path').resolve;
    const fs = require('fs');

    const config = {
    getTransformOptions: () => {
        const moduleMap = {};
        modulePaths.forEach(path => {
        if (fs.existsSync(path)) {
            moduleMap[resolve(path)] = true;
        }
        });
        return {
        preloadedModules: moduleMap,
        transform: { inlineRequires: { blacklist: moduleMap } },
        };
    },
    };

    module.exports = config;

Here's a link to the docs.

Rodrigo Mata
  • 1,779
  • 2
  • 14
  • 23
  • how to get modulePaths. I have follow the same steps which is mention on document, but in doc not mention the this file.https://facebook.github.io/react-native/docs/performance#updating-the-configjs – Harleen Kaur Arora Jun 07 '19 at 10:39