File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.13.13 (2023-03-29)
2
+
3
+ - 8c044c9 fix: ` require ` instead ` await import `
4
+
1
5
## 0.13.12 (2023-03-28)
2
6
3
7
- 7f6b3a4 fix: correctly path
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vite-plugin-electron-renderer" ,
3
- "version" : " 0.13.12 " ,
3
+ "version" : " 0.13.13 " ,
4
4
"description" : " Support use Node.js API in Electron-Renderer" ,
5
5
"main" : " ./dist/index.js" ,
6
6
"types" : " ./dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
import fs from 'node:fs'
2
2
import path from 'node:path'
3
3
import { fileURLToPath } from 'node:url'
4
- import { builtinModules } from 'node:module'
4
+ import { createRequire , builtinModules } from 'node:module'
5
5
import type {
6
6
Alias ,
7
7
BuildOptions ,
@@ -12,6 +12,7 @@ import type { RollupOptions } from 'rollup'
12
12
import libEsm from 'lib-esm'
13
13
14
14
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
15
+ const require = createRequire ( import . meta. url )
15
16
const builtins = builtinModules . filter ( m => ! m . startsWith ( '_' ) ) ; builtins . push ( ...builtins . map ( m => `node:${ m } ` ) )
16
17
const electronBuiltins = [ 'electron' , ...builtins ]
17
18
const PACKAGE_PATH = path . join ( __dirname , '..' )
@@ -141,7 +142,7 @@ async function buildResolve(options: RendererOptions) {
141
142
if ( typeof result === 'string' ) {
142
143
snippets = result
143
144
} else if ( result && typeof result === 'object' && result . platform === 'node' ) {
144
- const { exports } = libEsm ( { exports : Object . getOwnPropertyNames ( await import ( name ) ) } )
145
+ const { exports } = libEsm ( { exports : Object . getOwnPropertyNames ( /* await import */ require ( name ) ) } )
145
146
snippets = `
146
147
// If a module is a CommonJs, use the \`require()\` load it can bring better performance,
147
148
// especially it is a C/C++ module, this can avoid a lot of trouble.
You can’t perform that action at this time.
0 commit comments