-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
close #6202
β Deploy Preview for nuxt3-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
β€οΈ
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was intentionally in top-level to match source and generated chunk path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a non-problem because we used to have only one file for this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
if (_distDir.endsWith('chunks')) { _distDir = dirname(_distDir) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated
@@ -58,7 +56,9 @@ export async function buildClient (ctx: ViteBuildContext) { | |||
rootDir: ctx.nuxt.options.rootDir, | |||
buildAssetsURL: joinURL(ctx.nuxt.options.app.baseURL, ctx.nuxt.options.app.buildAssetsDir) | |||
}), | |||
viteNodePlugin(ctx) | |||
ctx.nuxt.options.experimental.viteNode | |||
? await import('./vite-node').then(r => r.viteNodePlugin(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.ts
module being bundled intochunks/index.js
changes its relative path. Move it toutils
to make it consistent across dev and build.Also taking the chance to improve the code splitting by dynamically importing for optional plugins. Previously
vite-node
androllup-plugin-visualizer
are always imported regardless if the feature is enabled or not.π Checklist