Skip to content

Commit 2f89866

Browse files
authored
Merge pull request #55 from electron-vite/v0.13.13
V0.13.13
2 parents 53e5c33 + f0f6a7e commit 2f89866

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.13.13 (2023-03-29)
2+
3+
- 8c044c9 fix: `require` instead `await import`
4+
15
## 0.13.12 (2023-03-28)
26

37
- 7f6b3a4 fix: correctly path

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-electron-renderer",
3-
"version": "0.13.12",
3+
"version": "0.13.13",
44
"description": "Support use Node.js API in Electron-Renderer",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
33
import { fileURLToPath } from 'node:url'
4-
import { builtinModules } from 'node:module'
4+
import { createRequire, builtinModules } from 'node:module'
55
import type {
66
Alias,
77
BuildOptions,
@@ -12,6 +12,7 @@ import type { RollupOptions } from 'rollup'
1212
import libEsm from 'lib-esm'
1313

1414
const __dirname = path.dirname(fileURLToPath(import.meta.url))
15+
const require = createRequire(import.meta.url)
1516
const builtins = builtinModules.filter(m => !m.startsWith('_')); builtins.push(...builtins.map(m => `node:${m}`))
1617
const electronBuiltins = ['electron', ...builtins]
1718
const PACKAGE_PATH = path.join(__dirname, '..')
@@ -141,7 +142,7 @@ async function buildResolve(options: RendererOptions) {
141142
if (typeof result === 'string') {
142143
snippets = result
143144
} 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)) })
145146
snippets = `
146147
// If a module is a CommonJs, use the \`require()\` load it can bring better performance,
147148
// especially it is a C/C++ module, this can avoid a lot of trouble.

0 commit comments

Comments
 (0)