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

packager: a way to blacklist some folders/files in a RN app? #7271

Closed
gre opened this issue Apr 28, 2016 · 12 comments
Closed

packager: a way to blacklist some folders/files in a RN app? #7271

gre opened this issue Apr 28, 2016 · 12 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@gre
Copy link
Contributor

gre commented Apr 28, 2016

Hi,
I have some folders under my root app like for instance a standalone node project that are not used by the app but for something else. How can I tell the packager to ignore these? It breaks when packager try to read the content of node_modules of that sub project, it shouldn't have enter there in the first place (because I never depend on it from any of the RN app jsbundle !!)

@radko93
Copy link
Contributor

radko93 commented Apr 28, 2016

There is a blacklist.js in react-native/packager.
Make a rn-cli.config.js in your project root and do something like this:

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

var config = {
  getBlacklistRE(platform) {
    return blacklist(platform, [
      /node_modules\/my-package\/excluded-directory\/.*/
    ]);
  }
};

module.exports = config;

@gre
Copy link
Contributor Author

gre commented Apr 28, 2016

thanks @radko93 !!

@dukeflyheli
Copy link

The code above is outdated or was incorrect, getBlacklistRE and blacklist do not take any parameters.

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

var config = {
getBlacklistRE() {
return blacklist([
/node_modules/my-package/excluded-directory/.*/
]);
}
};

module.exports = config;`

@kirkstrobeck
Copy link

I was suffering the same thing at #12582

My code ended up being

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

module.exports = {
  getBlacklistRE: () => blacklist([
    /coverage\/.*/,
  ]),
};

and my package.json start script became

"start": "react-native run-ios --config=rn-cli.config.js",

@alinz
Copy link

alinz commented Jul 6, 2017

blacklist does not exist anymore in react-native 46 :( so after a little bit of research, i found out that we have to use metro-bundler/build/blacklist instead of react-native/packager/blacklist.

@rcorrie
Copy link

rcorrie commented Jul 7, 2017

thanks @alinz that works for me

@azundo
Copy link

azundo commented Aug 11, 2017

As of react-native 47 I have to do something like:

const metroBundler = require('metro-bundler');

module.exports = {
  getBlacklistRE: function() {
    return metroBundler.createBlacklist([/coverage\/.*/]);
  }
};

@samuela
Copy link

samuela commented Sep 19, 2017

@azundo That doesn't work for me as of react-native 0.48.3 and metro-bundler 0.11.0: facebook/metro#58

@nicolascouvrat
Copy link

@samuela
Seems to work that way now (yey, folder changes...)

const blacklist = require('metro-bundler/src/blacklist')
var config = {
  getBlackListRE() {
    return blacklist([ 
      // your folders here
    ]);
  }
};

module.exports = config;

@esutton
Copy link

esutton commented Feb 20, 2018

( Correction: I had wrong case Change getBlackListRE -> getBlacklistRE )

After trying most all of the half-dozen above variations...

blacklist du jour

  • 2018 February 20 answer that works with RN 0.53

const blacklist = require('metro/src/blacklist');

const config = {
  getBlackListRE() {   //  <----  *** Error here : Change getBlackListRE -> getBlacklistRE
    // Do not include  /react-codemod folder in packager
    return blacklist([
      /react-codemod\/.*/,
    ]);
  },
};

module.exports = config;

@theRealRobG
Copy link

@esutton
getBlackListRE -> getBlacklistRE

@esutton
Copy link

esutton commented Mar 5, 2018

@theRealRobG Thank you for taking the time to point out my mistake!

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests