Ignore transform when requiring JS scripts from Assets

#1

Hey there.

I want to use a WebView with custom injected JS to render charts in my “undetached” Expo app.

To do this, I thought I’d write my custom JS in a file that I would just place in the “assets” folder, and load at runtime through the Expo.Asset.fromModule() method mentioned in the doc.

However, I realised that Expo will try to transform that JS, instead of simply loading it as a string. I also tried, very naively, to change the extension to “txt” hoping it would bypass the transform but it doesn’t, instead it will not resolve the module at all.

So my question here is : can I bundle a vanilla JS file within my app to inject it, untouched, into RN’s WebView ?

Sorry if the information is easily available, I wasn’t able to find it.

Thanks

#2

Actually, I found a simple workaround that is sufficient in my case : I do the same thing, but instead of trying to load a JS file, I load an HTML that does not get transformed.

2 Likes
closed #3

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.