How to make the reaction of the native packer to ignore certain directories

Problem:

My project has @providesModule naming collisionwhen trying to run react-native run-iosfrom the command line. It conflicts with the auto- dist/generated dir , which is created by another npm package, esdoc. I would like to be able to save this auto-generated directory and just make it ignore the directory to respond to my own packer dist/.

Error message:

[01/23/2017, 13:17:07] <START> Building Haste Map
    Failed to build DependencyGraph: @providesModule naming collision:
      Duplicate module name: ann
      Paths: /Users/thurt/projects/example/package.json collides with /Users/thurt/projects/example/dist/esdoc/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
  Duplicate module name: ann
  Paths: /Users/thurt/projects/example/package.json collides with /Users/thurt/projects/example/dist/esdoc/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (/Users/thurt/projects/example/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:158:13)
    at p.getName.then.name (/Users/thurt/projects/example/node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:133:31)
+14
source share
1 answer

The configuration for this tends to vary between RN versions. Below are instructions for creating a configuration file, loading a configuration file, and clearing the cache.

For React Native> = 0.59

metro.config.js :

const blacklist = require('metro-config/src/defaults/blacklist');

// blacklist is a function that takes an array of regexes and combines
// them with the default blacklist to return a single regex.

module.exports = {
  resolver: {
    blacklistRE: blacklist([/dist\/.*/])
  }
};

React Native> = 0,57, <0,59

rn-cli.config.js :

const blacklist = require('metro-config/src/defaults/blacklist');

// blacklist is a function that takes an array of regexes and combines
// them with the default blacklist to return a single regex.

module.exports = {
  resolver: {
    blacklistRE: blacklist([/dist\/.*/])
  }
};

React Native> = 0,52, <0,57

rn-cli.config.js :

const blacklist = require('metro').createBlacklist;

module.exports = {
  getBlacklistRE: function() {
    return blacklist([/dist\/.*/]);
  }
};

React Native> = 0,46, <0,52.

rn-cli.config.js :

const blacklist = require('metro-bundler').createBlacklist;

module.exports = {
  getBlacklistRE: function() {
    return blacklist([/dist\/.*/]);
  }
};

React Native <0,46.

rn-cli.config.js :

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

module.exports = {
  getBlacklistRE: function() {
    return blacklist([/dist\/.*/]);
  }
};

<0.59

CLI , --config:

react-native run-ios --config=rn-cli.config.js

( RN> = 0,59, metro.config.js)

:

, , , ; --reset-cache

+30

Source: https://habr.com/ru/post/1667575/


All Articles