[RMMV] [SCRIPTING] HOW TO MAKE A MODULAR PLUGIN WORK WITH BROWSERS?

Posts

Pages: 1
I've figured out a way to create MV plugins, having them split into multiple files without any added inconvenience to the user (as far as installation goes). The problem is, because I use Node's require() function, the plugins just don't work on browsers.

I get an error message about how the browser doesn't recognize the require function. Other error messages then pop up as an extension of that one. Note that they don't show up when playtesting through the editor.

Is there a way I can solve this without going file by file, turning my plugin into a monolithic one?
There's a tool called webpack that does the monolithing for you (and produces something semi incomprehensible as a side effect)

Or you could look at PluginManager.loadScript and copy that way of adding script tags to the DOM dynamically to get the browser to load for you.
Using PluginManager.loadScript would require me to go through each file, so that I wouldn't fetch my custom classes through module.exports.

I've tried webpack and RollupJS, but all I managed to get is a barely-edited version of the main file that imports the other files. I haven't managed to find any tutorials on using those for MV plugins, either
Pages: 1