From f6a7824597f92b561aa70ae927f8e5d652195af1 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Wed, 17 Jul 2024 09:35:02 +0200 Subject: [PATCH] =?UTF-8?q?Only=20add=20framework=20component=20formats=20?= =?UTF-8?q?to=20Vite=E2=80=99s=20`optimizeDeps`=20(#11472)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bjorn Lu --- .changeset/chatty-spies-jog.md | 5 +++++ packages/astro/src/core/create-vite.ts | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 .changeset/chatty-spies-jog.md diff --git a/.changeset/chatty-spies-jog.md b/.changeset/chatty-spies-jog.md new file mode 100644 index 0000000000..e95591d911 --- /dev/null +++ b/.changeset/chatty-spies-jog.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Avoids targeting all files in the `src/` directory for eager optimization by Vite. After this change, only JSX, Vue, Svelte, and Astro components get scanned for early optimization. diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index e07150c39d..bac87bf723 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -120,13 +120,8 @@ export async function createVite( customLogger: createViteLogger(logger, settings.config.vite.logLevel), appType: 'custom', optimizeDeps: { - // Scan all files within `srcDir` except for known server-code (e.g endpoints) - entries: [ - `${srcDirPattern}!(pages)/**/*`, // All files except for pages - `${srcDirPattern}pages/**/!(*.js|*.mjs|*.ts|*.mts)`, // All pages except for endpoints - `${srcDirPattern}pages/**/_*.{js,mjs,ts,mts}`, // Remaining JS/TS files prefixed with `_` (not endpoints) - `${srcDirPattern}pages/**/_*/**/*.{js,mjs,ts,mts}`, // Remaining JS/TS files within directories prefixed with `_` (not endpoints) - ], + // Scan for component code within `srcDir` + entries: [`${srcDirPattern}**/*.{jsx,tsx,vue,svelte,html,astro}`], exclude: ['astro', 'node-fetch'], }, plugins: [