question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assets in linked dependencies not loading.

See original GitHub issue

Current Behavior

I’m working on a React Native iOS app with linked dependencies. Image assets in these projects aren’t loading in <Image> components. If I copy the linked module’s source directly into my app’s node_modules folder, assets in these projects load fine.

Expected Behavior

Assets in linked dependencies load as if they were installed via yarn/npm install.

Haul Configuration (webpack.haul.js)

var path = require('path')

module.exports = ({ platform }, defaults) => {
  return {
    entry: `./index.${platform}.js`,
    devtool: 'source-map',
    resolve: {
      ...defaults.resolve,
      modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
    }
  }
};

I’ve added some logging to assetLoader.js which illustrates the issue (the root for my project for this example is /Users/erobinson/Code/company/reactnative-example/React/, with a symlinked dependency to a module located in /Users/erobinson/Code/javascript/reactnative-onboarding)…

filepath: /Users/erobinson/Code/javascript/reactnative-onboarding/images/arrow-left/arrow-left@1x.png
dirname: /Users/erobinson/Code/javascript/reactnative-onboarding/images/arrow-left
assets: assets/ios
url: ../../../javascript/reactnative-onboarding/images/arrow-left
dest: ../javascript/reactnative-onboarding/images/arrow-left/arrow-left@2x.png

The require for this image in my linked module results in a server request to /javascript/reactnative-onboarding/images/arrow-left/arrow-left@2x.png instead of looking in the assets/ios directory. I believe this is due to AssetLoader’s url property being assigned via path.relative, which is getting tripped up by symlinks outside of the containing app’s directory structure.

I guess my question is… is this something that should be handled via haul’s webpack config, or a bug in the assetLoader when dealing with symlinked resources?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
itaym2commented, Dec 13, 2017

Hi, I have a project using haul and symlinks for some packages, and I also encountered some weird issues when working with images.
After investigating the bundle created by haul I discovered that it used 2 different instances of AssetRegistry to register the images (one required from the app’s node_module dir, and one required from the linked package node_modules dir).

I configured webpack to always resolve react-native from the app’s node_modules folder, and it fixed the issue:

    resolve: {
        ...defaults.resolve,
        alias: {
                'react-native': path.resolve(__dirname, 'node_modules/react-native'),
        },

Not sure if this is the same problem you guys are having, but it’s worth giving it a shot.

0reactions
zamotanycommented, Nov 4, 2019

Closing due to inactivity. Feel free to create new issue if there’s still a problem with linked assets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter package dependency does not load it's own assets
1- create assets folder in same level of lib folder in flutter package and put your fonts or images. enter image description here....
Read more >
Can we load only required Asset's dependencies when ...
Let's say we have prefab A and B, their main Asset Bundle is C, and Asset Bundle C is dependent on Asset Bundle...
Read more >
Issue downloading assets from repository when deploying, ...
Issue downloading assets from repository when deploying, "Could not resolve dependencies for project". After INCIDENT-950, customers are ...
Read more >
wp_enqueue_script() | Function
Script Name Handle Script version License Image Cropper Image cropper (not used in core, see jcrop) Jcrop jcrop 0.9.12 MIT SWFObject swfobject 2.2‑20120417 MIT
Read more >
Dependency and resolution
A diagram showing both direct and indirect dependencies. When you add a package version as a dependency, that version is not necessarily the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found