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

Need a separate config file from .watchmanconfig #14

Open
cooperka opened this issue Jun 30, 2017 · 4 comments
Open

Need a separate config file from .watchmanconfig #14

cooperka opened this issue Jun 30, 2017 · 4 comments

Comments

@cooperka
Copy link

cooperka commented Jun 30, 2017

Background

In my project, I have a React Native library with an example app inside of it (a very standard setup). I'd like to link the root library into the example app's node_modules, which is easy to do with wml (yay!) simply by adding the example dir to the ignore_dirs array (to prevent infinite recursion) and running wml start.

Problem

The problem comes when I want to run unit tests in the main library, or npm start in the example app. The React Native packager needs to be able to find the example app, but it can't because it's ignored! I also can't add node_modules to ignore_dirs because then none of the unit tests would be able to find any modules in the root library. This leads to @providesModule conflicts because there are duplicate node_modules being found which were copied by wml into the example app.

I end up getting this error when trying to run the example app on a device (because the entire example directory is ignored by watchman):

Cannot find entry file index.ios.js in any of the roots: ["/Users/me/myApp/example"]

And this error on the node server at the same time as the error above:

error: bundling: Error
    at DependencyGraph._getAbsolutePath (/Users/me/myApp/example/node_modules/react-native/packager/src/node-haste/index.js:272:11)
    at DependencyGraph.getDependencies (/Users/me/myApp/example/node_modules/react-native/packager/src/node-haste/index.js:216:26)
    ...

Desired solution

I want wml to ignore node_modules and example when copying, but I don't want the unit tests or the React Native packager to ignore either of those directories. Is there any way to get finer-grained control over which files wml ignores vs. which ones watchman ignores?

I know wml uses watchman behind the scenes so maybe this isn't even possible. Any ideas would be appreciated. Thanks!

@sytolk
Copy link

sytolk commented Mar 2, 2018

Why not remove the example dir from the ignore_dirs array. And delete example dir with postinstall script like:
lib_dir_project/example_dir_project/package.json

"scripts": {
        "postinstall": "rm -rf ./node_modules/lib_dir_project/node_modules ./node_modules/lib_dir_project/example_dir_project",
},
"dependencies": {
        "lib_dir_project": "file:../",
}

@cooperka
Copy link
Author

cooperka commented Mar 2, 2018

That's what I've ended up doing actually. It's not perfect but it works (without wml).

@sytolk
Copy link

sytolk commented Mar 2, 2018

@cooperka my bad...
I have the same project structure and load library like this:
https://github.com/wix/react-native-navigation/blob/master/old-example-redux/package.json#L10

this is my script

"scripts": {
        "postinstall": "rm -rf ./node_modules/react-native-dlc-triplog/node_modules ./node_modules/react-native-dlc-triplog/TripApp",
        "wml:add": "node ./node_modules/wml/src/cli/index.js add ../ ./node_modules/react-native-dlc-triplog/",
        "wml:start": "node ./node_modules/wml/src/cli/index.js start",
        "wml:rm": "node ./node_modules/wml/src/cli/index.js rm all",
        "wml:list": "node ./node_modules/wml/src/cli/index.js list",
},
"devDependencies": {
  "wml": "^0.0.83",
},

I cannot set TripApp in .watchmanconfig and after npm run wml:start my TripApp folder is copied into dest library -> /node_modules/TripApp/node_modules..
maybe the only solution for this problem is to move out TripApp folder?

@Karsens
Copy link

Karsens commented Dec 11, 2021

To solve this I added an ignore key to every wml config file object, where you can list folders to ignore. This is read when copying files, so it doesn't copy these folders.

I forked this package and put it here: https://github.com/Code-From-Anywhere/dryduck

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

3 participants