mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +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 }) {
|
||||
// Resolve config
|
||||
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>{
|
||||
debug: nuxt.options.debug,
|
||||
rootDir: nuxt.options.rootDir,
|
||||
@ -35,14 +47,11 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
||||
name: 'publicAssetsURL',
|
||||
from: resolve(distDir, 'core/runtime/nitro/paths')
|
||||
}
|
||||
]
|
||||
],
|
||||
exclude: [...excludePattern, /[\\/]\.git[\\/]/]
|
||||
},
|
||||
esbuild: {
|
||||
options: {
|
||||
exclude: [
|
||||
new RegExp(`node_modules\\/(?!${nuxt.options._layers.map(l => l.cwd.match(/(?<=\/)node_modules\/(.+)$/)?.[1]).filter(Boolean).map(dir => escapeRE(dir!)).join('|')})`)
|
||||
]
|
||||
}
|
||||
options: { exclude: excludePattern }
|
||||
},
|
||||
analyze: nuxt.options.build.analyze && {
|
||||
template: 'treemap',
|
||||
|
Loading…
Reference in New Issue
Block a user