fix(nuxt): include layers in esbuild transform (#9014)

This commit is contained in:
Daniel Roe 2022-11-15 13:52:16 +00:00 committed by GitHub
parent 74b81bbeaa
commit 4c8369fbf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTy
import type { NitroConfig } from 'nitropack' import type { NitroConfig } from 'nitropack'
import type { Nuxt } from '@nuxt/schema' import type { Nuxt } from '@nuxt/schema'
import { resolvePath } from '@nuxt/kit' import { resolvePath } from '@nuxt/kit'
import escapeRE from 'escape-string-regexp'
import defu from 'defu' import defu from 'defu'
import fsExtra from 'fs-extra' import fsExtra from 'fs-extra'
import { dynamicEventHandler } from 'h3' import { dynamicEventHandler } from 'h3'
@ -21,6 +22,13 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
srcDir: nuxt.options.serverDir, srcDir: nuxt.options.serverDir,
dev: nuxt.options.dev, dev: nuxt.options.dev,
buildDir: nuxt.options.buildDir, buildDir: nuxt.options.buildDir,
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('|')})`)
]
}
},
analyze: nuxt.options.build.analyze && { analyze: nuxt.options.build.analyze && {
template: 'treemap', template: 'treemap',
projectRoot: nuxt.options.rootDir, projectRoot: nuxt.options.rootDir,