I am trying to transition an electron application built with create-react-app
to ViteJS
. So far, I've managed to get a lot of things fixed, but I'am having an issue with one of our dependencies.
My project uses an internal library built in golang for performance reasons, and this library is called from the main process of the electron application. However, I get the following error when running vite build
.
[commonjs--resolver] Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
This happens with the following line
module.exports = require('./build/Release/goapi.node');
goapi.node
is the compiled library. This library is compiled using node-gyp, and I'm 100% sure that the compilation is right, because it is working with the current setup that uses create-react-app.
Is there a plugin to add in the vite
config to support importing native modules? If not, how can I get around this problem?