Skip to content

Releases: electron-vite/vite-plugin-electron

v0.29.0

16 Nov 13:02
e1eb3c7
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#260

v0.28.8

20 Sep 09:10
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#236

Contributors:

v0.28.7

27 Apr 12:58
f6dabc3
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#235

Contributors:

v0.28.6

21 Apr 01:20
f361cb6
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#232

v0.28.5

19 Apr 04:43
a9dbd69
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#228

Contributors:

v0.28.4

17 Mar 02:18
06d8144
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#224

v0.28.3

17 Mar 01:51
20a9537
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#222

v0.28.2

11 Feb 01:55
6f50f42
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#212

v0.28.1

06 Feb 07:49
bf215e9
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#203

v0.28.0

13 Jan 02:47
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

#198


Migration to v0.28.0

  • No break changes. Just need to define "type": "module" in package.json for supports esm :)
  • By the way. Recommend using the vite-plugin-electron/simple API. It is simpler, and the main difference is its adaptation to preload 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    │
┗————————————————————┸——————————┸———————————┛