vite-plugin-electron-renderer
Advanced tools
Comparing version 0.14.3 to 0.14.4
@@ -8,4 +8,72 @@ "use strict"; | ||
const esbuild = require("esbuild"); | ||
const libEsm = require("lib-esm"); | ||
const os = require("node:os"); | ||
const keywords = [ | ||
"break", | ||
"case", | ||
"catch", | ||
"class", | ||
"const", | ||
"continue", | ||
"debugger", | ||
"default", | ||
"delete", | ||
"do", | ||
"else", | ||
"export", | ||
"extends", | ||
"false", | ||
"finally", | ||
"for", | ||
"function", | ||
"if", | ||
"import", | ||
"in", | ||
"instanceof", | ||
"new", | ||
"null", | ||
"return", | ||
"super", | ||
"switch", | ||
"this", | ||
"throw", | ||
"true", | ||
"try", | ||
"typeof", | ||
"var", | ||
"void", | ||
"while", | ||
"with" | ||
]; | ||
function libEsm(options) { | ||
const { | ||
window, | ||
require: require2, | ||
exports: members = [], | ||
conflict = "" | ||
} = options; | ||
const _M_ = "_M_" + conflict; | ||
const windowSnippet = window == null ? "" : `const ${_M_} = window["${window}"];`; | ||
const requireSnippet = require2 == null ? "" : ` | ||
import { createRequire } from "node:module"; | ||
const ${_M_} = createRequire(import.meta.url)("${require2}"); | ||
`.trim(); | ||
!members.includes("default") && members.push("default"); | ||
const alias = members.filter((member) => keywords.includes(member)).reduce((memo, keyword) => Object.assign(memo, { [keyword]: `keyword_${keyword + conflict}` }), {}); | ||
const exportsSnippet = ` | ||
${members.map((member) => { | ||
const LV = alias[member] ? `const ${alias[member]}` : `export const ${member}`; | ||
const RV = member === "default" ? `${_M_}.default || ${_M_}` : `${_M_}.${member}`; | ||
return `${LV} = ${RV};`; | ||
}).join("\n")} | ||
export { | ||
${Object.entries(alias).map(([member, alias2]) => `${alias2} as ${member},`).join("\n ")} | ||
}; | ||
`.trim(); | ||
return { | ||
window: windowSnippet, | ||
require: requireSnippet, | ||
exports: exportsSnippet, | ||
keywords: alias | ||
}; | ||
} | ||
function relativeify(relative) { | ||
@@ -12,0 +80,0 @@ if (relative === "") { |
{ | ||
"name": "vite-plugin-electron-renderer", | ||
"version": "0.14.3", | ||
"version": "0.14.4", | ||
"description": "Support use Node.js API in Electron-Renderer", | ||
@@ -28,8 +28,6 @@ "main": "./dist/index.js", | ||
}, | ||
"dependencies": { | ||
"lib-esm": "~0.4.0" | ||
}, | ||
"devDependencies": { | ||
"electron": "^24.3.1", | ||
"esbuild": "^0.17.19", | ||
"lib-esm": "^0.4.0", | ||
"node-fetch": "^3.3.1", | ||
@@ -36,0 +34,0 @@ "rollup": "^3.22.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43020
0
894
10
- Removedlib-esm@~0.4.0
- Removedlib-esm@0.4.2(transitive)