Releases: electron-vite/vite-plugin-electron
Releases · electron-vite/vite-plugin-electron
v0.29.0
Please refer to CHANGELOG.md for details.
v0.28.8
v0.28.7
v0.28.6
Please refer to CHANGELOG.md for details.
v0.28.5
v0.28.4
Please refer to CHANGELOG.md for details.
v0.28.3
Please refer to CHANGELOG.md for details.
v0.28.2
Please refer to CHANGELOG.md for details.
v0.28.1
Please refer to CHANGELOG.md for details.
v0.28.0
Please refer to CHANGELOG.md for details.
Migration to v0.28.0
- No break changes. Just need to define
"type": "module"
in package.json for supportsesm
:) - By the way. Recommend using the
vite-plugin-electron/simple
API. It is simpler, and the main difference is its adaptation topreload
scripts. - electron@28 Preload scripts 👉 limitations.
Preload scripts
In most cases, use cjs
format
`require()` can usable matrix
@see - https://github.com/electron/electron/blob/v30.0.0-nightly.20240104/docs/tutorial/esm.md#preload-scripts
┏———————————————————————————————————┳——————————┳———————————┓
│ webPreferences: { } │ import │ require │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: false(undefined) │ ✘ │ ✔ │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: true │ ✔ │ ✔ │
┠———————————————————————————————————╂——————————╂———————————┨
│ sandbox: true(undefined) │ ✘ │ ✔ │
┠———————————————————————————————————╂——————————╂———————————┨
│ sandbox: false │ ✔ │ ✘ │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: false │ ✘ │ ✔ │
│ sandbox: true │ │ │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: false │ ✔ │ ✘ │
│ sandbox: false │ │ │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: true │ ✘ │ ✔ │
│ sandbox: true │ │ │
┠———————————————————————————————————╂——————————╂———————————┨
│ nodeIntegration: true │ ✔ │ ✔ │
│ sandbox: false │ │ │
┗———————————————————————————————————┸——————————┸———————————┛
- import(✘): SyntaxError: Cannot use import statement outside a module
- require(✘): ReferenceError: require is not defined in ES module scope, you can use import instead
Built format
This is just the default behavior, and you can modify them at any time through custom config in the vite.config.js
{ "type": "module" }
┏————————————————————┳——————————┳———————————┓
│ built │ format │ suffix │
┠————————————————————╂——————————╂———————————┨
│ main process │ esm │ .js │
┠————————————————————╂——————————╂———————————┨
│ preload scripts │ cjs │ .mjs │ diff
┠————————————————————╂——————————╂———————————┨
│ renderer process │ - │ .js │
┗————————————————————┸——————————┸———————————┛
{ "type": "commonjs" } - default
┏————————————————————┳——————————┳———————————┓
│ built │ format │ suffix │
┠————————————————————╂——————————╂———————————┨
│ main process │ cjs │ .js │
┠————————————————————╂——————————╂———————————┨
│ preload scripts │ cjs │ .js │ diff
┠————————————————————╂——————————╂———————————┨
│ renderer process │ - │ .js │
┗————————————————————┸——————————┸———————————┛