Skip to content

Commit 14684ba

Browse files
authored
Merge pull request #94 from electron-vite/v0.10.2
V0.10.2
2 parents 4e730a7 + 5515043 commit 14684ba

File tree

28 files changed

+838
-735
lines changed

28 files changed

+838
-735
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.10.2 (2022-10-24)
2+
3+
1. Remove Vite `3.2.0` | #90
4+
2. ad9bb3c refactor(electron-renderer)!: remove `options.resolve()`, use 'lib-esm' for resolve Node.js modules and `electron` | vite-plugin-electron-renderer
5+
3. b500039 feat(electron-renderer): support `optimizeDeps` for Electron-Renderer 🚀
6+
4. f28e66b faet(outDir)!: `dist/electron` -> `dist/electron` | vite-plugin-electron
7+
18
## 0.10.1 (2022-10-12)
29

310
- 59a24df fix(electron-renderer): use `createRequire()` instead of `import()` 🐞

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*/dist-electron

examples/custom-start-electron-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"electron-builder": "^23.1.0",
2121
"typescript": "^4.7.4",
2222
"vite-plugin-electron": "workspace:*",
23-
"vite": "^3.2.0-beta.0"
23+
"vite": "^3.1.8"
2424
}
2525
}

examples/custom-start-electron-app/vite.config.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import { defineConfig } from 'vite'
33
import electron from 'vite-plugin-electron'
44

55
fs.rmSync('dist', { recursive: true, force: true })
6-
const cmds = process.argv.slice(2)
7-
const isdev = !cmds.length || cmds.includes('dev') || cmds.includes('serve')
86

97
export default defineConfig({
108
plugins: [
119
electron({
1210
entry: 'electron/main.ts',
13-
onstart: isdev ? startup => {
11+
onstart: options => {
1412
/** Start Electron App */
15-
startup(['.', '--no-sandbox'])
16-
} : undefined,
13+
options.startup(['.', '--no-sandbox'])
14+
},
1715
}),
1816
],
1917
})

examples/nodeIntegration/electron-builder.json5

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
output: "release/${version}",
1111
buildResources: "electron/resources",
1212
},
13-
files: ["dist"],
13+
files: [
14+
"dist",
15+
"dist-electron"
16+
],
1417
win: {
1518
target: [
1619
{

examples/nodeIntegration/electron/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ app.whenReady().then(() => {
1616
})
1717

1818
if (app.isPackaged) {
19-
win.loadFile(path.join(__dirname, '../index.html'))
19+
win.loadFile(path.join(__dirname, '../dist/index.html'))
2020
} else {
2121
win.loadURL(process.env.VITE_DEV_SERVER_URL)
2222
win.webContents.openDevTools()

examples/nodeIntegration/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-plugin-electron-node-integration",
33
"version": "0.0.0",
4-
"main": "dist/electron/main.js",
4+
"main": "dist-electron/main.js",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/electron-vite/vite-plugin-electron.git",
@@ -26,9 +26,8 @@
2626
"execa": "^6.1.0",
2727
"got": "^12.1.0",
2828
"node-fetch": "^3.2.8",
29+
"vite": "^3.1.8",
2930
"vite-plugin-electron": "workspace:*",
30-
"vite-plugin-electron-renderer": "workspace:*",
31-
"vite-plugin-esmodule": "^1.4.1",
32-
"vite": "^3.2.0-beta.0"
31+
"vite-plugin-electron-renderer": "workspace:*"
3332
}
3433
}

examples/nodeIntegration/vite.config.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fs from 'fs'
22
import { defineConfig } from 'vite'
33
import electron from 'vite-plugin-electron'
44
import renderer from 'vite-plugin-electron-renderer'
5-
import esmodule from 'vite-plugin-esmodule'
65
import pkg from './package.json'
76

87
fs.rmSync('dist', { recursive: true, force: true })
@@ -15,13 +14,17 @@ export default defineConfig({
1514
renderer({
1615
// Enables use of Node.js API in the Renderer-process
1716
nodeIntegration: true,
18-
// Explicitly specify external modules
19-
resolve: () => ['serialport', 'sqlite3'],
17+
// Like Vite's pre bundling
18+
optimizeDeps: {
19+
include: [
20+
'serialport', // cjs(C++)
21+
'electron-store', // cjs
22+
'execa', // esm
23+
'got', // esm
24+
'node-fetch', // esm
25+
],
26+
},
2027
}),
21-
// If an npm package is a pure ESM format package,
22-
// and the packages it depends on are also in ESM format,
23-
// then put it in `optimizeDeps.exclude` and it will work normally.
24-
esmodule(['execa', 'got', 'node-fetch']),
2528
],
2629
build: {
2730
minify: false,
@@ -30,6 +33,9 @@ export default defineConfig({
3033
},
3134
},
3235
optimizeDeps: {
36+
// If an npm package is a pure ESM format package,
37+
// and the packages it depends on are also in ESM format,
38+
// then put it in `optimizeDeps.exclude` and it will work normally.
3339
// exclude: ['only-support-pure-esmodule-package'],
3440
},
3541
})

examples/quick-start/electron/preload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ function domReady(condition: DocumentReadyState[] = ['complete', 'interactive'])
1515
const safeDOM = {
1616
append(parent: HTMLElement, child: HTMLElement) {
1717
if (!Array.from(parent.children).find(e => e === child)) {
18-
return parent.appendChild(child)
18+
parent.appendChild(child)
1919
}
2020
},
2121
remove(parent: HTMLElement, child: HTMLElement) {
2222
if (Array.from(parent.children).find(e => e === child)) {
23-
return parent.removeChild(child)
23+
parent.removeChild(child)
2424
}
2525
},
2626
}

examples/quick-start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"electron-builder": "^23.1.0",
2121
"typescript": "^4.7.4",
2222
"vite-plugin-electron": "workspace:*",
23-
"vite": "^3.2.0-beta.0"
23+
"vite": "^3.1.8"
2424
}
2525
}

0 commit comments

Comments
 (0)