From 219bde63f9b0f6e6026afc370411c2a85aa060c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Mon, 4 Sep 2023 11:45:57 +0800 Subject: [PATCH 01/19] feat(plugin-vite): optimize build speed --- packages/plugin/vite/src/ViteConfig.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin/vite/src/ViteConfig.ts b/packages/plugin/vite/src/ViteConfig.ts index 7a65300602..dcb514fb3d 100644 --- a/packages/plugin/vite/src/ViteConfig.ts +++ b/packages/plugin/vite/src/ViteConfig.ts @@ -83,6 +83,7 @@ export default class ViteConfigGenerator { // 🚧 Multiple builds may conflict. outDir: path.join(this.baseDir, 'build'), watch: watch ? {} : undefined, + minify: this.isProd, }, clearScreen: false, define, From c67f0f6268812b3b995a92ddd0edbceeba1d8a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Mon, 4 Sep 2023 11:48:03 +0800 Subject: [PATCH 02/19] fix(plugin-vite): build size to lag --- packages/plugin/vite/package.json | 4 +- packages/plugin/vite/src/VitePlugin.ts | 63 +++++++++- packages/plugin/vite/src/util/package.ts | 116 +++++++++++++++++ packages/plugin/vite/src/util/packageJson.ts | 45 +++++++ packages/plugin/vite/test/VitePlugin_spec.ts | 125 +++++++++++++++++++ 5 files changed, 346 insertions(+), 7 deletions(-) create mode 100644 packages/plugin/vite/src/util/package.ts create mode 100644 packages/plugin/vite/src/util/packageJson.ts create mode 100644 packages/plugin/vite/test/VitePlugin_spec.ts diff --git a/packages/plugin/vite/package.json b/packages/plugin/vite/package.json index f979706d45..b24c9cbb38 100644 --- a/packages/plugin/vite/package.json +++ b/packages/plugin/vite/package.json @@ -12,13 +12,12 @@ "main": "dist/VitePlugin.js", "typings": "dist/VitePlugin.d.ts", "scripts": { - "test": "xvfb-maybe mocha --config ../../../.mocharc.js test/**/*_spec.ts" + "test": "xvfb-maybe mocha --config ../../../.mocharc.js test/**/*_spec.ts test/*_spec.ts" }, "devDependencies": { "@malept/cross-spawn-promise": "^2.0.0", "@types/node": "^18.0.3", "chai": "^4.3.3", - "fs-extra": "^10.0.0", "mocha": "^9.0.1", "which": "^2.0.2", "xvfb-maybe": "^0.2.1" @@ -33,6 +32,7 @@ "@electron-forge/web-multi-logger": "7.2.0", "chalk": "^4.0.0", "debug": "^4.3.1", + "fs-extra": "^10.0.0", "vite": "^4.1.1" }, "publishConfig": { diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 0625915855..9aa9a0e5b3 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -1,17 +1,22 @@ -import fs from 'node:fs/promises'; import { AddressInfo } from 'node:net'; import path from 'node:path'; import { namedHookWithTaskFn, PluginBase } from '@electron-forge/plugin-base'; -import { ForgeMultiHookMap, StartResult } from '@electron-forge/shared-types'; +import { ForgeMultiHookMap, ResolvedForgeConfig, StartResult } from '@electron-forge/shared-types'; +import chalk from 'chalk'; import debug from 'debug'; +import fs from 'fs-extra'; // eslint-disable-next-line node/no-extraneous-import import { RollupWatcher } from 'rollup'; import { default as vite } from 'vite'; import { VitePluginConfig } from './Config'; +import { getFlatDependencies } from './util/package'; import ViteConfigGenerator from './ViteConfig'; +// Convenient for user customization. +export { resolveDependencies } from './util/package'; + const d = debug('electron-forge:plugin:vite'); export default class VitePlugin extends PluginBase { @@ -41,7 +46,7 @@ export default class VitePlugin extends PluginBase { process.on('SIGINT' as NodeJS.Signals, (_signal) => this.exitHandler({ exit: true })); }; - private setDirectories(dir: string): void { + public setDirectories(dir: string): void { this.projectDir = dir; this.baseDir = path.join(dir, '.vite'); } @@ -55,7 +60,7 @@ export default class VitePlugin extends PluginBase { prePackage: [ namedHookWithTaskFn<'prePackage'>(async () => { this.isProd = true; - await fs.rm(this.baseDir, { recursive: true, force: true }); + await fs.remove(this.baseDir); await Promise.all([this.build(), this.buildRenderer()]); }, 'Building vite bundles'), @@ -67,14 +72,62 @@ export default class VitePlugin extends PluginBase { this.exitHandler({ cleanup: true, exit: true }); }); }, + resolveForgeConfig: this.resolveForgeConfig, + packageAfterCopy: this.packageAfterCopy, + }; + }; + + resolveForgeConfig = async (forgeConfig: ResolvedForgeConfig): Promise => { + forgeConfig.packagerConfig ??= {}; + + if (forgeConfig.packagerConfig.ignore) { + if (typeof forgeConfig.packagerConfig.ignore !== 'function') { + console.error( + chalk.red(`You have set packagerConfig.ignore, the Electron Forge Vite plugin normally sets this automatically. + +Your packaged app may be larger than expected if you dont ignore everything other than the '.vite' folder`) + ); + } + return forgeConfig; + } + + forgeConfig.packagerConfig.ignore = (file: string) => { + if (!file) return false; + + return !/^[/\\]\.vite($|[/\\]).*$/.test(file); }; + return forgeConfig; + }; + + packageAfterCopy = async (_forgeConfig: ResolvedForgeConfig, buildPath: string): Promise => { + const pj = await fs.readJson(path.resolve(this.projectDir, 'package.json')); + const flatDependencies = await getFlatDependencies(this.projectDir); + + if (!/^(.\/)?.vite\//.test(pj.main)) { + throw new Error(`Electron Forge is configured to use the Vite plugin. The plugin expects the +"main" entry point in "package.json" to be ".vite/*" (where the plugin outputs +the generated files). Instead, it is ${JSON.stringify(pj.main)}`); + } + + if (pj.config) { + delete pj.config.forge; + } + + await fs.writeJson(path.resolve(buildPath, 'package.json'), pj, { + spaces: 2, + }); + + // Copy the dependencies in package.json + for (const dep of flatDependencies) { + await fs.copy(path.resolve(dep.src), path.resolve(buildPath, dep.dest)); + } }; startLogic = async (): Promise => { if (VitePlugin.alreadyStarted) return false; VitePlugin.alreadyStarted = true; - await fs.rm(this.baseDir, { recursive: true, force: true }); + await fs.remove(this.baseDir); return { tasks: [ diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts new file mode 100644 index 0000000000..50fe127848 --- /dev/null +++ b/packages/plugin/vite/src/util/package.ts @@ -0,0 +1,116 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +import type { PackageJsonManifest } from './packageJson'; + +export interface Dependency { + name: string; + path: SourceAndDestination; + dependencies: Dependency[]; +} + +export interface SourceAndDestination { + src: string; + dest: string; +} + +function isRootDirectory(dir: string) { + // Linux or Windows root path + return dir === '/' || /^[A-Z]:$/i.test(dir); +} + +export async function lookupNodeModulesPaths(root: string, paths: string[] = []): Promise { + if (!root) return paths; + if (!path.isAbsolute(root)) return paths; + + const p = path.join(root, 'node_modules'); + + if (fs.existsSync(p) && (await fs.promises.stat(p)).isDirectory()) { + paths = paths.concat(p); + } + root = path.join(root, '..'); + + return isRootDirectory(root) ? paths : await lookupNodeModulesPaths(root, paths); +} + +export async function readPackageJson(root = process.cwd()): Promise { + const packageJsonPath = path.join(root, 'package.json'); + try { + const packageJsonStr = await fs.promises.readFile(packageJsonPath, 'utf8'); + try { + return JSON.parse(packageJsonStr); + } catch (error) { + console.error(`parse 'package.json': ${packageJsonPath}`); + throw error; + } + } catch (error) { + console.error(`'package.json' not found: ${packageJsonPath}`); + throw error; + } +} + +export async function resolveDependencies(root: string) { + const rootDependencies = Object.keys((await readPackageJson(root)).dependencies || {}); + const resolve = async (prePath: string, dependencies: string[], collected: Map = new Map()) => + await Promise.all( + dependencies.map(async (name) => { + let curPath = prePath, + depPath = null, + packageJson = null; + while (!packageJson && !isRootDirectory(curPath)) { + const allNodeModules = await lookupNodeModulesPaths(curPath); + + for (const nodeModules of allNodeModules) { + depPath = path.join(nodeModules, name); + if (fs.existsSync(depPath)) break; + } + + if (depPath) { + try { + packageJson = await readPackageJson(depPath); + } catch (err) { + // lookup node_modules + curPath = path.join(curPath, '..'); + if (curPath.length < root.length) { + console.error(`not found 'node_modules' in root path: ${root}`); + throw err; + } + } + } + } + + if (!depPath || !packageJson) { + throw new Error(`find dependencies error in: ${curPath}`); + } + + const result: Dependency = { + name, + path: { + src: depPath, + dest: path.relative(root, depPath), + }, + dependencies: [], + }; + const shouldResolveDeps = !collected.has(depPath); + collected.set(depPath, result); + if (shouldResolveDeps) { + result.dependencies = await resolve(depPath, Object.keys(packageJson.dependencies || {}), collected); + } + return result; + }) + ); + return resolve(root, rootDependencies); +} + +export async function getFlatDependencies(root = process.cwd()) { + const dpesTree = await resolveDependencies(root); + const depsFlat = new Map(); + + const flatten = (dep: Dependency) => { + depsFlat.set(dep.path.src, dep.path); // dedup + dep.dependencies.forEach(flatten); + }; + dpesTree.forEach(flatten); + + return [...depsFlat.values()]; +} diff --git a/packages/plugin/vite/src/util/packageJson.ts b/packages/plugin/vite/src/util/packageJson.ts new file mode 100644 index 0000000000..2c903c354e --- /dev/null +++ b/packages/plugin/vite/src/util/packageJson.ts @@ -0,0 +1,45 @@ +export interface Person { + name: string; + url?: string; + email?: string; +} + +export interface PackageJsonManifest { + // mandatory (npm) + name: string; + version: string; + engines: { [name: string]: string }; + + // optional (npm) + author?: string | Person; + displayName?: string; + description?: string; + keywords?: string[]; + categories?: string[]; + homepage?: string; + bugs?: string | { url?: string; email?: string }; + license?: string; + contributors?: string | Person[]; + main?: string; + browser?: string; + repository?: string | { type?: string; url?: string }; + scripts?: { [name: string]: string }; + dependencies?: { [name: string]: string }; + devDependencies?: { [name: string]: string }; + private?: boolean; + pricing?: string; + + // not supported (npm) + // files?: string[]; + // bin + // man + // directories + // config + // peerDependencies + // bundledDependencies + // optionalDependencies + // os?: string[]; + // cpu?: string[]; + // preferGlobal + // publishConfig +} diff --git a/packages/plugin/vite/test/VitePlugin_spec.ts b/packages/plugin/vite/test/VitePlugin_spec.ts new file mode 100644 index 0000000000..c1e8efc71d --- /dev/null +++ b/packages/plugin/vite/test/VitePlugin_spec.ts @@ -0,0 +1,125 @@ +import * as os from 'os'; +import * as path from 'path'; + +import { ResolvedForgeConfig } from '@electron-forge/shared-types'; +import { expect } from 'chai'; +import { IgnoreFunction } from 'electron-packager'; +import * as fs from 'fs-extra'; + +import { VitePluginConfig } from '../src/Config'; +import { VitePlugin } from '../src/VitePlugin'; + +describe('VitePlugin', () => { + const baseConfig: VitePluginConfig = { + build: [], + renderer: [], + }; + + const viteTestDir = path.resolve(os.tmpdir(), 'electron-forge-plugin-vite-test'); + + describe('packageAfterCopy', () => { + const packageJSONPath = path.join(viteTestDir, 'package.json'); + const packagedPath = path.join(viteTestDir, 'packaged'); + const packagedPackageJSONPath = path.join(packagedPath, 'package.json'); + let plugin: VitePlugin; + + before(async () => { + await fs.ensureDir(packagedPath); + plugin = new VitePlugin(baseConfig); + plugin.setDirectories(viteTestDir); + }); + + it('should remove config.forge from package.json', async () => { + const packageJSON = { main: './.vite/build/main.js', config: { forge: 'config.js' } }; + await fs.writeJson(packageJSONPath, packageJSON); + await plugin.packageAfterCopy({} as ResolvedForgeConfig, packagedPath); + expect(await fs.pathExists(packagedPackageJSONPath)).to.equal(true); + expect((await fs.readJson(packagedPackageJSONPath)).config).to.not.have.property('forge'); + }); + + it('should succeed if there is no config.forge', async () => { + const packageJSON = { main: '.vite/build/main.js' }; + await fs.writeJson(packageJSONPath, packageJSON); + await plugin.packageAfterCopy({} as ResolvedForgeConfig, packagedPath); + expect(await fs.pathExists(packagedPackageJSONPath)).to.equal(true); + expect(await fs.readJson(packagedPackageJSONPath)).to.not.have.property('config'); + }); + + it('should fail if there is no main key in package.json', async () => { + const packageJSON = {}; + await fs.writeJson(packageJSONPath, packageJSON); + await expect(plugin.packageAfterCopy({} as ResolvedForgeConfig, packagedPath)).to.eventually.be.rejectedWith(/entry point/); + }); + + it('should fail if main in package.json does not starts with .vite/', async () => { + const packageJSON = { main: 'src/main.js' }; + await fs.writeJson(packageJSONPath, packageJSON); + await expect(plugin.packageAfterCopy({} as ResolvedForgeConfig, packagedPath)).to.eventually.be.rejectedWith(/entry point/); + }); + + after(async () => { + await fs.remove(viteTestDir); + }); + }); + + describe('resolveForgeConfig', () => { + let plugin: VitePlugin; + + before(() => { + plugin = new VitePlugin(baseConfig); + }); + + it('sets packagerConfig and packagerConfig.ignore if it does not exist', async () => { + const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); + expect(config.packagerConfig).to.not.equal(undefined); + expect(config.packagerConfig.ignore).to.be.a('function'); + }); + + describe('packagerConfig.ignore', () => { + it('does not overwrite an existing ignore value', async () => { + const config = await plugin.resolveForgeConfig({ + packagerConfig: { + ignore: /test/, + }, + } as ResolvedForgeConfig); + + expect(config.packagerConfig.ignore).to.deep.equal(/test/); + }); + + it('ignores everything but files in .vite', async () => { + const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); + const ignore = config.packagerConfig.ignore as IgnoreFunction; + + expect(ignore('')).to.equal(false); + expect(ignore('/abc')).to.equal(true); + expect(ignore('/.vite')).to.equal(false); + expect(ignore('/.vite/foo')).to.equal(false); + }); + + it('ignores source map files by default', async () => { + const viteConfig = { ...baseConfig }; + plugin = new VitePlugin(viteConfig); + const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); + const ignore = config.packagerConfig.ignore as IgnoreFunction; + + expect(ignore(path.join('/.vite', 'build', 'main.js'))).to.equal(false); + // TODO: check sourcemap files + // expect(ignore(path.join('/.vite', 'build', 'main.js.map'))).to.equal(true); + expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); + // expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(true); + }); + + it('includes source map files when specified by config', async () => { + const viteConfig = { ...baseConfig, packageSourceMaps: true }; + plugin = new VitePlugin(viteConfig); + const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); + const ignore = config.packagerConfig.ignore as IgnoreFunction; + + expect(ignore(path.join('/.vite', 'build', 'main.js'))).to.equal(false); + expect(ignore(path.join('/.vite', 'build', 'main.js.map'))).to.equal(false); + expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); + expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(false); + }); + }); + }); +}); From 478d5e635c4d424f4a882705757855765bae170c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Mon, 1 Jan 2024 11:47:11 +0800 Subject: [PATCH 03/19] fix(plugin-vite): fix test --- packages/plugin/vite/package.json | 1 + packages/plugin/vite/test/ViteConfig_spec.ts | 1 + packages/plugin/vite/test/VitePlugin_spec.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugin/vite/package.json b/packages/plugin/vite/package.json index b24c9cbb38..ed264c79cc 100644 --- a/packages/plugin/vite/package.json +++ b/packages/plugin/vite/package.json @@ -15,6 +15,7 @@ "test": "xvfb-maybe mocha --config ../../../.mocharc.js test/**/*_spec.ts test/*_spec.ts" }, "devDependencies": { + "@electron/packager": "^18.1.2", "@malept/cross-spawn-promise": "^2.0.0", "@types/node": "^18.0.3", "chai": "^4.3.3", diff --git a/packages/plugin/vite/test/ViteConfig_spec.ts b/packages/plugin/vite/test/ViteConfig_spec.ts index 87d188342d..f4d07aec0a 100644 --- a/packages/plugin/vite/test/ViteConfig_spec.ts +++ b/packages/plugin/vite/test/ViteConfig_spec.ts @@ -63,6 +63,7 @@ describe('ViteConfigGenerator', () => { emptyOutDir: false, outDir: path.join('.vite', 'build'), watch: undefined, + minify: true, // this.isProd === true }, clearScreen: false, define: {}, diff --git a/packages/plugin/vite/test/VitePlugin_spec.ts b/packages/plugin/vite/test/VitePlugin_spec.ts index c1e8efc71d..fc2bb58a00 100644 --- a/packages/plugin/vite/test/VitePlugin_spec.ts +++ b/packages/plugin/vite/test/VitePlugin_spec.ts @@ -2,8 +2,8 @@ import * as os from 'os'; import * as path from 'path'; import { ResolvedForgeConfig } from '@electron-forge/shared-types'; +import { IgnoreFunction } from '@electron/packager'; import { expect } from 'chai'; -import { IgnoreFunction } from 'electron-packager'; import * as fs from 'fs-extra'; import { VitePluginConfig } from '../src/Config'; From 51f5aec886e474593bfec8ee1ffb1f0ac44330dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Mon, 1 Jan 2024 11:47:58 +0800 Subject: [PATCH 04/19] feat(plugin-vite): util/package test --- packages/plugin/vite/test/fixture/.gitignore | 4 + .../vite/test/fixture/package/package.json | 7 ++ .../plugin/vite/test/util/package_spec.ts | 78 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 packages/plugin/vite/test/fixture/.gitignore create mode 100644 packages/plugin/vite/test/fixture/package/package.json create mode 100644 packages/plugin/vite/test/util/package_spec.ts diff --git a/packages/plugin/vite/test/fixture/.gitignore b/packages/plugin/vite/test/fixture/.gitignore new file mode 100644 index 0000000000..2f0cb5a3b2 --- /dev/null +++ b/packages/plugin/vite/test/fixture/.gitignore @@ -0,0 +1,4 @@ +# lockfile +package-lock.json +pnpm-lock.yaml +yarn.lock diff --git a/packages/plugin/vite/test/fixture/package/package.json b/packages/plugin/vite/test/fixture/package/package.json new file mode 100644 index 0000000000..5186d39673 --- /dev/null +++ b/packages/plugin/vite/test/fixture/package/package.json @@ -0,0 +1,7 @@ +{ + "name": "@electron-forge/plugin-vite-test-util-package", + "version": "0.1.0", + "dependencies": { + "electron-squirrel-startup": "^1.0.0" + } +} diff --git a/packages/plugin/vite/test/util/package_spec.ts b/packages/plugin/vite/test/util/package_spec.ts new file mode 100644 index 0000000000..5ed9d9f3de --- /dev/null +++ b/packages/plugin/vite/test/util/package_spec.ts @@ -0,0 +1,78 @@ +import { exec } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; +import { promisify } from 'node:util'; + +import { expect } from 'chai'; + +import { getFlatDependencies, lookupNodeModulesPaths, readPackageJson, resolveDependencies } from '../../src/util/package'; + +const execPromise = promisify(exec); +const packageRoot = path.join(__dirname, '../fixture/package'); +const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')); +const depsTree = [ + { + name: 'electron-squirrel-startup', + path: { + src: path.join(packageRoot, 'node_modules', 'electron-squirrel-startup'), + dest: path.join('node_modules', 'electron-squirrel-startup'), + }, + dependencies: [ + { + name: 'debug', + path: { + src: path.join(packageRoot, 'node_modules', 'debug'), + dest: path.join('node_modules', 'debug'), + }, + dependencies: [ + { + name: 'ms', + path: { + src: path.join(packageRoot, 'node_modules', 'ms'), + dest: path.join('node_modules', 'ms'), + }, + dependencies: [], + }, + ], + }, + ], + }, +]; +const depsFlat = [ + { + src: path.join(packageRoot, 'node_modules', 'electron-squirrel-startup'), + dest: path.join('node_modules', 'electron-squirrel-startup'), + }, + { + src: path.join(packageRoot, 'node_modules', 'debug'), + dest: path.join('node_modules', 'debug'), + }, + { + src: path.join(packageRoot, 'node_modules', 'ms'), + dest: path.join('node_modules', 'ms'), + }, +]; + +describe('package', () => { + before(async () => { + await execPromise('npm install', { cwd: packageRoot }); + }); + + it('package.json is loaded correct', async () => { + const packageJson2 = await readPackageJson(packageRoot); + expect(typeof packageJson2).equal('object'); + expect(packageJson2).deep.equal(packageJson); + }); + + it('dependencies of package.json is resolved correct', async () => { + const depsT = await resolveDependencies(packageRoot); + const depsF = await getFlatDependencies(packageRoot); + expect(depsTree).deep.equal(depsT); + expect(depsFlat).deep.equal(depsF); + }); + + it('node_modules paths is lookup correct', async () => { + const paths = await lookupNodeModulesPaths(packageRoot); + expect(paths.length).gt(0); + }); +}); From 6d3103a3800102807163fe15361c2790c7d45455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Mon, 1 Jan 2024 12:19:12 +0800 Subject: [PATCH 05/19] fix(vite-plugin): correct Windows root directory Regexp --- packages/plugin/vite/src/util/package.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index 50fe127848..9b54ef0e05 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -16,7 +16,7 @@ export interface SourceAndDestination { function isRootDirectory(dir: string) { // Linux or Windows root path - return dir === '/' || /^[A-Z]:$/i.test(dir); + return dir === '/' || /^[A-Z]:\\$/i.test(dir); } export async function lookupNodeModulesPaths(root: string, paths: string[] = []): Promise { From 57375dc27d85316f8cbb3083f388c1ea3eb750bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Mon, 8 Jan 2024 19:32:02 +0800 Subject: [PATCH 06/19] chore(plugin-vite): cleanup rename function --- packages/plugin/vite/src/util/package.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index 9b54ef0e05..f35a6241a2 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -14,7 +14,7 @@ export interface SourceAndDestination { dest: string; } -function isRootDirectory(dir: string) { +function isRootPath(dir: string) { // Linux or Windows root path return dir === '/' || /^[A-Z]:\\$/i.test(dir); } @@ -30,7 +30,7 @@ export async function lookupNodeModulesPaths(root: string, paths: string[] = []) } root = path.join(root, '..'); - return isRootDirectory(root) ? paths : await lookupNodeModulesPaths(root, paths); + return isRootPath(root) ? paths : await lookupNodeModulesPaths(root, paths); } export async function readPackageJson(root = process.cwd()): Promise { @@ -57,7 +57,7 @@ export async function resolveDependencies(root: string) { let curPath = prePath, depPath = null, packageJson = null; - while (!packageJson && !isRootDirectory(curPath)) { + while (!packageJson && !isRootPath(curPath)) { const allNodeModules = await lookupNodeModulesPaths(curPath); for (const nodeModules of allNodeModules) { From 2f6602ff6659bf71ac68af0ae74746fcd8316335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Mon, 8 Jan 2024 20:09:26 +0800 Subject: [PATCH 07/19] fix(plugin-vite): fix template test --- .../vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts index 565769df86..f73c9ae0b2 100644 --- a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts +++ b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts @@ -21,7 +21,7 @@ describe('ViteTypeScriptTemplate', () => { after(async () => { await yarnOrNpmSpawn(['link:remove']); await killWindowsEsbuildExe(); - await fs.remove(dir); + fs.rmSync(dir, { recursive: true, force: true }); }); describe('template files are copied to project', () => { From 83a26e0bb23051b6582472570b8309275e31c742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 11:38:47 +0800 Subject: [PATCH 08/19] chore(vite-plugin): update `config.ignore` log Co-authored-by: Black-Hole --- packages/plugin/vite/src/VitePlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 9aa9a0e5b3..98c6bc2828 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -83,7 +83,7 @@ export default class VitePlugin extends PluginBase { if (forgeConfig.packagerConfig.ignore) { if (typeof forgeConfig.packagerConfig.ignore !== 'function') { console.error( - chalk.red(`You have set packagerConfig.ignore, the Electron Forge Vite plugin normally sets this automatically. + chalk.yellow(`You have set packagerConfig.ignore, the Electron Forge Vite plugin normally sets this automatically. Your packaged app may be larger than expected if you dont ignore everything other than the '.vite' folder`) ); From c615b46943dd3021f4cc4140748e8ae505babfa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 11:41:56 +0800 Subject: [PATCH 09/19] chore(vite-plugin): use String.includes instead Regexp Co-authored-by: Black-Hole --- packages/plugin/vite/src/VitePlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 98c6bc2828..109d0ab259 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -103,7 +103,7 @@ Your packaged app may be larger than expected if you dont ignore everything othe const pj = await fs.readJson(path.resolve(this.projectDir, 'package.json')); const flatDependencies = await getFlatDependencies(this.projectDir); - if (!/^(.\/)?.vite\//.test(pj.main)) { + if (!pj.main?.includes(".vite/")) { throw new Error(`Electron Forge is configured to use the Vite plugin. The plugin expects the "main" entry point in "package.json" to be ".vite/*" (where the plugin outputs the generated files). Instead, it is ${JSON.stringify(pj.main)}`); From ed28654cb8868a8a1492bc27f3acb0d1b7f1fe18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 11:43:08 +0800 Subject: [PATCH 10/19] chore(plugin-vite): update check root path Regexp Co-authored-by: Black-Hole --- packages/plugin/vite/src/util/package.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index f35a6241a2..524dc3d62d 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -15,8 +15,8 @@ export interface SourceAndDestination { } function isRootPath(dir: string) { - // Linux or Windows root path - return dir === '/' || /^[A-Z]:\\$/i.test(dir); + // *unix or Windows root path + return dir === '/' || /^[a-zA-Z]:\\$/i.test(dir); } export async function lookupNodeModulesPaths(root: string, paths: string[] = []): Promise { From bb7a9210dd84eec1b7d9327a1b565c5a70d7b6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 11:49:15 +0800 Subject: [PATCH 11/19] chore(plugin-vite): cleanup `resolvePackageJson()` of utils.ts Co-authored-by: Black-Hole --- packages/plugin/vite/src/util/package.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index 524dc3d62d..ab0d014e7b 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -37,14 +37,9 @@ export async function readPackageJson(root = process.cwd()): Promise Date: Tue, 9 Jan 2024 16:52:23 +0800 Subject: [PATCH 12/19] chore(plugin-vite): code style cleanup --- packages/plugin/vite/src/VitePlugin.ts | 4 ++-- packages/plugin/vite/src/util/package.ts | 11 ++++++++++- packages/plugin/vite/test/util/package_spec.ts | 7 ++++++- .../test/ViteTypeScriptTemplate_spec_slow.ts | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 109d0ab259..0debb29bc8 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -103,7 +103,7 @@ Your packaged app may be larger than expected if you dont ignore everything othe const pj = await fs.readJson(path.resolve(this.projectDir, 'package.json')); const flatDependencies = await getFlatDependencies(this.projectDir); - if (!pj.main?.includes(".vite/")) { + if (!pj.main?.includes('.vite/')) { throw new Error(`Electron Forge is configured to use the Vite plugin. The plugin expects the "main" entry point in "package.json" to be ".vite/*" (where the plugin outputs the generated files). Instead, it is ${JSON.stringify(pj.main)}`); @@ -119,7 +119,7 @@ the generated files). Instead, it is ${JSON.stringify(pj.main)}`); // Copy the dependencies in package.json for (const dep of flatDependencies) { - await fs.copy(path.resolve(dep.src), path.resolve(buildPath, dep.dest)); + await fs.copy(dep.src, path.resolve(buildPath, dep.dest)); } }; diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index ab0d014e7b..054203728d 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -19,13 +19,22 @@ function isRootPath(dir: string) { return dir === '/' || /^[a-zA-Z]:\\$/i.test(dir); } +export async function isDirectory(p: string): Promise { + try { + const stat = await fs.promises.stat(p); + return stat.isDirectory(); + } catch { + return false; + } +} + export async function lookupNodeModulesPaths(root: string, paths: string[] = []): Promise { if (!root) return paths; if (!path.isAbsolute(root)) return paths; const p = path.join(root, 'node_modules'); - if (fs.existsSync(p) && (await fs.promises.stat(p)).isDirectory()) { + if (await isDirectory(p)) { paths = paths.concat(p); } root = path.join(root, '..'); diff --git a/packages/plugin/vite/test/util/package_spec.ts b/packages/plugin/vite/test/util/package_spec.ts index 5ed9d9f3de..1cd67738c7 100644 --- a/packages/plugin/vite/test/util/package_spec.ts +++ b/packages/plugin/vite/test/util/package_spec.ts @@ -5,7 +5,7 @@ import { promisify } from 'node:util'; import { expect } from 'chai'; -import { getFlatDependencies, lookupNodeModulesPaths, readPackageJson, resolveDependencies } from '../../src/util/package'; +import { getFlatDependencies, isDirectory, lookupNodeModulesPaths, readPackageJson, resolveDependencies } from '../../src/util/package'; const execPromise = promisify(exec); const packageRoot = path.join(__dirname, '../fixture/package'); @@ -71,6 +71,11 @@ describe('package', () => { expect(depsFlat).deep.equal(depsF); }); + it('isDirectory check is correct', async () => { + expect(await isDirectory(packageRoot)).true; + expect(await isDirectory(path.join(packageRoot, 'package.json'))).false; + }); + it('node_modules paths is lookup correct', async () => { const paths = await lookupNodeModulesPaths(packageRoot); expect(paths.length).gt(0); diff --git a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts index f73c9ae0b2..bc48013866 100644 --- a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts +++ b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts @@ -21,6 +21,7 @@ describe('ViteTypeScriptTemplate', () => { after(async () => { await yarnOrNpmSpawn(['link:remove']); await killWindowsEsbuildExe(); + // TODO: use the async API fs.rmSync(dir, { recursive: true, force: true }); }); From 378775f2ea45892a60b5fcd2fda25b84669056f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 17:38:50 +0800 Subject: [PATCH 13/19] chore(plugin-vite): better ignore check --- packages/plugin/vite/src/VitePlugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index 0debb29bc8..d030f7bcc6 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -94,7 +94,9 @@ Your packaged app may be larger than expected if you dont ignore everything othe forgeConfig.packagerConfig.ignore = (file: string) => { if (!file) return false; - return !/^[/\\]\.vite($|[/\\]).*$/.test(file); + // Always starts with `/` + // @see - https://github.com/electron/packager/blob/v18.1.3/src/copy-filter.ts#L89-L93 + return !file.startsWith('/.vite'); }; return forgeConfig; }; From 4856b15733eb45209565f84bd668bf76a0887bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Tue, 9 Jan 2024 19:33:44 +0800 Subject: [PATCH 14/19] chore(plugin-vite): update test --- packages/plugin/vite/test/VitePlugin_spec.ts | 17 ++++++++--------- packages/plugin/vite/test/util/package_spec.ts | 2 +- packages/plugin/vite/test/util/plugins_spec.ts | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/plugin/vite/test/VitePlugin_spec.ts b/packages/plugin/vite/test/VitePlugin_spec.ts index fc2bb58a00..c0119fe652 100644 --- a/packages/plugin/vite/test/VitePlugin_spec.ts +++ b/packages/plugin/vite/test/VitePlugin_spec.ts @@ -102,11 +102,10 @@ describe('VitePlugin', () => { const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); const ignore = config.packagerConfig.ignore as IgnoreFunction; - expect(ignore(path.join('/.vite', 'build', 'main.js'))).to.equal(false); - // TODO: check sourcemap files - // expect(ignore(path.join('/.vite', 'build', 'main.js.map'))).to.equal(true); - expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); - // expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(true); + expect(ignore(path.posix.join('/.vite', 'build', 'main.js'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'build', 'main.js.map'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(false); }); it('includes source map files when specified by config', async () => { @@ -115,10 +114,10 @@ describe('VitePlugin', () => { const config = await plugin.resolveForgeConfig({} as ResolvedForgeConfig); const ignore = config.packagerConfig.ignore as IgnoreFunction; - expect(ignore(path.join('/.vite', 'build', 'main.js'))).to.equal(false); - expect(ignore(path.join('/.vite', 'build', 'main.js.map'))).to.equal(false); - expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); - expect(ignore(path.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'build', 'main.js'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'build', 'main.js.map'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js'))).to.equal(false); + expect(ignore(path.posix.join('/.vite', 'renderer', 'main_window', 'assets', 'index.js.map'))).to.equal(false); }); }); }); diff --git a/packages/plugin/vite/test/util/package_spec.ts b/packages/plugin/vite/test/util/package_spec.ts index 1cd67738c7..f9ee8e5262 100644 --- a/packages/plugin/vite/test/util/package_spec.ts +++ b/packages/plugin/vite/test/util/package_spec.ts @@ -53,7 +53,7 @@ const depsFlat = [ }, ]; -describe('package', () => { +describe('util/package', () => { before(async () => { await execPromise('npm install', { cwd: packageRoot }); }); diff --git a/packages/plugin/vite/test/util/plugins_spec.ts b/packages/plugin/vite/test/util/plugins_spec.ts index bdf0eb226e..9375dee789 100644 --- a/packages/plugin/vite/test/util/plugins_spec.ts +++ b/packages/plugin/vite/test/util/plugins_spec.ts @@ -8,7 +8,7 @@ import { resolveConfig } from 'vite'; import { externalBuiltins } from '../../src/util/plugins'; -describe('plugins', () => { +describe('util/plugins', () => { it('externalBuiltins', async () => { const nativeModules = builtinModules.filter((e) => !e.startsWith('_')); const builtins: any[] = ['electron', ...nativeModules, ...nativeModules.map((m) => `node:${m}`)]; From 32e683ea4cc6490336f44072c1ce5efef3bfb20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Fri, 12 Jan 2024 17:07:51 +0800 Subject: [PATCH 15/19] chore(plugin-vite): update test comments --- .../vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts index bc48013866..ad606a6664 100644 --- a/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts +++ b/packages/template/vite-typescript/test/ViteTypeScriptTemplate_spec_slow.ts @@ -21,7 +21,9 @@ describe('ViteTypeScriptTemplate', () => { after(async () => { await yarnOrNpmSpawn(['link:remove']); await killWindowsEsbuildExe(); - // TODO: use the async API + // TODO: use the async API @caoxiemeihao + // In the vite@4 running test will occupy the `dist` folder, causing an error on the Windows PC when call `fs.remove()`. + // Currently, vite has released 5 version, and forge-vite-plugin will be upgrade soon vite@5 and I will try to fix issue in the next PR about vite@5. fs.rmSync(dir, { recursive: true, force: true }); }); From 2a92f184c4bab3074a55876d9ae710ce435c8c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Sat, 13 Jan 2024 10:55:27 +0800 Subject: [PATCH 16/19] chore(vite-plugin): resmove export resolveDependencies --- packages/plugin/vite/src/VitePlugin.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/plugin/vite/src/VitePlugin.ts b/packages/plugin/vite/src/VitePlugin.ts index d030f7bcc6..3a1c6b5110 100644 --- a/packages/plugin/vite/src/VitePlugin.ts +++ b/packages/plugin/vite/src/VitePlugin.ts @@ -14,9 +14,6 @@ import { VitePluginConfig } from './Config'; import { getFlatDependencies } from './util/package'; import ViteConfigGenerator from './ViteConfig'; -// Convenient for user customization. -export { resolveDependencies } from './util/package'; - const d = debug('electron-forge:plugin:vite'); export default class VitePlugin extends PluginBase { From 68542f0d29a0790d3b8c6da1086318780b17a725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Sat, 13 Jan 2024 10:56:48 +0800 Subject: [PATCH 17/19] chore(plugin-vite): typo --- packages/plugin/vite/src/util/package.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index 054203728d..215713b28b 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -107,14 +107,14 @@ export async function resolveDependencies(root: string) { } export async function getFlatDependencies(root = process.cwd()) { - const dpesTree = await resolveDependencies(root); + const depsTree = await resolveDependencies(root); const depsFlat = new Map(); const flatten = (dep: Dependency) => { depsFlat.set(dep.path.src, dep.path); // dedup dep.dependencies.forEach(flatten); }; - dpesTree.forEach(flatten); + depsTree.forEach(flatten); return [...depsFlat.values()]; } From 0564e07e086d26f61dd1a8a906abd97273ba04cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Wed, 17 Jan 2024 18:38:28 +0800 Subject: [PATCH 18/19] chore(plugin-vite): use fs-extra for better logic --- packages/plugin/vite/src/util/package.ts | 20 ++------- packages/plugin/vite/src/util/packageJson.ts | 45 ------------------- .../plugin/vite/test/util/package_spec.ts | 10 +---- 3 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 packages/plugin/vite/src/util/packageJson.ts diff --git a/packages/plugin/vite/src/util/package.ts b/packages/plugin/vite/src/util/package.ts index 215713b28b..0fbb9a4a78 100644 --- a/packages/plugin/vite/src/util/package.ts +++ b/packages/plugin/vite/src/util/package.ts @@ -1,7 +1,6 @@ -import fs from 'node:fs'; import path from 'node:path'; -import type { PackageJsonManifest } from './packageJson'; +import fs from 'fs-extra'; export interface Dependency { name: string; @@ -42,19 +41,8 @@ export async function lookupNodeModulesPaths(root: string, paths: string[] = []) return isRootPath(root) ? paths : await lookupNodeModulesPaths(root, paths); } -export async function readPackageJson(root = process.cwd()): Promise { - const packageJsonPath = path.join(root, 'package.json'); - try { - const packageJsonStr = await fs.promises.readFile(packageJsonPath, 'utf8'); - return JSON.parse(packageJsonStr); - } catch (error) { - console.error(`parse ${packageJsonPath} failed: ${error}`); - throw error; - } -} - export async function resolveDependencies(root: string) { - const rootDependencies = Object.keys((await readPackageJson(root)).dependencies || {}); + const rootDependencies = Object.keys((await fs.readJson(path.join(root, 'package.json'))).dependencies || {}); const resolve = async (prePath: string, dependencies: string[], collected: Map = new Map()) => await Promise.all( dependencies.map(async (name) => { @@ -66,12 +54,12 @@ export async function resolveDependencies(root: string) { for (const nodeModules of allNodeModules) { depPath = path.join(nodeModules, name); - if (fs.existsSync(depPath)) break; + if (await fs.pathExists(depPath)) break; } if (depPath) { try { - packageJson = await readPackageJson(depPath); + packageJson = await fs.readJson(path.join(depPath, 'package.json')); } catch (err) { // lookup node_modules curPath = path.join(curPath, '..'); diff --git a/packages/plugin/vite/src/util/packageJson.ts b/packages/plugin/vite/src/util/packageJson.ts deleted file mode 100644 index 2c903c354e..0000000000 --- a/packages/plugin/vite/src/util/packageJson.ts +++ /dev/null @@ -1,45 +0,0 @@ -export interface Person { - name: string; - url?: string; - email?: string; -} - -export interface PackageJsonManifest { - // mandatory (npm) - name: string; - version: string; - engines: { [name: string]: string }; - - // optional (npm) - author?: string | Person; - displayName?: string; - description?: string; - keywords?: string[]; - categories?: string[]; - homepage?: string; - bugs?: string | { url?: string; email?: string }; - license?: string; - contributors?: string | Person[]; - main?: string; - browser?: string; - repository?: string | { type?: string; url?: string }; - scripts?: { [name: string]: string }; - dependencies?: { [name: string]: string }; - devDependencies?: { [name: string]: string }; - private?: boolean; - pricing?: string; - - // not supported (npm) - // files?: string[]; - // bin - // man - // directories - // config - // peerDependencies - // bundledDependencies - // optionalDependencies - // os?: string[]; - // cpu?: string[]; - // preferGlobal - // publishConfig -} diff --git a/packages/plugin/vite/test/util/package_spec.ts b/packages/plugin/vite/test/util/package_spec.ts index f9ee8e5262..8833d43afd 100644 --- a/packages/plugin/vite/test/util/package_spec.ts +++ b/packages/plugin/vite/test/util/package_spec.ts @@ -1,15 +1,13 @@ import { exec } from 'node:child_process'; -import fs from 'node:fs'; import path from 'node:path'; import { promisify } from 'node:util'; import { expect } from 'chai'; -import { getFlatDependencies, isDirectory, lookupNodeModulesPaths, readPackageJson, resolveDependencies } from '../../src/util/package'; +import { getFlatDependencies, isDirectory, lookupNodeModulesPaths, resolveDependencies } from '../../src/util/package'; const execPromise = promisify(exec); const packageRoot = path.join(__dirname, '../fixture/package'); -const packageJson = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')); const depsTree = [ { name: 'electron-squirrel-startup', @@ -58,12 +56,6 @@ describe('util/package', () => { await execPromise('npm install', { cwd: packageRoot }); }); - it('package.json is loaded correct', async () => { - const packageJson2 = await readPackageJson(packageRoot); - expect(typeof packageJson2).equal('object'); - expect(packageJson2).deep.equal(packageJson); - }); - it('dependencies of package.json is resolved correct', async () => { const depsT = await resolveDependencies(packageRoot); const depsF = await getFlatDependencies(packageRoot); From c7da7560e99ad34daa12b48a1a022a71b8b20e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Wang=28=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7=29?= <308487730@qq.com> Date: Wed, 17 Jan 2024 20:33:35 +0800 Subject: [PATCH 19/19] chore(plugin-vite): bump vite to 4.5.1 --- package.json | 2 +- packages/plugin/vite/package.json | 2 +- yarn.lock | 311 +++++++++++++++--------------- 3 files changed, 157 insertions(+), 158 deletions(-) diff --git a/package.json b/package.json index 88ba7231e3..4402283159 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "source-map-support": "^0.5.13", "sudo-prompt": "^9.1.1", "username": "^5.1.0", - "vite": "^4.1.1", + "vite": "^4.5.1", "webpack": "^5.69.1", "webpack-dev-server": "^4.0.0", "webpack-merge": "^5.7.3", diff --git a/packages/plugin/vite/package.json b/packages/plugin/vite/package.json index ed264c79cc..691b97362e 100644 --- a/packages/plugin/vite/package.json +++ b/packages/plugin/vite/package.json @@ -34,7 +34,7 @@ "chalk": "^4.0.0", "debug": "^4.3.1", "fs-extra": "^10.0.0", - "vite": "^4.1.1" + "vite": "^4.5.1" }, "publishConfig": { "access": "public" diff --git a/yarn.lock b/yarn.lock index f9d07e9525..dd1f86cfa4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1111,115 +1111,115 @@ fs-extra "^11.1.1" minimist "^1.2.8" -"@esbuild/android-arm64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.16.17.tgz#cf91e86df127aa3d141744edafcba0abdc577d23" - integrity sha512-MIGl6p5sc3RDTLLkYL1MyL8BMRN4tLMRCn+yRJJmEDvYZ2M7tmAf80hx1kbNEUX2KJ50RRtxZ4JHLvCfuB6kBg== - -"@esbuild/android-arm@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.16.17.tgz#025b6246d3f68b7bbaa97069144fb5fb70f2fff2" - integrity sha512-N9x1CMXVhtWEAMS7pNNONyA14f71VPQN9Cnavj1XQh6T7bskqiLLrSca4O0Vr8Wdcga943eThxnVp3JLnBMYtw== - -"@esbuild/android-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.16.17.tgz#c820e0fef982f99a85c4b8bfdd582835f04cd96e" - integrity sha512-a3kTv3m0Ghh4z1DaFEuEDfz3OLONKuFvI4Xqczqx4BqLyuFaFkuaG4j2MtA6fuWEFeC5x9IvqnX7drmRq/fyAQ== - -"@esbuild/darwin-arm64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.16.17.tgz#edef4487af6b21afabba7be5132c26d22379b220" - integrity sha512-/2agbUEfmxWHi9ARTX6OQ/KgXnOWfsNlTeLcoV7HSuSTv63E4DqtAc+2XqGw1KHxKMHGZgbVCZge7HXWX9Vn+w== - -"@esbuild/darwin-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.16.17.tgz#42829168730071c41ef0d028d8319eea0e2904b4" - integrity sha512-2By45OBHulkd9Svy5IOCZt376Aa2oOkiE9QWUK9fe6Tb+WDr8hXL3dpqi+DeLiMed8tVXspzsTAvd0jUl96wmg== - -"@esbuild/freebsd-arm64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.17.tgz#1f4af488bfc7e9ced04207034d398e793b570a27" - integrity sha512-mt+cxZe1tVx489VTb4mBAOo2aKSnJ33L9fr25JXpqQqzbUIw/yzIzi+NHwAXK2qYV1lEFp4OoVeThGjUbmWmdw== - -"@esbuild/freebsd-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.16.17.tgz#636306f19e9bc981e06aa1d777302dad8fddaf72" - integrity sha512-8ScTdNJl5idAKjH8zGAsN7RuWcyHG3BAvMNpKOBaqqR7EbUhhVHOqXRdL7oZvz8WNHL2pr5+eIT5c65kA6NHug== - -"@esbuild/linux-arm64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.16.17.tgz#a003f7ff237c501e095d4f3a09e58fc7b25a4aca" - integrity sha512-7S8gJnSlqKGVJunnMCrXHU9Q8Q/tQIxk/xL8BqAP64wchPCTzuM6W3Ra8cIa1HIflAvDnNOt2jaL17vaW+1V0g== - -"@esbuild/linux-arm@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.16.17.tgz#b591e6a59d9c4fe0eeadd4874b157ab78cf5f196" - integrity sha512-iihzrWbD4gIT7j3caMzKb/RsFFHCwqqbrbH9SqUSRrdXkXaygSZCZg1FybsZz57Ju7N/SHEgPyaR0LZ8Zbe9gQ== - -"@esbuild/linux-ia32@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.16.17.tgz#24333a11027ef46a18f57019450a5188918e2a54" - integrity sha512-kiX69+wcPAdgl3Lonh1VI7MBr16nktEvOfViszBSxygRQqSpzv7BffMKRPMFwzeJGPxcio0pdD3kYQGpqQ2SSg== - -"@esbuild/linux-loong64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.16.17.tgz#d5ad459d41ed42bbd4d005256b31882ec52227d8" - integrity sha512-dTzNnQwembNDhd654cA4QhbS9uDdXC3TKqMJjgOWsC0yNCbpzfWoXdZvp0mY7HU6nzk5E0zpRGGx3qoQg8T2DQ== - -"@esbuild/linux-mips64el@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.16.17.tgz#4e5967a665c38360b0a8205594377d4dcf9c3726" - integrity sha512-ezbDkp2nDl0PfIUn0CsQ30kxfcLTlcx4Foz2kYv8qdC6ia2oX5Q3E/8m6lq84Dj/6b0FrkgD582fJMIfHhJfSw== - -"@esbuild/linux-ppc64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.16.17.tgz#206443a02eb568f9fdf0b438fbd47d26e735afc8" - integrity sha512-dzS678gYD1lJsW73zrFhDApLVdM3cUF2MvAa1D8K8KtcSKdLBPP4zZSLy6LFZ0jYqQdQ29bjAHJDgz0rVbLB3g== - -"@esbuild/linux-riscv64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.16.17.tgz#c351e433d009bf256e798ad048152c8d76da2fc9" - integrity sha512-ylNlVsxuFjZK8DQtNUwiMskh6nT0vI7kYl/4fZgV1llP5d6+HIeL/vmmm3jpuoo8+NuXjQVZxmKuhDApK0/cKw== - -"@esbuild/linux-s390x@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.16.17.tgz#661f271e5d59615b84b6801d1c2123ad13d9bd87" - integrity sha512-gzy7nUTO4UA4oZ2wAMXPNBGTzZFP7mss3aKR2hH+/4UUkCOyqmjXiKpzGrY2TlEUhbbejzXVKKGazYcQTZWA/w== - -"@esbuild/linux-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.16.17.tgz#e4ba18e8b149a89c982351443a377c723762b85f" - integrity sha512-mdPjPxfnmoqhgpiEArqi4egmBAMYvaObgn4poorpUaqmvzzbvqbowRllQ+ZgzGVMGKaPkqUmPDOOFQRUFDmeUw== - -"@esbuild/netbsd-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.16.17.tgz#7d4f4041e30c5c07dd24ffa295c73f06038ec775" - integrity sha512-/PzmzD/zyAeTUsduZa32bn0ORug+Jd1EGGAUJvqfeixoEISYpGnAezN6lnJoskauoai0Jrs+XSyvDhppCPoKOA== - -"@esbuild/openbsd-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.16.17.tgz#970fa7f8470681f3e6b1db0cc421a4af8060ec35" - integrity sha512-2yaWJhvxGEz2RiftSk0UObqJa/b+rIAjnODJgv2GbGGpRwAfpgzyrg1WLK8rqA24mfZa9GvpjLcBBg8JHkoodg== - -"@esbuild/sunos-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.16.17.tgz#abc60e7c4abf8b89fb7a4fe69a1484132238022c" - integrity sha512-xtVUiev38tN0R3g8VhRfN7Zl42YCJvyBhRKw1RJjwE1d2emWTVToPLNEQj/5Qxc6lVFATDiy6LjVHYhIPrLxzw== - -"@esbuild/win32-arm64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.16.17.tgz#7b0ff9e8c3265537a7a7b1fd9a24e7bd39fcd87a" - integrity sha512-ga8+JqBDHY4b6fQAmOgtJJue36scANy4l/rL97W+0wYmijhxKetzZdKOJI7olaBaMhWt8Pac2McJdZLxXWUEQw== - -"@esbuild/win32-ia32@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.16.17.tgz#e90fe5267d71a7b7567afdc403dfd198c292eb09" - integrity sha512-WnsKaf46uSSF/sZhwnqE4L/F89AYNMiD4YtEcYekBt9Q7nj0DiId2XH2Ng2PHM54qi5oPrQ8luuzGszqi/veig== - -"@esbuild/win32-x64@0.16.17": - version "0.16.17" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.17.tgz#c5a1a4bfe1b57f0c3e61b29883525c6da3e5c091" - integrity sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q== +"@esbuild/android-arm64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz#984b4f9c8d0377443cc2dfcef266d02244593622" + integrity sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ== + +"@esbuild/android-arm@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.18.20.tgz#fedb265bc3a589c84cc11f810804f234947c3682" + integrity sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw== + +"@esbuild/android-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.18.20.tgz#35cf419c4cfc8babe8893d296cd990e9e9f756f2" + integrity sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg== + +"@esbuild/darwin-arm64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz#08172cbeccf95fbc383399a7f39cfbddaeb0d7c1" + integrity sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA== + +"@esbuild/darwin-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz#d70d5790d8bf475556b67d0f8b7c5bdff053d85d" + integrity sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ== + +"@esbuild/freebsd-arm64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz#98755cd12707f93f210e2494d6a4b51b96977f54" + integrity sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw== + +"@esbuild/freebsd-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz#c1eb2bff03915f87c29cece4c1a7fa1f423b066e" + integrity sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ== + +"@esbuild/linux-arm64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz#bad4238bd8f4fc25b5a021280c770ab5fc3a02a0" + integrity sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA== + +"@esbuild/linux-arm@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz#3e617c61f33508a27150ee417543c8ab5acc73b0" + integrity sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg== + +"@esbuild/linux-ia32@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz#699391cccba9aee6019b7f9892eb99219f1570a7" + integrity sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA== + +"@esbuild/linux-loong64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz#e6fccb7aac178dd2ffb9860465ac89d7f23b977d" + integrity sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg== + +"@esbuild/linux-mips64el@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz#eeff3a937de9c2310de30622a957ad1bd9183231" + integrity sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ== + +"@esbuild/linux-ppc64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz#2f7156bde20b01527993e6881435ad79ba9599fb" + integrity sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA== + +"@esbuild/linux-riscv64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz#6628389f210123d8b4743045af8caa7d4ddfc7a6" + integrity sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A== + +"@esbuild/linux-s390x@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz#255e81fb289b101026131858ab99fba63dcf0071" + integrity sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ== + +"@esbuild/linux-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz#c7690b3417af318a9b6f96df3031a8865176d338" + integrity sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w== + +"@esbuild/netbsd-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz#30e8cd8a3dded63975e2df2438ca109601ebe0d1" + integrity sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A== + +"@esbuild/openbsd-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz#7812af31b205055874c8082ea9cf9ab0da6217ae" + integrity sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg== + +"@esbuild/sunos-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz#d5c275c3b4e73c9b0ecd38d1ca62c020f887ab9d" + integrity sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ== + +"@esbuild/win32-arm64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz#73bc7f5a9f8a77805f357fab97f290d0e4820ac9" + integrity sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg== + +"@esbuild/win32-ia32@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz#ec93cbf0ef1085cc12e71e0d661d20569ff42102" + integrity sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g== + +"@esbuild/win32-x64@0.18.20": + version "0.18.20" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz#786c5f41f043b07afb1af37683d7c33668858f6d" + integrity sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ== "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" @@ -5736,33 +5736,33 @@ es6-weak-map@^2.0.1: es6-iterator "^2.0.3" es6-symbol "^3.1.1" -esbuild@^0.16.14: - version "0.16.17" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.16.17.tgz#fc2c3914c57ee750635fee71b89f615f25065259" - integrity sha512-G8LEkV0XzDMNwXKgM0Jwu3nY3lSTwSGY6XbxM9cr9+s0T/qSV1q1JVPBGzm3dcjhCic9+emZDmMffkwgPeOeLg== +esbuild@^0.18.10: + version "0.18.20" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.18.20.tgz#4709f5a34801b43b799ab7d6d82f7284a9b7a7a6" + integrity sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA== optionalDependencies: - "@esbuild/android-arm" "0.16.17" - "@esbuild/android-arm64" "0.16.17" - "@esbuild/android-x64" "0.16.17" - "@esbuild/darwin-arm64" "0.16.17" - "@esbuild/darwin-x64" "0.16.17" - "@esbuild/freebsd-arm64" "0.16.17" - "@esbuild/freebsd-x64" "0.16.17" - "@esbuild/linux-arm" "0.16.17" - "@esbuild/linux-arm64" "0.16.17" - "@esbuild/linux-ia32" "0.16.17" - "@esbuild/linux-loong64" "0.16.17" - "@esbuild/linux-mips64el" "0.16.17" - "@esbuild/linux-ppc64" "0.16.17" - "@esbuild/linux-riscv64" "0.16.17" - "@esbuild/linux-s390x" "0.16.17" - "@esbuild/linux-x64" "0.16.17" - "@esbuild/netbsd-x64" "0.16.17" - "@esbuild/openbsd-x64" "0.16.17" - "@esbuild/sunos-x64" "0.16.17" - "@esbuild/win32-arm64" "0.16.17" - "@esbuild/win32-ia32" "0.16.17" - "@esbuild/win32-x64" "0.16.17" + "@esbuild/android-arm" "0.18.20" + "@esbuild/android-arm64" "0.18.20" + "@esbuild/android-x64" "0.18.20" + "@esbuild/darwin-arm64" "0.18.20" + "@esbuild/darwin-x64" "0.18.20" + "@esbuild/freebsd-arm64" "0.18.20" + "@esbuild/freebsd-x64" "0.18.20" + "@esbuild/linux-arm" "0.18.20" + "@esbuild/linux-arm64" "0.18.20" + "@esbuild/linux-ia32" "0.18.20" + "@esbuild/linux-loong64" "0.18.20" + "@esbuild/linux-mips64el" "0.18.20" + "@esbuild/linux-ppc64" "0.18.20" + "@esbuild/linux-riscv64" "0.18.20" + "@esbuild/linux-s390x" "0.18.20" + "@esbuild/linux-x64" "0.18.20" + "@esbuild/netbsd-x64" "0.18.20" + "@esbuild/openbsd-x64" "0.18.20" + "@esbuild/sunos-x64" "0.18.20" + "@esbuild/win32-arm64" "0.18.20" + "@esbuild/win32-ia32" "0.18.20" + "@esbuild/win32-x64" "0.18.20" escalade@^3.1.1: version "3.1.1" @@ -9711,10 +9711,10 @@ nanoid@3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -nanoid@^3.3.6: - version "3.3.6" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" - integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== +nanoid@^3.3.7: + version "3.3.7" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" + integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== natural-compare@^1.4.0: version "1.4.0" @@ -10791,12 +10791,12 @@ postcss-selector-parser@^6.0.10: cssesc "^3.0.0" util-deprecate "^1.0.2" -postcss@^8.4.21: - version "8.4.31" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d" - integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ== +postcss@^8.4.27: + version "8.4.33" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.33.tgz#1378e859c9f69bf6f638b990a0212f43e2aaa742" + integrity sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg== dependencies: - nanoid "^3.3.6" + nanoid "^3.3.7" picocolors "^1.0.0" source-map-js "^1.0.2" @@ -11465,10 +11465,10 @@ roarr@^2.15.3: semver-compare "^1.0.0" sprintf-js "^1.1.2" -rollup@^3.10.0: - version "3.17.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.17.2.tgz#a4ecd29c488672a0606e41ef57474fad715750a9" - integrity sha512-qMNZdlQPCkWodrAZ3qnJtvCAl4vpQ8q77uEujVCCbC/6CLB7Lcmvjq7HyiOSnf4fxTT9XgsE36oLHJBH49xjqA== +rollup@^3.27.1: + version "3.29.4" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.4.tgz#4d70c0f9834146df8705bfb69a9a19c9e1109981" + integrity sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw== optionalDependencies: fsevents "~2.3.2" @@ -12950,15 +12950,14 @@ version-guard@^1.1.1: resolved "https://registry.yarnpkg.com/version-guard/-/version-guard-1.1.1.tgz#7a6e87a1babff1b43d6a7b0fd239731e278262fa" integrity sha512-MGQLX89UxmYHgDvcXyjBI0cbmoW+t/dANDppNPrno64rYr8nH4SHSuElQuSYdXGEs0mUzdQe1BY+FhVPNsAmJQ== -vite@^4.1.1: - version "4.1.5" - resolved "https://registry.yarnpkg.com/vite/-/vite-4.1.5.tgz#9c93d579f62179ab99c4182fa37acf1b380a374b" - integrity sha512-zJ0RiVkf61kpd7O+VtU6r766xgnTaIknP/lR6sJTZq3HtVJ3HGnTo5DaJhTUtYoTyS/CQwZ6yEVdc/lrmQT7dQ== +vite@^4.5.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/vite/-/vite-4.5.1.tgz#3370986e1ed5dbabbf35a6c2e1fb1e18555b968a" + integrity sha512-AXXFaAJ8yebyqzoNB9fu2pHoo/nWX+xZlaRwoeYUxEqBO+Zj4msE5G+BhGBll9lYEKv9Hfks52PAF2X7qDYXQA== dependencies: - esbuild "^0.16.14" - postcss "^8.4.21" - resolve "^1.22.1" - rollup "^3.10.0" + esbuild "^0.18.10" + postcss "^8.4.27" + rollup "^3.27.1" optionalDependencies: fsevents "~2.3.2"