Conversation
close #6202
✅ Deploy Preview for nuxt3-docs canceled.
|
packages/vite/src/utils/dirs.ts
Outdated
| import { fileURLToPath } from 'node:url' | ||
| import { resolve } from 'pathe' | ||
|
|
||
| export const distDir = resolve(fileURLToPath(import.meta.url), '../..') |
There was a problem hiding this comment.
This file was intentionally in top-level to match source and generated chunk path.
There was a problem hiding this comment.
Yes, but unbuild always extracts it into a chunk even when I have directly imported it in index.ts. Or maybe we need another top-level export dirs to make sure it's always on top-level?
There was a problem hiding this comment.
It was a non-problem because we used to have only one file for this package.
There was a problem hiding this comment.
I see. The only issue is that is approach can be easily broken if chunk generation changes with unbuild>rollup.
Currently, we use this workaround for the main nuxt pkg:
framework/packages/nuxt/src/dirs.ts
Line 5 in 5a042cd
| }), | ||
| viteNodePlugin(ctx) | ||
| ctx.nuxt.options.experimental.viteNode | ||
| ? await import('./vite-node').then(r => r.viteNodePlugin(ctx)) |
There was a problem hiding this comment.
Since this is going to be the default option, I think we can safely import it normally when removed experimental flag. Difference is small but rollup this way can optimize startup time to add nested dependencies to top level dist/index.mjs
🔗 Linked issue
close nuxt/nuxt#14446
❓ Type of change
📚 Description
The cause of nuxt/nuxt#14446 is that the
dirs.tsmodule being bundled intochunks/index.jschanges its relative path. Move it toutilsto make it consistent across dev and build.Also taking the chance to improve the code splitting by dynamically importing for optional plugins. Previously
vite-nodeandrollup-plugin-visualizerare always imported regardless if the feature is enabled or not.📝 Checklist