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.

HAUL does not include 'assets' of other react-native modules

See original GitHub issue

Current Behavior

React Native app, where used library/module/package with own assets. (In my case OTF fonts) At the current moment font files simply ignored by webpack and untouched.

folder structure of the module:

node_modules/@example/module
├── assets
│   └── fonts
│       └── native
│           ├── ExampleHeadline-Bold.otf
│           ├── ExampleHeadline-Bolditalic.otf
│           ├── ExampleHeadline-Light.otf
│           ├── ExampleHeadline-LightItalic.otf
│           ├── ExampleSans-Bold.otf
│           ├── ExampleSans-BoldItalic.otf
│           ├── ExampleSans-Light.otf
│           ├── ExampleSans-LightItalic.otf
│           ├── ExampleSans-Medium.otf
│           ├── ExampleSans-MediumItalic.otf
│           ├── ExampleSans-Regular.otf
│           └── ExampleSans-RegularItalic.otf
├── build
│   ├── native
│   │   ├── ActionIconArrowBottom
│   │   │   ├── index.js
│   │   │   └── index.js.map
...
├── package.json
├── readme.md

Expected Behavior

font files should be a part of the final bundle/resources.

Haul Configuration (webpack.haul.js)

default

Your Environment

Mac Os

software version
Haul 1.0.0-rc.7
react-native
node 8.xx
npm or yarn yarn

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
zamotanycommented, Oct 17, 2019

I have refined the test and noticed that in both cases (haul e2e test and repro project) the assets were extracted but to an incorrect path, so I thing that the Asset Resolver is calculating paths incorrectly.

1reaction
joeblynchcommented, Oct 16, 2019

@zamotany I think I have a reproduction case, which might help with debugging. I can see the issue when I produce an iOS bundle, but it appears to work when I produce an Android bundle. I can only reproduce when using a monorepo, where the dependency containing the asset is hoisted.

Repro steps:

  1. Download and extract the test project
  2. From the root directory: yarn
  3. cd packages/HaulTest
  4. yarn haul:ios

At the root of the project there should now be a bundle directory, which contains index.jsbundle, but no assets.

Next, run yarn haul:android. In bundle there should now be a index.android.bundle file, along with the image asset under bundle/drawable-mdpi/node_modules_reacttestimport_src_assets_haul_logo_box_only.png.

Talking with @rdy offline, he noticed that the asset is served by the dev server, but not bundled. Looking at index.jsbundle I notice the following code:

a.registerAsset({__packager_asset:!0,scales:[1],name:"haul_logo_box_only",type:"png",hash:"94d5b522d6ff976a852e4d2199488358",httpServerLocation:"../node_modules/react-test-import/src/assets",height:297,width:296})}));

I’m guessing the httpServerLocation being set may be why it’s working in the case where the dev server is being used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native with haul not working, throwing some loader ...
When i run react-native run-android i see the following error. Can someone help me please. ERROR Failed to compile. ./node_modules/native-base- ...
Read more >
Import local packages in React Native using NPM Link and ...
I was setting up a new React Native project and wanted to use some local packages which aren't available on an NPM repository....
Read more >
Applying and Organizing Styles in React Native - Manning
Each component supports a specific set of styles. Those styles may be applicable to other types of components. For example, the Text component ......
Read more >
Platform Specific Code
React Native provides a module that detects the platform in which the app is running. You can use the detection logic to implement ......
Read more >
React Native as a Service
Using Haul we could write a webpack configuration that would allow us to use packages from our internal infrastructure in the React Native...
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