@thatkawaiisam/electron-vite 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +105 -0
- package/bin/electron-bytecode.cjs +32 -0
- package/bin/electron-vite.js +30 -0
- package/dist/chunks/lib-6iOrRH4E.js +38 -0
- package/dist/chunks/lib-B1EDBNjL.js +110 -0
- package/dist/chunks/lib-CKGCTpsN.js +25 -0
- package/dist/chunks/lib-D8_qgfjp.js +1814 -0
- package/dist/cli.js +119 -0
- package/dist/index.d.ts +175 -0
- package/dist/index.js +108 -0
- package/node.d.ts +112 -0
- package/package.json +110 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { cac } from 'cac';
|
|
2
|
+
import colors from 'picocolors';
|
|
3
|
+
import { createLogger } from 'vite';
|
|
4
|
+
|
|
5
|
+
var version = "5.0.0";
|
|
6
|
+
|
|
7
|
+
const cli = cac('electron-vite');
|
|
8
|
+
function createInlineConfig(root, options) {
|
|
9
|
+
return {
|
|
10
|
+
root,
|
|
11
|
+
mode: options.mode,
|
|
12
|
+
configFile: options.config,
|
|
13
|
+
logLevel: options.logLevel,
|
|
14
|
+
clearScreen: options.clearScreen,
|
|
15
|
+
ignoreConfigWarning: options.ignoreConfigWarning,
|
|
16
|
+
build: {
|
|
17
|
+
sourcemap: options.sourcemap,
|
|
18
|
+
outDir: options.outDir,
|
|
19
|
+
...(options.w || options.watch ? { watch: {} } : null)
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
cli
|
|
24
|
+
.option('-c, --config <file>', `[string] use specified config file`)
|
|
25
|
+
.option('-l, --logLevel <level>', `[string] info | warn | error | silent`)
|
|
26
|
+
.option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
|
|
27
|
+
.option('-d, --debug [feat]', `[string | boolean] show debug logs`)
|
|
28
|
+
.option('-f, --filter <filter>', `[string] filter debug logs`)
|
|
29
|
+
.option('-m, --mode <mode>', `[string] set env mode`)
|
|
30
|
+
.option('--ignoreConfigWarning', `[boolean] ignore config warning`)
|
|
31
|
+
.option('--sourcemap', `[boolean] output source maps for debug (default: false)`)
|
|
32
|
+
.option('--outDir <dir>', `[string] output directory (default: out)`)
|
|
33
|
+
.option('--entry <file>', `[string] specify electron entry file`);
|
|
34
|
+
// dev
|
|
35
|
+
cli
|
|
36
|
+
.command('[root]', 'start dev server and electron app')
|
|
37
|
+
.alias('serve')
|
|
38
|
+
.alias('dev')
|
|
39
|
+
.option('-w, --watch', `[boolean] rebuilds when main process or preload script modules have changed on disk`)
|
|
40
|
+
.option('--inspect [port]', `[boolean | number] enable V8 inspector on the specified port`)
|
|
41
|
+
.option('--inspectBrk [port]', `[boolean | number] enable V8 inspector on the specified port`)
|
|
42
|
+
.option('--remoteDebuggingPort <port>', `[string] port for remote debugging`)
|
|
43
|
+
.option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`)
|
|
44
|
+
.option('--rendererOnly', `[boolean] only dev server for the renderer`)
|
|
45
|
+
.action(async (root, options) => {
|
|
46
|
+
if (options.remoteDebuggingPort) {
|
|
47
|
+
process.env.REMOTE_DEBUGGING_PORT = options.remoteDebuggingPort;
|
|
48
|
+
}
|
|
49
|
+
if (options.inspect) {
|
|
50
|
+
process.env.V8_INSPECTOR_PORT = typeof options.inspect === 'number' ? `${options.inspect}` : '5858';
|
|
51
|
+
}
|
|
52
|
+
if (options.inspectBrk) {
|
|
53
|
+
process.env.V8_INSPECTOR_BRK_PORT = typeof options.inspectBrk === 'number' ? `${options.inspectBrk}` : '5858';
|
|
54
|
+
}
|
|
55
|
+
if (options.noSandbox) {
|
|
56
|
+
process.env.NO_SANDBOX = '1';
|
|
57
|
+
}
|
|
58
|
+
if (options['--']) {
|
|
59
|
+
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
|
|
60
|
+
}
|
|
61
|
+
if (options.entry) {
|
|
62
|
+
process.env.ELECTRON_ENTRY = options.entry;
|
|
63
|
+
}
|
|
64
|
+
const { createServer } = await import('./chunks/lib-B1EDBNjL.js');
|
|
65
|
+
const inlineConfig = createInlineConfig(root, options);
|
|
66
|
+
try {
|
|
67
|
+
await createServer(inlineConfig, { rendererOnly: options.rendererOnly });
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
const error = e;
|
|
71
|
+
createLogger(options.logLevel).error(colors.red(`error during start dev server and electron app:\n${error.stack}`), { error });
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
// build
|
|
76
|
+
cli.command('build [root]', 'build for production').action(async (root, options) => {
|
|
77
|
+
const { build } = await import('./chunks/lib-6iOrRH4E.js');
|
|
78
|
+
const inlineConfig = createInlineConfig(root, options);
|
|
79
|
+
if (options.entry) {
|
|
80
|
+
process.env.ELECTRON_ENTRY = options.entry;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
await build(inlineConfig);
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
const error = e;
|
|
87
|
+
createLogger(options.logLevel).error(colors.red(`error during build:\n${error.stack}`), { error });
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
// preview
|
|
92
|
+
cli
|
|
93
|
+
.command('preview [root]', 'start electron app to preview production build')
|
|
94
|
+
.option('--noSandbox', `[boolean] forces renderer process to run un-sandboxed`)
|
|
95
|
+
.option('--skipBuild', `[boolean] skip build`)
|
|
96
|
+
.action(async (root, options) => {
|
|
97
|
+
const { preview } = await import('./chunks/lib-CKGCTpsN.js');
|
|
98
|
+
const inlineConfig = createInlineConfig(root, options);
|
|
99
|
+
if (options.noSandbox) {
|
|
100
|
+
process.env.NO_SANDBOX = '1';
|
|
101
|
+
}
|
|
102
|
+
if (options.entry) {
|
|
103
|
+
process.env.ELECTRON_ENTRY = options.entry;
|
|
104
|
+
}
|
|
105
|
+
if (options['--']) {
|
|
106
|
+
process.env.ELECTRON_CLI_ARGS = JSON.stringify(options['--']);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await preview(inlineConfig, { skipBuild: options.skipBuild });
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
const error = e;
|
|
113
|
+
createLogger(options.logLevel).error(colors.red(`error during preview electron app:\n${error.stack}`), { error });
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
cli.help();
|
|
118
|
+
cli.version(version);
|
|
119
|
+
cli.parse();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Plugin, UserConfig as UserConfig$1, BuildEnvironmentOptions, ConfigEnv, LogLevel, FilterPattern } from 'vite';
|
|
2
|
+
export { LogLevel, createLogger, defineConfig as defineViteConfig, mergeConfig } from 'vite';
|
|
3
|
+
import { TransformConfig } from '@swc/core';
|
|
4
|
+
|
|
5
|
+
interface ExternalOptions {
|
|
6
|
+
exclude?: string[];
|
|
7
|
+
include?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Automatically externalize dependencies.
|
|
11
|
+
*
|
|
12
|
+
* @deprecated use `build.externalizeDeps` config option instead
|
|
13
|
+
*/
|
|
14
|
+
declare function externalizeDepsPlugin(options?: ExternalOptions): Plugin | null;
|
|
15
|
+
|
|
16
|
+
interface BytecodeOptions {
|
|
17
|
+
chunkAlias?: string | string[];
|
|
18
|
+
transformArrowFunctions?: boolean;
|
|
19
|
+
removeBundleJS?: boolean;
|
|
20
|
+
protectedStrings?: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Compile source code to v8 bytecode.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated use `build.bytecode` config option instead
|
|
26
|
+
*/
|
|
27
|
+
declare function bytecodePlugin(options?: BytecodeOptions): Plugin | null;
|
|
28
|
+
|
|
29
|
+
interface IsolatedEntriesMixin {
|
|
30
|
+
/**
|
|
31
|
+
* Build each entry point as an isolated bundle without code splitting.
|
|
32
|
+
*
|
|
33
|
+
* When enabled, each entry will include all its dependencies inline,
|
|
34
|
+
* preventing automatic code splitting across entries and ensuring each
|
|
35
|
+
* output file is fully standalone.
|
|
36
|
+
*
|
|
37
|
+
* **Important**: When using `isolatedEntries` in `preload` config, you
|
|
38
|
+
* should also disable `build.externalizeDeps` to ensure third-party dependencies
|
|
39
|
+
* from `node_modules` are bundled together, which is required for Electron
|
|
40
|
+
* sandbox support.
|
|
41
|
+
*
|
|
42
|
+
* @experimental
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
isolatedEntries?: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface ExternalizeDepsMixin {
|
|
48
|
+
/**
|
|
49
|
+
* Options pass on to `externalizeDeps` plugin in electron-vite.
|
|
50
|
+
*
|
|
51
|
+
* Automatically externalize dependencies.
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
externalizeDeps?: boolean | ExternalOptions;
|
|
56
|
+
}
|
|
57
|
+
interface BytecodeMixin {
|
|
58
|
+
/**
|
|
59
|
+
* Options pass on to `bytecode` plugin in electron-vite.
|
|
60
|
+
* https://electron-vite.org/guide/source-code-protection#options
|
|
61
|
+
*
|
|
62
|
+
* Compile source code to v8 bytecode.
|
|
63
|
+
*/
|
|
64
|
+
bytecode?: boolean | BytecodeOptions;
|
|
65
|
+
}
|
|
66
|
+
interface MainBuildOptions extends BuildEnvironmentOptions, ExternalizeDepsMixin, BytecodeMixin {
|
|
67
|
+
}
|
|
68
|
+
interface PreloadBuildOptions extends BuildEnvironmentOptions, ExternalizeDepsMixin, BytecodeMixin, IsolatedEntriesMixin {
|
|
69
|
+
}
|
|
70
|
+
interface RendererBuildOptions extends BuildEnvironmentOptions, IsolatedEntriesMixin {
|
|
71
|
+
}
|
|
72
|
+
interface BaseViteConfig<T> extends Omit<UserConfig$1, 'build'> {
|
|
73
|
+
/**
|
|
74
|
+
* Build specific options
|
|
75
|
+
*/
|
|
76
|
+
build?: T;
|
|
77
|
+
}
|
|
78
|
+
interface MainViteConfig extends BaseViteConfig<MainBuildOptions> {
|
|
79
|
+
}
|
|
80
|
+
interface PreloadViteConfig extends BaseViteConfig<PreloadBuildOptions> {
|
|
81
|
+
}
|
|
82
|
+
interface RendererViteConfig extends BaseViteConfig<RendererBuildOptions> {
|
|
83
|
+
}
|
|
84
|
+
interface UserConfig {
|
|
85
|
+
/**
|
|
86
|
+
* Custom Electron package name (e.g., '@overwolf/ow-electron').
|
|
87
|
+
* Can also be set via ELECTRON_PKG_NAME environment variable.
|
|
88
|
+
*
|
|
89
|
+
* @default 'electron'
|
|
90
|
+
*/
|
|
91
|
+
electronPackage?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Vite config options for electron main process
|
|
94
|
+
*
|
|
95
|
+
* @see https://vitejs.dev/config/
|
|
96
|
+
*/
|
|
97
|
+
main?: MainViteConfig;
|
|
98
|
+
/**
|
|
99
|
+
* Vite config options for electron renderer process
|
|
100
|
+
*
|
|
101
|
+
* @see https://vitejs.dev/config/
|
|
102
|
+
*/
|
|
103
|
+
renderer?: RendererViteConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Vite config options for electron preload scripts
|
|
106
|
+
*
|
|
107
|
+
* @see https://vitejs.dev/config/
|
|
108
|
+
*/
|
|
109
|
+
preload?: PreloadViteConfig;
|
|
110
|
+
}
|
|
111
|
+
type ElectronViteConfigFnObject = (env: ConfigEnv) => UserConfig;
|
|
112
|
+
type ElectronViteConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
|
|
113
|
+
type ElectronViteConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
114
|
+
type ElectronViteConfigExport = UserConfig | Promise<UserConfig> | ElectronViteConfigFnObject | ElectronViteConfigFnPromise | ElectronViteConfigFn;
|
|
115
|
+
/**
|
|
116
|
+
* Type helper to make it easier to use `electron.vite.config.*`
|
|
117
|
+
* accepts a direct {@link UserConfig} object, or a function that returns it.
|
|
118
|
+
* The function receives a object that exposes two properties:
|
|
119
|
+
* `command` (either `'build'` or `'serve'`), and `mode`.
|
|
120
|
+
*/
|
|
121
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
122
|
+
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
123
|
+
declare function defineConfig(config: ElectronViteConfigFnObject): ElectronViteConfigFnObject;
|
|
124
|
+
declare function defineConfig(config: ElectronViteConfigFnPromise): ElectronViteConfigFnPromise;
|
|
125
|
+
declare function defineConfig(config: ElectronViteConfigExport): ElectronViteConfigExport;
|
|
126
|
+
type InlineConfig = Omit<UserConfig$1, 'base'> & {
|
|
127
|
+
configFile?: string | false;
|
|
128
|
+
envFile?: false;
|
|
129
|
+
ignoreConfigWarning?: boolean;
|
|
130
|
+
};
|
|
131
|
+
interface ResolvedConfig {
|
|
132
|
+
config?: UserConfig;
|
|
133
|
+
configFile?: string;
|
|
134
|
+
configFileDependencies: string[];
|
|
135
|
+
}
|
|
136
|
+
declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
|
|
137
|
+
declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, ignoreConfigWarning?: boolean): Promise<{
|
|
138
|
+
path: string;
|
|
139
|
+
config: UserConfig;
|
|
140
|
+
dependencies: string[];
|
|
141
|
+
}>;
|
|
142
|
+
|
|
143
|
+
declare function createServer(inlineConfig: InlineConfig | undefined, options: {
|
|
144
|
+
rendererOnly?: boolean;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Bundles the electron app for production.
|
|
149
|
+
*/
|
|
150
|
+
declare function build(inlineConfig?: InlineConfig): Promise<void>;
|
|
151
|
+
|
|
152
|
+
declare function preview(inlineConfig: InlineConfig | undefined, options: {
|
|
153
|
+
skipBuild?: boolean;
|
|
154
|
+
}): Promise<void>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Load `.env` files within the `envDir` (default: `process.cwd()`) .
|
|
158
|
+
* By default, only env variables prefixed with `VITE_`, `MAIN_VITE_`, `PRELOAD_VITE_` and
|
|
159
|
+
* `RENDERER_VITE_` are loaded, unless `prefixes` is changed.
|
|
160
|
+
*/
|
|
161
|
+
declare function loadEnv(mode: string, envDir?: string, prefixes?: string | string[]): Record<string, string>;
|
|
162
|
+
|
|
163
|
+
type SwcOptions = {
|
|
164
|
+
include?: FilterPattern;
|
|
165
|
+
exclude?: FilterPattern;
|
|
166
|
+
transformOptions?: TransformConfig;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Use SWC to support for emitting type metadata for decorators.
|
|
170
|
+
* When using `swcPlugin`, you need to install `@swc/core`.
|
|
171
|
+
*/
|
|
172
|
+
declare function swcPlugin(options?: SwcOptions): Plugin;
|
|
173
|
+
|
|
174
|
+
export { build, bytecodePlugin, createServer, defineConfig, externalizeDepsPlugin, loadConfigFromFile, loadEnv, preview, resolveConfig, swcPlugin };
|
|
175
|
+
export type { BytecodeOptions, ElectronViteConfigExport, ElectronViteConfigFn, ElectronViteConfigFnObject, ElectronViteConfigFnPromise, ExternalOptions, InlineConfig, MainViteConfig, PreloadViteConfig, RendererViteConfig, ResolvedConfig, SwcOptions, UserConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createFilter } from 'vite';
|
|
2
|
+
export { createLogger, defineConfig as defineViteConfig, mergeConfig } from 'vite';
|
|
3
|
+
export { b as bytecodePlugin, d as defineConfig, e as externalizeDepsPlugin, a as loadConfigFromFile, l as loadEnv, r as resolveConfig } from './chunks/lib-D8_qgfjp.js';
|
|
4
|
+
export { createServer } from './chunks/lib-B1EDBNjL.js';
|
|
5
|
+
export { build } from './chunks/lib-6iOrRH4E.js';
|
|
6
|
+
export { preview } from './chunks/lib-CKGCTpsN.js';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import 'node:path';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:url';
|
|
11
|
+
import 'picocolors';
|
|
12
|
+
import 'esbuild';
|
|
13
|
+
import 'node:child_process';
|
|
14
|
+
import 'node:crypto';
|
|
15
|
+
import 'node:fs/promises';
|
|
16
|
+
import 'magic-string';
|
|
17
|
+
import '@babel/core';
|
|
18
|
+
|
|
19
|
+
async function transformWithSWC(code, id, options) {
|
|
20
|
+
const { sourcemap = false, minify = false } = options;
|
|
21
|
+
delete options.sourcemap;
|
|
22
|
+
delete options.minify;
|
|
23
|
+
const isTs = /\.tsx?$/.test(id);
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
25
|
+
let swc;
|
|
26
|
+
try {
|
|
27
|
+
swc = require('@swc/core');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error('swc plugin require @swc/core, you need to install it.');
|
|
31
|
+
}
|
|
32
|
+
const jsc = {
|
|
33
|
+
parser: {
|
|
34
|
+
syntax: isTs ? 'typescript' : 'ecmascript',
|
|
35
|
+
decorators: true
|
|
36
|
+
},
|
|
37
|
+
transform: {
|
|
38
|
+
legacyDecorator: true,
|
|
39
|
+
decoratorMetadata: true,
|
|
40
|
+
...options
|
|
41
|
+
},
|
|
42
|
+
keepClassNames: true,
|
|
43
|
+
target: 'es2022',
|
|
44
|
+
minify: {
|
|
45
|
+
format: {
|
|
46
|
+
comments: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const result = await swc.transform(code, {
|
|
51
|
+
jsc,
|
|
52
|
+
sourceMaps: sourcemap,
|
|
53
|
+
minify,
|
|
54
|
+
configFile: false,
|
|
55
|
+
swcrc: false
|
|
56
|
+
});
|
|
57
|
+
const map = sourcemap && result.map ? JSON.parse(result.map) : { mappings: '' };
|
|
58
|
+
return {
|
|
59
|
+
code: result.code,
|
|
60
|
+
map
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Use SWC to support for emitting type metadata for decorators.
|
|
65
|
+
* When using `swcPlugin`, you need to install `@swc/core`.
|
|
66
|
+
*/
|
|
67
|
+
function swcPlugin(options = {}) {
|
|
68
|
+
const filter = createFilter(options.include || /\.(m?ts|[jt]sx)$/, options.exclude || /\.js$/);
|
|
69
|
+
let sourcemap = false;
|
|
70
|
+
let minify = false;
|
|
71
|
+
return {
|
|
72
|
+
name: 'vite:swc',
|
|
73
|
+
config() {
|
|
74
|
+
return {
|
|
75
|
+
esbuild: false
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
async configResolved(resolvedConfig) {
|
|
79
|
+
sourcemap = resolvedConfig.build?.sourcemap === 'inline' ? 'inline' : !!resolvedConfig.build?.sourcemap;
|
|
80
|
+
minify = resolvedConfig.build?.minify;
|
|
81
|
+
},
|
|
82
|
+
async transform(code, id) {
|
|
83
|
+
if (filter(id)) {
|
|
84
|
+
const result = await transformWithSWC(code, id, { sourcemap, ...(options.transformOptions || {}) });
|
|
85
|
+
return {
|
|
86
|
+
code: result.code,
|
|
87
|
+
map: result.map
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async renderChunk(code, chunk) {
|
|
92
|
+
if (!minify || minify === 'terser') {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const result = await transformWithSWC(code, chunk.fileName, {
|
|
96
|
+
sourcemap,
|
|
97
|
+
minify: true,
|
|
98
|
+
...(options.transformOptions || {})
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
code: result.code,
|
|
102
|
+
map: result.map
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { swcPlugin };
|
package/node.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// node worker
|
|
2
|
+
declare module '*?nodeWorker' {
|
|
3
|
+
import type { Worker, WorkerOptions } from 'node:worker_threads'
|
|
4
|
+
export default function (options: WorkerOptions): Worker
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// module path
|
|
8
|
+
declare module '*?modulePath' {
|
|
9
|
+
const src: string
|
|
10
|
+
export default src
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// node asset
|
|
14
|
+
declare module '*?asset' {
|
|
15
|
+
const src: string
|
|
16
|
+
export default src
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*?asset&asarUnpack' {
|
|
20
|
+
const src: string
|
|
21
|
+
export default src
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.json?commonjs-external&asset' {
|
|
25
|
+
const src: string
|
|
26
|
+
export default src
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// native node module
|
|
30
|
+
declare module '*.node' {
|
|
31
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
32
|
+
const node: any
|
|
33
|
+
export default node
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// node wasm
|
|
37
|
+
declare module '*.wasm?loader' {
|
|
38
|
+
const loadWasm: (options?: WebAssembly.Imports) => Promise<WebAssembly.Instance>
|
|
39
|
+
export default loadWasm
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// build-in process env
|
|
43
|
+
declare namespace NodeJS {
|
|
44
|
+
interface ProcessEnv {
|
|
45
|
+
/**
|
|
46
|
+
* Vite's dev server address for Electron renderers.
|
|
47
|
+
*/
|
|
48
|
+
readonly ELECTRON_RENDERER_URL?: string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Refer to Vite's ImportMeta type declarations
|
|
53
|
+
// <https://github.com/vitejs/vite/blob/main/packages/vite/types/importMeta.d.ts>
|
|
54
|
+
|
|
55
|
+
interface ImportMetaEnv {
|
|
56
|
+
MODE: string
|
|
57
|
+
DEV: boolean
|
|
58
|
+
PROD: boolean
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface ImportGlobOptions<Eager extends boolean, AsType extends string> {
|
|
62
|
+
/**
|
|
63
|
+
* Import type for the import url.
|
|
64
|
+
*/
|
|
65
|
+
as?: AsType
|
|
66
|
+
/**
|
|
67
|
+
* Import as static or dynamic
|
|
68
|
+
*
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
eager?: Eager
|
|
72
|
+
/**
|
|
73
|
+
* Import only the specific named export. Set to `default` to import the default export.
|
|
74
|
+
*/
|
|
75
|
+
import?: string
|
|
76
|
+
/**
|
|
77
|
+
* Custom queries
|
|
78
|
+
*/
|
|
79
|
+
query?: string | Record<string, string | number | boolean>
|
|
80
|
+
/**
|
|
81
|
+
* Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
|
|
82
|
+
*
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
exhaustive?: boolean
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface KnownAsTypeMap {
|
|
89
|
+
raw: string
|
|
90
|
+
url: string
|
|
91
|
+
worker: Worker
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface ImportGlobFunction {
|
|
95
|
+
/**
|
|
96
|
+
* Import a list of files with a glob pattern.
|
|
97
|
+
*
|
|
98
|
+
* https://vitejs.dev/guide/features.html#glob-import
|
|
99
|
+
*/
|
|
100
|
+
<Eager extends boolean, As extends string, T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown>(
|
|
101
|
+
glob: string | string[],
|
|
102
|
+
options?: ImportGlobOptions<Eager, As>
|
|
103
|
+
): (Eager extends true ? true : false) extends true ? Record<string, T> : Record<string, () => Promise<T>>
|
|
104
|
+
<M>(glob: string | string[], options?: ImportGlobOptions<false, string>): Record<string, () => Promise<M>>
|
|
105
|
+
<M>(glob: string | string[], options: ImportGlobOptions<true, string>): Record<string, M>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface ImportMeta {
|
|
109
|
+
url: string
|
|
110
|
+
readonly env: ImportMetaEnv
|
|
111
|
+
glob: ImportGlobFunction
|
|
112
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thatkawaiisam/electron-vite",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Electron build tooling based on Vite",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./node": {
|
|
12
|
+
"types": "./node.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"electron-vite": "bin/electron-vite.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin",
|
|
21
|
+
"dist",
|
|
22
|
+
"node.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
26
|
+
},
|
|
27
|
+
"packageManager": "pnpm@10.12.4",
|
|
28
|
+
"author": "Alex Wei<https://github.com/alex8088>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/alex8088/electron-vite.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/alex8088/electron-vite/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://electron-vite.org",
|
|
38
|
+
"keywords": [
|
|
39
|
+
"electron",
|
|
40
|
+
"vite",
|
|
41
|
+
"cli",
|
|
42
|
+
"plugin"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"format": "prettier --write .",
|
|
46
|
+
"lint": "eslint --cache .",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"build": "pnpm run lint && rollup -c rollup.config.ts --configPlugin typescript"
|
|
49
|
+
},
|
|
50
|
+
"simple-git-hooks": {
|
|
51
|
+
"pre-commit": "npx lint-staged",
|
|
52
|
+
"commit-msg": "node scripts/verifyCommit.js $1"
|
|
53
|
+
},
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.js": [
|
|
56
|
+
"prettier --write"
|
|
57
|
+
],
|
|
58
|
+
"*.ts?(x)": [
|
|
59
|
+
"eslint",
|
|
60
|
+
"prettier --parser=typescript --write"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@swc/core": "^1.0.0",
|
|
65
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
"@swc/core": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@eslint/js": "^9.37.0",
|
|
74
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
75
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
76
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
77
|
+
"@swc/core": "^1.13.5",
|
|
78
|
+
"@types/babel__core": "^7.20.5",
|
|
79
|
+
"@types/node": "^22.18.11",
|
|
80
|
+
"eslint": "^9.37.0",
|
|
81
|
+
"eslint-config-prettier": "^10.1.8",
|
|
82
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
83
|
+
"globals": "^16.4.0",
|
|
84
|
+
"lint-staged": "^16.2.4",
|
|
85
|
+
"prettier": "^3.6.2",
|
|
86
|
+
"rollup": "^4.52.4",
|
|
87
|
+
"rollup-plugin-dts": "^6.2.3",
|
|
88
|
+
"rollup-plugin-rm": "^1.0.2",
|
|
89
|
+
"simple-git-hooks": "^2.13.1",
|
|
90
|
+
"tslib": "^2.8.1",
|
|
91
|
+
"typescript": "^5.9.3",
|
|
92
|
+
"typescript-eslint": "^8.46.1",
|
|
93
|
+
"vite": "^7.1.10"
|
|
94
|
+
},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"@babel/core": "^7.28.4",
|
|
97
|
+
"@babel/plugin-transform-arrow-functions": "^7.27.1",
|
|
98
|
+
"cac": "^6.7.14",
|
|
99
|
+
"esbuild": "^0.25.11",
|
|
100
|
+
"magic-string": "^0.30.19",
|
|
101
|
+
"picocolors": "^1.1.1"
|
|
102
|
+
},
|
|
103
|
+
"pnpm": {
|
|
104
|
+
"onlyBuiltDependencies": [
|
|
105
|
+
"@swc/core",
|
|
106
|
+
"esbuild",
|
|
107
|
+
"simple-git-hooks"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|