Follow symlinks? #1
Comments
symlinks not working in React Native is one of the biggest RN complaints, so if my understanding is correct and this would fix that, this would be great! |
I think we won't have time to deal with this anytime soon unfortunately. I'd love to reopen once we have a strong case. |
Can we leave this open until it's resolved? This is a huge PITA for code sharing, and developing modules. I'm not sure what your looking for in terms of a strong case, but it's definitely a major pain point for me, and module developers. Currently I am trying to use lerna, and react-primitives to reorganize a project boilerplate to maximize code reuse, while maintaining upgradability by rn. Lerna works by symlinking and installing your packages in a mono repo, which is an incredibly helpful pattern for code reuse, and completely broken when the react native packager won't follow symlinks. |
Yeah, it should be open. We should find a fix but we are not actively invested in making this change ourselves right now. If the community can find a reasonable solution, we should merge it and make it work. |
I suspect it has to do with this line //...
this._moduleResolver = new ModuleResolver({
dirExists: filePath => {
try {
var stats = fs.lstatSync(filePath);
return stats.isDirectory() || stats.isSymbolicLink();
} catch (e) {}
return false;
},
// ... Though I am short on time for digesting how to get started with this project at the moment. I may have more time over the weekend for a proper PR. Or if someone else gets the chance to play around with it, that would be awesome. I never have enough time to accomplish all the things I want to do :( Edit: added "may", as the docs don't explicitly say you isDirectory() won't return true on a symlink, but I believe that is the case. Edit^2: https://github.com/ericwooley/symlinkTest You do need to explicitly check on OSX Sierra at least, not sure about linux or windows. Edit^3: the commit where the test was removed c1a8157 |
With |
The test was removed because it was already broken for a long time, unfortunately (I forgot to put that in the changeset description apparently). Now I realised I shouldn't have removed it completely, only make verify the broken behavior.
|
Interesting. I am pretty confused by this project, as I am not sure how it is imported by RN. But I manually edited this change into I also put a console log there to offer some insight, and it was definitely logging. So that line appears to be used by the react-native project while doing real work (as opposed to debugging). After much frustration with this issue, it ended up being easier to PR the libs i need to work with haul, rather than try to tackle this problem. I wish I had more time for this issue, but it appears to be a pretty rough one to solve, given what @jeanlauliac said. Hopefully this gets officially resolved soon. as I would much prefer to use the built in solution. On a side note, haul seems to have fixed all the symlink issues. Is there a downside to haul that you know of? It seems like it could be something that could be officially brought into the fold. |
Something that half-works is not symbolic linking but hard linking. You can't hard link directories, but you can use The only catch is that it seems in order to trigger rebundling I have to save the changed file (even though the action of saving isn't changing the contents of the file). |
@ericwooley Can you explain how your PR, haul, and storybooks (?) relate to the react-native symbolic link issue? |
@bleighb Haul is an alternative to the react-native packager that doesn't have issues with symlinks. They reference this issue because those PR's and issues are about issues with symlinking and the metro bundler. As to your cp -r issue, you might have better luck with rsync. Which is something I considered at one point. |
I'm in the lerna boat, too. The way I finally worked around this issue was to just explicitly add the packages in our monorepo to rn-cli.config.js, instead of having them as dependencies in the RN project's package.json (and symlinked into node_modules)
May have changed for Metro. HTH |
@kschzt I will have to try that solution tonight. I imagine that there will be more pressure on this issue once yarn workspaces are released. Until then, your solution may be the only way forward. |
I was unable to get things to work in something like a monorepo when trying @kschzt’s approach. If I have module
Why does it not check to see if the module exists inside the (react-native v0.45.0.) |
How are you importing your files
I'm not really sure how roots work in this context, but the way your importing may be a factor. Or are you using the |
@ericwooley 2(ish): Both the project and I are new to React Native (migrating an existing web app); I’m not familiar with the |
funny, it used to work ( |
This lerna project seems to work with Symlinks too (react-native 0.40) |
I have played with that too @AshCoolman, and it does seem to work, but setting it up in a similar way with other versions has not worked. |
@ericwooley My experience too |
Is the only solution at the moment to use haul or some custom shell scripts? |
(hopefully more dynamic) as suggested in: - facebook/metro#1 (comment)
* use path.join instead of [...].join('/') (with an extra `,` now gone) * use JavaScript Proxy object for `resolver.extraNodeModules` (hopefully more dynamic), as suggested in: - facebook/metro#1 (comment) * additional cleanup of comments & log message
Any up to date for this? Still can't use symlinked modules. |
Symlinked node_modules dir is the only way to deal with iCloud sync issues (renaming Please, fix this issue :( |
Yeah, I used it on a yarn link and it works well 🤙🏻 |
When metro resolves a file it looks for the file in a
Watchman
Node impl The node implementation deliberately doesn't follow symlinks for reasons unknown - maybe keeping parity with watchman? _fs().default.lstat(file, (err, stat) => {
activeCalls--;
if (!err && stat && !stat.isSymbolicLink()) { <-- symlinks are just skipped
if (stat.isDirectory()) {
search(file);
} else { A simple patch below would follow symlinks - but maybe other issues would arise because symlinks can point to files outside of the project roots. //_fs().default.lstat(file, (err, stat) => {
_fs().default.stat(file, (err, stat) => {
activeCalls--;
//if (!err && stat && !stat.isSymbolicLink()) {
if (!err && stat) {
if (stat.isDirectory()) {
search(file);
} else { |
@vjpr interesting - is this much different from the following PRs?
The Jest maintainers seem to have no sense of urgency around resolving this issue and do not seem interested in any solutions that only fix the problem for metro users without more robust handling for the larger jest ecosystem. |
Guys, do you know how to use symlinked files? Not repos. I have |
I am making a new ecosystem where I need to run the symlink component in the project. symlink are working with create-react-app with override some properties but it is not working on expo |
The package bundler for Expo/RN ( |
@kesha-antonov Add the parent dir of the |
rn-cli.config.js
I made symlink
i am getting same error
@vjpr it is not working by manually i am algo getting this error
|
@rafeca @davidaurelio @mjesun @jeanlauliac @cpojer and @haggholm can you help me in
|
any there to help me about import symlink
|
Locking this issue due to spam. Will reopen in the future. |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
I'm removing a test from
DependencyGraph-test
that looked like so, but wasn't actually working after I fixed problems with thefs
mocks:What is the expected behavior?
Reintroduce the test and verify symlinks work.
The text was updated successfully, but these errors were encountered: