vite-plugin-electron-renderer
Advanced tools
Comparing version 0.1.0 to 0.1.1
37
index.js
@@ -5,3 +5,3 @@ const fs = require('fs'); | ||
/** @type {import('./types').VitePluginElectronRenderer} */ | ||
/** @type {import('.').VitePluginElectronRenderer} */ | ||
module.exports = function (options = {}) { | ||
@@ -39,3 +39,6 @@ const { resolve } = options; | ||
generateESModule(cacheDir, resolve); | ||
modifyAlias(config, Object.keys(resolve).map(moduleId => ({ [moduleId]: path.join(cacheDir, moduleId) }))); | ||
modifyAlias( | ||
config, | ||
Object.keys(resolve).map(moduleId => ({ [moduleId]: path.join(cacheDir, moduleId) })), | ||
); | ||
} | ||
@@ -72,13 +75,10 @@ }, | ||
/** @type {import('./types').GenerateESModule} */ | ||
function generateESModule( | ||
cacheDir, | ||
resolveDict, | ||
) { | ||
/** @type {import('.').GenerateESModule} */ | ||
function generateESModule(cacheDir, resolve) { | ||
// generate custom-resolve module file | ||
for (const [module, strOrFn] of Object.entries(resolveDict)) { | ||
for (const [module, strOrFn] of Object.entries(resolve)) { | ||
const moduleId = path.join(cacheDir, module + '.js'); | ||
const moduleContent = typeof strOrFn === 'function' ? strOrFn() : strOrFn; | ||
// for '@scope/name' module | ||
// supported nest module ('@scope/name') | ||
ensureDir(path.parse(moduleId).dir); | ||
@@ -90,10 +90,7 @@ // write custom-resolve | ||
/** @type {import('./types').ModifyAlias} */ | ||
function modifyAlias( | ||
config, | ||
aliaList, | ||
) { | ||
/** @type {import('.').ModifyAlias} */ | ||
function modifyAlias(config, aliaList) { | ||
if (!config.resolve) config.resolve = {}; | ||
let alias = config.resolve.alias || {}; | ||
let alias = config.resolve.alias || []; | ||
if (!Array.isArray(alias)) { | ||
@@ -111,3 +108,3 @@ // keep the the original alias | ||
/** @type {import('./types').ModifyOptimizeDepsExclude} */ | ||
/** @type {import('.').ModifyOptimizeDepsExclude} */ | ||
function modifyOptimizeDepsExclude(config, exclude) { | ||
@@ -120,3 +117,3 @@ if (!config.optimizeDeps) config.optimizeDeps = {}; | ||
/** @type {import('./types').ModifyRollupExternal} */ | ||
/** @type {import('.').ModifyRollupExternal} */ | ||
function modifyRollupExternal(config) { | ||
@@ -147,3 +144,3 @@ if (!config.build) config.build = {}; | ||
/** @type {import('./types').ModifyOptionsForElectron} */ | ||
/** @type {import('.').ModifyOptionsForElectron} */ | ||
function modifyOptionsForElectron(config) { | ||
@@ -177,6 +174,2 @@ // electron use `loadFile` load Renderer-process file | ||
function cleanUrl(url) { | ||
return url.replace(/\?.*$/s, '').replace(/#.*$/s, ''); | ||
} | ||
function ensureDir(dir) { | ||
@@ -183,0 +176,0 @@ if (!(fs.existsSync(dir) && fs.statSync(dir).isDirectory())) { |
{ | ||
"name": "vite-plugin-electron-renderer", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Use Electron and NodeJs API in Renderer-process", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
13728
0
218