vite-plugin-electron-renderer
Advanced tools
Changelog
0.13.11 (2023-03-27)
__cjs_require
avoid esbuild parse require
Changelog
0.13.8 (2023-03-26)
.js
-> .mjs
0.13.8
is very compact, keeping only the API for handling C/C++
modules.
renderer(options: RendererOptions)
export interface RendererOptions {
/**
* Explicitly tell Vite how to load modules, which is very useful for C/C++ modules.
* Most of the time, you don't need to use it when a module is a C/C++ module, you can load them by return `{ platform: 'node' }`.
*
* If you know exactly how Vite works, you can customize the return snippets.
* `e.g.`
* ```js
* renderer({
* resolve: (id) => `const lib = require("${id}");\nexport default lib.default || lib;`
* })
* ```
*
* @experimental
*/
resolve?: {
[id: string]: (() => string | { platform: 'browser' | 'node' } | Promise<string | { platform: 'browser' | 'node' }>)
}
}
Here is an example using serialport
import renderer from 'vite-plugin-electron-renderer'
export default {
plugins: [
renderer({
resolve: {
serialport: () => ({ platform: 'node' }),
// Equivalent to
// serialport: () => `const lib = require("serialport");\nexport default lib.default || lib;`
},
}),
],
}
Changelog
0.13.7 (2023-03-25)
__esModule
cjs
, external
. add freeze
, ignore
.resolve.alias
commentscjs
format by default with improvements to esm
.external
to be compatible with the esm
build format.Changelog
0.13.6 (2023-03-24)
Since 0.13.6
, Pre-Bundling have been greatly improved and Pure-JavaScript/Node.js modules no longer require any configuration - out of the box.
C/C++ modules, however, still require explicit configuration.
export default {
plugins: [
renderer({
optimizeDeps: {
resolve(args) {
if (args.path === 'serialport') {
return { platform: 'node' } // C/C++ module
}
},
},
}),
],
}
Changelog
0.13.5 (2023-03-23)
options.optimizer
-> options.optimizeDeps
Changelog
0.13.4 (2023-03-22)
.vite
cache.vite
cache