klippa-app/nativescript-http

ReferenceError: Cannot access 'Cache' before initialization

mayerlench opened this issue · 1 comments

UPDATE
I tested this issue on a MAC/Android and it works, i dont get the error. The issue appears only on Windows

When I use the plugin in the webpack.config.js I get an error.
I can only get it to work if I pass the "replaceImageCache: false" config but then I don't get ImageCache

Nativescript 8
Flavor: react-nativescript
Windows/Android

const webpack = require("@nativescript/webpack");
const NativeScriptHTTPPlugin = require("@klippa/nativescript-http/webpack");


module.exports = (env) => {
	webpack.init(env);

	// Learn how to customize:
	// https://docs.nativescript.org/webpack
	webpack.chainWebpack(config => {

		config.plugin('NativeScriptHTTPPlugin').use(NativeScriptHTTPPlugin)

	});

	return webpack.resolveConfig();
};
// loading image in useEffect causes the error
    React.useEffect(() => {
        Http.getImage('https://cdn.britannica.com/60/217660-050-DBCC409A/cheddar-cheese-wedge.jpg')
            .then(async res => {
                const b64 = res.toBase64String('jpg', 1)
                console.log('🚀 ~ file: HomeScreen.tsx ~ line 16 ~ React.useEffect ~ b64', b64)
            })

    }, [])
System.err: ReferenceError: Cannot access 'Cache' before initialization
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:689)
System.err:     at com.tns.Runtime.run(Runtime.java:681)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
System.err:     at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7507)
System.err:     ... 9 more
Successfully synced application org.finitydevs.global on device R58M84FQC8N.

This issue is related to #50