File tree Expand file tree Collapse file tree 6 files changed +29
-9
lines changed Expand file tree Collapse file tree 6 files changed +29
-9
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.10.4 (2022-11-14)
2
+
3
+ ` optimizerDeps ` should not process builtins, builtins will be processed in ` use-node.js.ts ` .
4
+
5
+ - 6436b49 fix: avoid built-in modules
6
+
1
7
## 0.10.3 (2022-11-09)
2
8
3
9
- ` optimizerDeps ` generate sourcemap by default vite-plugin-electron #70
Original file line number Diff line number Diff line change @@ -15,10 +15,10 @@ app.whenReady().then(() => {
15
15
} ,
16
16
} )
17
17
18
- if ( app . isPackaged ) {
19
- win . loadFile ( path . join ( __dirname , '../dist/index.html' ) )
20
- } else {
18
+ if ( process . env . VITE_DEV_SERVER_URL ) {
21
19
win . loadURL ( process . env . VITE_DEV_SERVER_URL )
22
20
win . webContents . openDevTools ( )
21
+ } else {
22
+ win . loadFile ( path . join ( __dirname , '../dist/index.html' ) )
23
23
}
24
24
} )
Original file line number Diff line number Diff line change 1
1
import './samples'
2
2
3
3
document . getElementById ( 'app' ) ! . innerHTML = `
4
- <h1>examples/nodeIntegration</h1>
4
+ <h1>Hi there 👋</h1>
5
+ <p>Now, you can use Electron and Node.js API in Renderer process.</p>
6
+ <pre>
7
+ import { ipcRenderer } from 'electron'
8
+ import fs from 'fs'
9
+ </pre>
5
10
`
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ app.whenReady().then(() => {
14
14
nodeIntegrationInWorker : true ,
15
15
}
16
16
} )
17
- if ( app . isPackaged ) {
18
- win . loadFile ( path . join ( __dirname , '../dist/index.html' ) )
19
- } else {
17
+ if ( process . env . VITE_DEV_SERVER_URL ) {
20
18
win . loadURL ( process . env . VITE_DEV_SERVER_URL )
21
19
win . webContents . openDevTools ( )
20
+ } else {
21
+ win . loadFile ( path . join ( __dirname , '../dist/index.html' ) )
22
22
}
23
23
24
24
const worker = new Worker ( path . join ( __dirname , './worker.js' ) )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vite-plugin-electron-renderer" ,
3
- "version" : " 0.10.3 " ,
3
+ "version" : " 0.10.4 " ,
4
4
"description" : " Support use Node.js API in Electron-Renderer" ,
5
5
"main" : " plugins/index.mjs" ,
6
6
"types" : " plugins" ,
Original file line number Diff line number Diff line change @@ -19,9 +19,14 @@ export type DepOptimizationConfig = {
19
19
}
20
20
21
21
const cjs_require = createRequire ( import . meta. url )
22
+ const builtins = [
23
+ ...builtinModules ,
24
+ ...builtinModules . map ( mod => `node:${ mod } ` ) ,
25
+ ]
26
+ const CACHE_DIR = '.vite-electron-renderer'
27
+
22
28
let root : string
23
29
let node_modules_path : string
24
- const CACHE_DIR = '.vite-electron-renderer'
25
30
26
31
export default function optimizer ( options : DepOptimizationConfig ) : Plugin {
27
32
return {
@@ -61,6 +66,10 @@ export default function optimizer(options: DepOptimizationConfig): Plugin {
61
66
deps . push ( { cjs : name } )
62
67
continue
63
68
}
69
+ if ( builtins . includes ( name ) ) {
70
+ // Process in './use-node.js.ts'
71
+ continue
72
+ }
64
73
const pkg = cjs_require ( path . join ( node_modules_path , name , 'package.json' ) )
65
74
if ( pkg ) {
66
75
// bare module
You can’t perform that action at this time.
0 commit comments