Open zycoJamie opened 9 months ago
You probably need to add your theme to vite.ssr.noExternal in config. Can you share a repo where I can reproduce this?
I write following code in my theme config,
vite: {
optimizeDeps: {
exclude: ["my-theme-name"],
},
The error is resolved, but is it bug of vite's "optimizeDeps"? The variable of Symbol is extracted and it is duplicated.
Describe the bug
Custom theme is a npm package, layout of the theme is following:
configProvider's source is following:
themeConfig is a Symbol in configProvider.
when i setup vitepress and use custom theme in development "vitepress dev", i get an error.
In .vitepress/cache/deps, myTheme.js has a duplicated themeConfig variable.
but in Layout.vue it uses Header and Header uses themeConfig that is a Symbol:
In Header.vue, themeConfig exists in myTheme/src/compositions/configProvider.ts, but in .vitepress/cache/deps/myTheme.js, it also exits a themeConfig. two themeConfig, two Symbol. In the result, provide/inject is fail.
In development this is bad, in production, the configProvider module is not extracted, the themeConfig variable is unique.
Reproduction
as mentioned earlier
Expected behavior
In development, some es module that come from node_modules ain't extracted, the variable don't be duplicated.
System Info
Additional context
No response
Validations