Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow unocss config loading since v0.59.0 #3812

Open
4 tasks done
hi-ogawa opened this issue May 16, 2024 · 3 comments · May be fixed by #3814
Open
4 tasks done

Slow unocss config loading since v0.59.0 #3812

hi-ogawa opened this issue May 16, 2024 · 3 comments · May be fixed by #3814
Assignees

Comments

@hi-ogawa
Copy link

hi-ogawa commented May 16, 2024

UnoCSS version

0.60.2

Describe the bug

I was seeing slower startup when integrating unocss in a recent project and it looks like this is happening since v0.59.0.
It might not be noticeable on a decent PC, but I happen to be (temporary) using a worst laptop and this felt like a significant slow down (for exampele, from 608.85ms to 2.020s in a stackblitz reproduction below).

I briefly checked perf from node --inspect-brk repro.mjs and it appears that jiti (used by unconfig, which in turn used by @unocss/config) is taking a long time transforming something. I'm suspecting this might be because jiti is transforming entire unocss after it became esm only.

Show screenshot of performance devtools

image

Reproduction

https://github.com/hi-ogawa/reproductions/tree/main/unocss-jiti-esm-slow-config
https://stackblitz.com/github/hi-ogawa/reproductions/tree/main/unocss-jiti-esm-slow-config?file=repro.mjs

// node repro.mjs
import { loadConfig } from "@unocss/config";

console.time("[loadConfig]");
console.log(await loadConfig());
console.timeEnd("[loadConfig]");
$ npm install && (node repro.mjs && (cd fast && npm i && node repro.mjs))
... on v0.60.2 ...
{
  config: {},
  sources: [ '/home/projects/qgnigvkoz.github/uno.config.ts' ]
}
[loadConfig]: 2.020s

... on v0.58.9 ...
{
  config: {},
  sources: [ '/home/projects/qgnigvkoz.github/fast/uno.config.ts' ]
}
[loadConfig]: 608.85ms

System Info

(stackblitz)

Validations

@userquin
Copy link
Member

On my latpop also reproducible (i7 12700H):

  • v0.58.9: [loadConfig]: 889.937ms
  • v0.60.2: [loadConfig]: 1.620s

@userquin
Copy link
Member

@hi-ogawa you can provide cwd and file name when loading the configuration: await loadConfig(process.cwd(), 'unocss.config.ts'):

  • v0.58.9: [loadConfig]: 225.94ms
  • v0.60.2: [loadConfig]: 664.644ms

@userquin
Copy link
Member

userquin commented May 16, 2024

Using in the reproductions (preparing PR):

	"overrides": {
		"unconfig": "0.4.1"
	}
  • v0.58.9: [loadConfig]: 215.667ms
  • v0.60.2: [loadConfig]: 203.762ms

antfu added a commit that referenced this issue May 16, 2024
@antfu antfu linked a pull request May 16, 2024 that will close this issue
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 a pull request may close this issue.

2 participants