Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-electron

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-electron - npm Package Compare versions

Comparing version 0.8.5 to 0.8.6

22

dist/build.js

@@ -1,14 +0,18 @@

import { build as viteBuild, } from 'vite';
import { checkPkgMain, createWithExternal, resolveBuildConfig, resolveRuntime, } from './config';
export async function build(config, viteConfig) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.build = void 0;
const vite_1 = require("vite");
const config_1 = require("./config");
async function build(config, viteConfig) {
if (config.preload) {
const preloadRuntime = resolveRuntime('preload', config, viteConfig);
await viteBuild(createWithExternal(preloadRuntime)(resolveBuildConfig(preloadRuntime)));
const preloadRuntime = (0, config_1.resolveRuntime)('preload', config, viteConfig);
await (0, vite_1.build)((0, config_1.createWithExternal)(preloadRuntime)((0, config_1.resolveBuildConfig)(preloadRuntime)));
}
const mainRuntime = resolveRuntime('main', config, viteConfig);
const ILCG = createWithExternal(mainRuntime)(resolveBuildConfig(mainRuntime));
const mainRuntime = (0, config_1.resolveRuntime)('main', config, viteConfig);
const ILCG = (0, config_1.createWithExternal)(mainRuntime)((0, config_1.resolveBuildConfig)(mainRuntime));
if (!ILCG.plugins)
ILCG.plugins = [];
ILCG.plugins.push(checkPkgMain.buildElectronMainPlugin(mainRuntime));
await viteBuild(ILCG);
ILCG.plugins.push(config_1.checkPkgMain.buildElectronMainPlugin(mainRuntime));
await (0, vite_1.build)(ILCG);
}
exports.build = build;

@@ -1,9 +0,16 @@

