mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-07-15 19:51:08 +08:00
Compare commits
5 Commits
082b1331ff
...
73f2562172
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f2562172 | ||
|
|
cc0df8a8cc | ||
|
|
93e84f6bce | ||
|
|
619a337c6d | ||
|
|
963f8aba51 |
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,3 +1,33 @@
|
||||
### v2.0.0-beta.0 (_2023-12-13_)
|
||||
|
||||
- feat: bump minimum node version to 18
|
||||
- feat: migrate to ESM
|
||||
- feat: support vite 5
|
||||
- feat: add package.json to export map
|
||||
- feat: support ESM in Electron
|
||||
- fix: emit assets when ssr is enabled
|
||||
- perf: improve package.json resolve
|
||||
- perf: use magic-string hires boundary for sourcemaps
|
||||
- perf: build compatilibity target for Electron 28
|
||||
- pref: resolve import meta url in CommonJS format
|
||||
- perf(worker): ESM syntax
|
||||
- perf: package version
|
||||
- refactor: build
|
||||
- refactor: file hashes use url-safe base64 encoded hashes in vite 5 (rollup 4)
|
||||
- refactor: remove Electron 11, 12 build compatilibity target
|
||||
- refactor: use dynamic import directly
|
||||
- build: use rollup-plugin-dts
|
||||
- chore(deps): update all non-major dependencies
|
||||
- chore(deps): update lint-staged to v15
|
||||
- chore(deps): update eslint-config-prettier to v9
|
||||
- chore(deps): update @rollup/plugin-typescript to v11
|
||||
- chore(deps): update rollup to v4
|
||||
- chore(deps): update vite to v5
|
||||
- chore(deps): update esbuild to v0.19
|
||||
- chore(deps): update typescript to 5.3.3
|
||||
- chore: improve prettier config
|
||||
- chore: update homepage
|
||||
|
||||
### v1.0.29 (_2023-11-17_)
|
||||
|
||||
- feat(cli): support --noSandbox option for dev and preview command
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron-vite",
|
||||
"version": "1.0.29",
|
||||
"version": "2.0.0-beta.0",
|
||||
"description": "Electron build tooling based on Vite",
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
@ -74,6 +74,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-json": "^6.0.1",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"@swc/core": "^1.3.100",
|
||||
|
||||
16
pnpm-lock.yaml
generated
16
pnpm-lock.yaml
generated
@ -25,6 +25,9 @@ dependencies:
|
||||
version: 1.0.0
|
||||
|
||||
devDependencies:
|
||||
'@rollup/plugin-json':
|
||||
specifier: ^6.0.1
|
||||
version: 6.0.1(rollup@4.6.1)
|
||||
'@rollup/plugin-node-resolve':
|
||||
specifier: ^15.2.3
|
||||
version: 15.2.3(rollup@4.6.1)
|
||||
@ -590,6 +593,19 @@ packages:
|
||||
tslib: 2.6.2
|
||||
dev: true
|
||||
|
||||
/@rollup/plugin-json@6.0.1(rollup@4.6.1):
|
||||
resolution: {integrity: sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@rollup/pluginutils': 5.1.0(rollup@4.6.1)
|
||||
rollup: 4.6.1
|
||||
dev: true
|
||||
|
||||
/@rollup/plugin-node-resolve@15.2.3(rollup@4.6.1):
|
||||
resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
@ -3,6 +3,7 @@ import fs from 'node:fs/promises'
|
||||
import { type Plugin, defineConfig } from 'rollup'
|
||||
import ts from '@rollup/plugin-typescript'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import json from '@rollup/plugin-json'
|
||||
import dts from 'rollup-plugin-dts'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
@ -47,6 +48,7 @@ export default defineConfig([
|
||||
external,
|
||||
plugins: [
|
||||
clean('buildStart', 'dist'),
|
||||
json(),
|
||||
ts({ compilerOptions: { rootDir: 'src', declaration: true, declarationDir: 'dist/types' } }),
|
||||
resolve()
|
||||
],
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { createRequire } from 'node:module'
|
||||
import { cac } from 'cac'
|
||||
import colors from 'picocolors'
|
||||
import { LogLevel, createLogger } from 'vite'
|
||||
import { InlineConfig } from './config'
|
||||
|
||||
const _require = createRequire(import.meta.url)
|
||||
import { version } from '../package.json'
|
||||
|
||||
const cli = cac('electron-vite')
|
||||
|
||||
@ -163,6 +161,6 @@ cli
|
||||
})
|
||||
|
||||
cli.help()
|
||||
cli.version(_require('../package.json').version)
|
||||
cli.version(version)
|
||||
|
||||
cli.parse()
|
||||
|
||||
@ -18,6 +18,7 @@ import { build } from 'esbuild'
|
||||
import { electronMainVitePlugin, electronPreloadVitePlugin, electronRendererVitePlugin } from './plugins/electron'
|
||||
import assetPlugin from './plugins/asset'
|
||||
import workerPlugin from './plugins/worker'
|
||||
import importMetaUrlPlugin from './plugins/importMetaUrl'
|
||||
import esmShimPlugin from './plugins/esm'
|
||||
import { isObject } from './utils'
|
||||
|
||||
@ -136,6 +137,7 @@ export async function resolveConfig(
|
||||
...electronMainVitePlugin({ root }),
|
||||
assetPlugin(),
|
||||
workerPlugin(),
|
||||
importMetaUrlPlugin(),
|
||||
esmShimPlugin()
|
||||
])
|
||||
|
||||
@ -149,7 +151,12 @@ export async function resolveConfig(
|
||||
if (outDir) {
|
||||
resetOutDir(preloadViteConfig, outDir, 'preload')
|
||||
}
|
||||
mergePlugins(preloadViteConfig, [...electronPreloadVitePlugin({ root }), assetPlugin(), esmShimPlugin()])
|
||||
mergePlugins(preloadViteConfig, [
|
||||
...electronPreloadVitePlugin({ root }),
|
||||
assetPlugin(),
|
||||
importMetaUrlPlugin(),
|
||||
esmShimPlugin()
|
||||
])
|
||||
|
||||
loadResult.config.preload = preloadViteConfig
|
||||
loadResult.config.preload.configFile = false
|
||||
|
||||
@ -126,6 +126,7 @@ export function electronMainVitePlugin(options?: ElectronPluginOptions): Plugin[
|
||||
config.build.modulePreload = false
|
||||
// enable ssr build
|
||||
config.build.ssr = true
|
||||
config.build.ssrEmitAssets = true
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -269,6 +270,7 @@ export function electronPreloadVitePlugin(options?: ElectronPluginOptions): Plug
|
||||
config.build.modulePreload = false
|
||||
// enable ssr build
|
||||
config.build.ssr = true
|
||||
config.build.ssrEmitAssets = true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
15
src/plugins/importMetaUrl.ts
Normal file
15
src/plugins/importMetaUrl.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
export default function importMetaUrlPlugin(): Plugin {
|
||||
return {
|
||||
name: 'vite:import-meta-url',
|
||||
apply: 'build',
|
||||
enforce: 'pre',
|
||||
resolveImportMeta(property, { format }): string | null {
|
||||
if (property === 'url' && format === 'cjs') {
|
||||
return `require("url").pathToFileURL(__filename).href`
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,7 @@ export default function workerPlugin(): Plugin {
|
||||
const assetRefId = `__VITE_NODE_WORKER_ASSET__${hash}__`
|
||||
return `
|
||||
import { Worker } from 'node:worker_threads';
|
||||
export default function (options) { return new Worker(require.resolve(${assetRefId}), options); }`
|
||||
export default function (options) { return new Worker(new URL(${assetRefId}, import.meta.url), options); }`
|
||||
}
|
||||
},
|
||||
renderChunk(code, chunk): { code: string; map: SourceMapInput } | null {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user