I
I
IDONTSUDO2020-05-12 20:16:20
React
IDONTSUDO, 2020-05-12 20:16:20

React Webpack including some scripts depending on development mode?

5ebad7e6ac6b1577095681.png

I want this code to work for me. But the browser gives an error.

Uncaught ReferenceError: mp is not defined
    at Object.s (rage-rpc.min.js:1)
    at Module.eval (rage-rpc.min.js:1)
    at Module.eval (rage-rpc.min.js:1)
    at n (rage-rpc.min.js:1)
    at eval (rage-rpc.min.js:1)
    at eval (rage-rpc.min.js:1)
    at eval (rage-rpc.min.js:1)
    at eval (rage-rpc.min.js:1)
    at Object../node_modules/rage-rpc/dist/rage-rpc.min.js (main.js:1175)
    at __webpack_require__ (main.js:790)


Because mp is not a browser object (It is a game object, but that's another story). Is there a way other than wrapping mp in window to make this work?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IDONTSUDO, 2020-05-12
@IDONTSUDO

async function load() {
if(false){
let say = await import('../../RPC/index');
say.default()
}
}
load()
It worked.

M
mr_elk2015, 2021-01-26
@mr_elk2015

I myself encountered this problem on the rage, the easiest way in this case is to raise the Rest API and already from React through (approx.) Axios make a request to the api, from where to pick up any object from the server.
Server (api):
6010300da2b55541121465.png
Client (react):
6010303755171880605332.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question