import fs from 'fs';
import path from 'path';
import { mergeConfig, normalizePath, } from 'vite';
import { resolveModules } from 'vite-plugin-electron-renderer/plugins/use-node.js';
export function resolveRuntime(proc, config, viteConfig) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkPkgMain = exports.createWithExternal = exports.resolveBuildConfig = exports.resolveRuntime = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const vite_1 = require("vite");
const use_node_js_1 = require("vite-plugin-electron-renderer/plugins/use-node.js");
function resolveRuntime(proc, config, viteConfig) {
return { proc, config, viteConfig };
}
export function resolveBuildConfig(runtime) {
exports.resolveRuntime = resolveRuntime;
function resolveBuildConfig(runtime) {
var _a;

@@ -48,8 +55,9 @@ const { proc, config, viteConfig } = runtime;

// Assign default dir
defaultConfig.build.outDir = normalizePath(`${viteConfig.build.outDir}/electron`);
return mergeConfig(defaultConfig, ((_a = config[proc]) === null || _a === void 0 ? void 0 : _a.vite) || {});
defaultConfig.build.outDir = (0, vite_1.normalizePath)(`${viteConfig.build.outDir}/electron`);
return (0, vite_1.mergeConfig)(defaultConfig, ((_a = config[proc]) === null || _a === void 0 ? void 0 : _a.vite) || {});
}
export function createWithExternal(runtime) {
exports.resolveBuildConfig = resolveBuildConfig;
function createWithExternal(runtime) {
const { proc, config, viteConfig } = runtime;
const { builtins, dependencies } = resolveModules(viteConfig.root, config[proc]);
const { builtins, dependencies } = (0, use_node_js_1.resolveModules)(viteConfig.root, config[proc]);
const modules = builtins.concat(dependencies);

@@ -83,10 +91,11 @@ return function withExternal(ILCG) {

}
export function checkPkgMain(runtime, electronMainBuildResolvedConfig) {
exports.createWithExternal = createWithExternal;
function checkPkgMain(runtime, electronMainBuildResolvedConfig) {
const mainConfig = electronMainBuildResolvedConfig;
const { config, viteConfig } = runtime;
const cwd = process.cwd();
const pkgId = path.join(cwd, 'package.json');
if (!fs.existsSync(pkgId))
const pkgId = path_1.default.join(cwd, 'package.json');
if (!fs_1.default.existsSync(pkgId))
return;
const distfile = normalizePath(path.resolve(mainConfig.root, mainConfig.build.outDir, path.parse(config.main.entry).name)
const distfile = (0, vite_1.normalizePath)(path_1.default.resolve(mainConfig.root, mainConfig.build.outDir, path_1.default.parse(config.main.entry).name)
// https://github.com/electron-vite/vite-plugin-electron/blob/5cd2c2ce68bb76b2a1770d50aa4164a59ab8110c/packages/electron/src/config.ts#L57

@@ -106,6 +115,7 @@ + '.js');

if (message) {
fs.appendFileSync(path.join(cwd, 'vite-plugin-electron.log'), message);
fs_1.default.appendFileSync(path_1.default.join(cwd, 'vite-plugin-electron.log'), message);
return message;
}
}
exports.checkPkgMain = checkPkgMain;
checkPkgMain.buildElectronMainPlugin = function buildElectronMainPlugin(runtime) {

@@ -112,0 +122,0 @@ return {

@@ -1,9 +0,16 @@

import { bootstrap } from './serve';
import { build } from './build';
import renderer from 'vite-plugin-electron-renderer';
import buildConfig from 'vite-plugin-electron-renderer/plugins/build-config';
export function defineConfig(config) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineConfig = void 0;
const serve_1 = require("./serve");
const build_1 = require("./build");
const vite_plugin_electron_renderer_1 = __importDefault(require("vite-plugin-electron-renderer"));
const build_config_1 = __importDefault(require("vite-plugin-electron-renderer/plugins/build-config"));
function defineConfig(config) {
return config;
}
export default function electron(config) {
exports.defineConfig = defineConfig;
function electron(config) {
const name = 'vite-plugin-electron';

@@ -13,5 +20,5 @@ return [

// Enable use Electron, Node.js API in Renderer-process
? renderer(config.renderer)
? (0, vite_plugin_electron_renderer_1.default)(config.renderer)
// There is also `buildConfig()` in `renderer()`
: [buildConfig()]),
: [(0, build_config_1.default)()]),
{

@@ -22,3 +29,3 @@ name: `${name}:serve`,

server.httpServer.on('listening', () => {
bootstrap(config, server);
(0, serve_1.bootstrap)(config, server);
});

@@ -36,3 +43,3 @@ },

async closeBundle() {
await build(config, viteConfig);
await (0, build_1.build)(config, viteConfig);
}

@@ -43,1 +50,2 @@ };

}
exports.default = electron;

@@ -1,5 +0,8 @@

import { spawn } from 'child_process';
import { build as viteBuild, mergeConfig, } from 'vite';
import { createWithExternal, resolveRuntime, resolveBuildConfig, checkPkgMain, } from './config';
export const loopbackHosts = new Set([
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bootstrap = exports.wildcardHosts = exports.loopbackHosts = void 0;
const child_process_1 = require("child_process");
const vite_1 = require("vite");
const config_1 = require("./config");
exports.loopbackHosts = new Set([
'localhost',

@@ -10,3 +13,3 @@ '127.0.0.1',

]);
export const wildcardHosts = new Set([
exports.wildcardHosts = new Set([
'0.0.0.0',

@@ -17,3 +20,3 @@ '::',

function resolveHostname(hostname) {
return loopbackHosts.has(hostname) || wildcardHosts.has(hostname) ? 'localhost' : hostname;
return exports.loopbackHosts.has(hostname) || exports.wildcardHosts.has(hostname) ? 'localhost' : hostname;
}

@@ -36,3 +39,3 @@ function resolveEnv(server) {

}
export async function bootstrap(config, server) {
async function bootstrap(config, server) {
const electronPath = require('electron');

@@ -42,4 +45,4 @@ const { config: viteConfig } = server;

if (config.preload) {
const preloadRuntime = resolveRuntime('preload', config, viteConfig);
const preloadConfig = mergeConfig({
const preloadRuntime = (0, config_1.resolveRuntime)('preload', config, viteConfig);
const preloadConfig = (0, vite_1.mergeConfig)({
build: {

@@ -54,4 +57,4 @@ watch: true,

}],
}, resolveBuildConfig(preloadRuntime));
await viteBuild(createWithExternal(preloadRuntime)(preloadConfig));
}, (0, config_1.resolveBuildConfig)(preloadRuntime));
await (0, vite_1.build)((0, config_1.createWithExternal)(preloadRuntime)(preloadConfig));
}

@@ -67,4 +70,4 @@ // ---- Electron-Main ----

}
const mainRuntime = resolveRuntime('main', config, viteConfig);
const mainConfig = mergeConfig({
const mainRuntime = (0, config_1.resolveRuntime)('main', config, viteConfig);
const mainConfig = (0, vite_1.mergeConfig)({
build: {

@@ -82,3 +85,3 @@ watch: true,

// Start Electron.app
process.electronApp = spawn(electronPath, ['.'], { stdio: 'inherit', env: process.env });
process.electronApp = (0, child_process_1.spawn)(electronPath, ['.'], { stdio: 'inherit', env: process.env });
// Exit command after Electron.app exits

@@ -88,6 +91,7 @@ process.electronApp.once('exit', process.exit);

},
checkPkgMain.buildElectronMainPlugin(mainRuntime),
config_1.checkPkgMain.buildElectronMainPlugin(mainRuntime),
],
}, resolveBuildConfig(mainRuntime));
await viteBuild(createWithExternal(mainRuntime)(mainConfig));
}, (0, config_1.resolveBuildConfig)(mainRuntime));
await (0, vite_1.build)((0, config_1.createWithExternal)(mainRuntime)(mainConfig));
}
exports.bootstrap = bootstrap;

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
{
"name": "vite-plugin-electron",
"version": "0.8.5",
"version": "0.8.6",
"description": "Integrate Vite and Electron",

@@ -13,5 +13,4 @@ "main": "dist/index.js",

"license": "MIT",
"type": "module",
"dependencies": {
"vite-plugin-electron-renderer": "0.8.5"
"vite-plugin-electron-renderer": "0.8.6"
},

@@ -18,0 +17,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc