mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-19 01:45:53 +00:00
fix(nuxt): don't exclude pnpm layers from nitro esbuild/imports (#9952)
This commit is contained in:
parent
1b888b4223
commit
e451a9965e
@ -16,6 +16,18 @@ import { ImportProtectionPlugin } from './plugins/import-protection'
|
|||||||
export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||||
// Resolve config
|
// Resolve config
|
||||||
const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig
|
const _nitroConfig = ((nuxt.options as any).nitro || {}) as NitroConfig
|
||||||
|
|
||||||
|
const excludePaths = nuxt.options._layers
|
||||||
|
.flatMap(l => [
|
||||||
|
l.cwd.match(/(?<=\/)node_modules\/(.+)$/)?.[1],
|
||||||
|
l.cwd.match(/\.pnpm\/.+\/node_modules\/(.+)$/)?.[1]
|
||||||
|
])
|
||||||
|
.filter((dir): dir is string => Boolean(dir))
|
||||||
|
.map(dir => escapeRE(dir))
|
||||||
|
const excludePattern = excludePaths.length
|
||||||
|
? [new RegExp(`node_modules\\/(?!${excludePaths.join('|')})`)]
|
||||||
|
: [/node_modules/]
|
||||||
|
|
||||||
const nitroConfig: NitroConfig = defu(_nitroConfig, <NitroConfig>{
|
const nitroConfig: NitroConfig = defu(_nitroConfig, <NitroConfig>{
|
||||||
debug: nuxt.options.debug,
|
debug: nuxt.options.debug,
|
||||||
rootDir: nuxt.options.rootDir,
|
rootDir: nuxt.options.rootDir,
|
||||||
@ -35,14 +47,11 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
|||||||
name: 'publicAssetsURL',
|
name: 'publicAssetsURL',
|
||||||
from: resolve(distDir, 'core/runtime/nitro/paths')
|
from: resolve(distDir, 'core/runtime/nitro/paths')
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
exclude: [...excludePattern, /[\\/]\.git[\\/]/]
|
||||||
},
|
},
|
||||||
esbuild: {
|
esbuild: {
|
||||||
options: {
|
options: { exclude: excludePattern }
|
||||||
exclude: [
|
|
||||||
new RegExp(`node_modules\\/(?!${nuxt.options._layers.map(l => l.cwd.match(/(?<=\/)node_modules\/(.+)$/)?.[1]).filter(Boolean).map(dir => escapeRE(dir!)).join('|')})`)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
analyze: nuxt.options.build.analyze && {
|
analyze: nuxt.options.build.analyze && {
|
||||||
template: 'treemap',
|
template: 'treemap',
|
||||||
|
Loading…
Reference in New Issue
Block a user