From 2d347f546e9907b07c5bd8a33d049a67d44e197e Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 15 Nov 2022 13:52:16 +0000 Subject: [PATCH] fix(nuxt): include layers in esbuild transform (#9014) --- packages/nuxt/src/core/nitro.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index c075a3efcebc..3d3797cdc26d 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -4,6 +4,7 @@ import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTy import type { NitroConfig } from 'nitropack' import type { Nuxt } from '@nuxt/schema' import { resolvePath } from '@nuxt/kit' +import escapeRE from 'escape-string-regexp' import defu from 'defu' import fsExtra from 'fs-extra' import { dynamicEventHandler } from 'h3' @@ -21,6 +22,13 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { srcDir: nuxt.options.serverDir, dev: nuxt.options.dev, 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 && { template: 'treemap', projectRoot: nuxt.options.rootDir,