Skip to content

fix: normalize config.root - #443

Merged
antfu merged 5 commits into
unplugin:mainfrom
bufan-huang:main
Dec 3, 2023
Merged

fix: normalize config.root#443
antfu merged 5 commits into
unplugin:mainfrom
bufan-huang:main

Conversation

@bufan-huang

Copy link
Copy Markdown
Contributor

c2440d46ed9f4b1f2fd740dfe862f10

Invalid sorting of type file generation, resulting in unnecessary git versions
Reading DTS file is empty while writing the file is incomplete

vite

Debugger attached.
环境变量 VITE_DROP_CONSOLE undefined
configResolved 《======= 【Trigger Event 1】
scanDirs writeConfigFilesThrottled
writeConfigFiles
readFile Ing 1700340039378 《======= 【Trigger Event 1 readFile Ing】
originalContent:/* eslint-disable /
/
prettier-ignore /
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const $: typeof import('vue/macros')['$']
const $$: typeof import('vue/macros')['$$']
const $computed: typeof import('vue/macros')['$c 1700340039385
content !== lastDTS writeFile true
buildStart 《======= 【Trigger Event 2】
scanDirs writeConfigFilesThrottled
writeConfigFiles
readFile Ing 1700340039970 《======= 【Trigger Event 2 readFile Ing】
writeFile ing : 《======= 【Trigger Event 1 writeFile Ing】
E:\hby\project*
*\packages\vite-vue3-admin-main\auto-imports.d.ts
/
eslint-disable /
/
prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const $: typeof import('vue/macros')['$']
const $$: typeof import('vue/macros')['$$']
const $computed: typeof import('vue/macros')['$c 1700340039988

VITE v4.5.0 ready in 7238 ms

➜ Local: http://localhost:8088/
➜ Network: http://198.18.0.1:8088/
➜ Network: http://192.168.110.110:8088/
➜ press h to show help
originalContent: 1700340040095 《======= 【Trigger Event 2 readFile End content empty】
content !== lastDTS writeFile false
writeFile end : 1700340040098 《======= 【Trigger Event 1 writeFile End】
writeFile ing :
E:\hby\project**\packages\vite-vue3-admin-main\auto-imports.d.ts
/* eslint-disable /
/
prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const $$: typeof import('vue/macros')['$$']
const $: typeof import('vue/macros')['$']
const $computed: typeof import('vue/macros')['$c 1700340040104
writeFile end : 1700340040115

It was found that the configResolved event triggered writing to the file while the buildStart event triggered it

Vite related pr
vitejs/vite#1693

fea7d33124812fd4a4a5bcf5b2186c3
Can also read file locks

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment thread src/core/ctx.ts Outdated
const isWindows = os.platform() === 'win32'

export function createContext(options: Options = {}, root = process.cwd()) {
root = isWindows ? slash(root) : root

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could always slash without checking with os

@antfu antfu changed the title fix: config.root for win32 fix: normalize config.root Dec 3, 2023
@antfu
antfu merged commit 35d46e2 into unplugin:main Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants