From 2ccd0154222bb0d4f5ec08b9fe801348b437b653 Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 8 Jan 2025 00:01:33 +0800 Subject: [PATCH 1/2] Remove custom optimizeDeps.include in react and vue integration --- .changeset/brown-flies-repeat.md | 5 +++++ .changeset/curvy-pans-share.md | 5 +++++ .changeset/smart-ties-hear.md | 5 +++++ packages/integrations/react/src/index.ts | 12 +----------- packages/integrations/solid/src/index.ts | 1 + packages/integrations/vue/src/index.ts | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 .changeset/brown-flies-repeat.md create mode 100644 .changeset/curvy-pans-share.md create mode 100644 .changeset/smart-ties-hear.md diff --git a/.changeset/brown-flies-repeat.md b/.changeset/brown-flies-repeat.md new file mode 100644 index 000000000000..a19bfcdd106b --- /dev/null +++ b/.changeset/brown-flies-repeat.md @@ -0,0 +1,5 @@ +--- +'@astrojs/vue': patch +--- + +Removes vue-specific entrypoints in `optimizeDeps.include` and rely on `@vitejs/plugin-vue` to add diff --git a/.changeset/curvy-pans-share.md b/.changeset/curvy-pans-share.md new file mode 100644 index 000000000000..df4ef548abf2 --- /dev/null +++ b/.changeset/curvy-pans-share.md @@ -0,0 +1,5 @@ +--- +'@astrojs/solid-js': patch +--- + +Adds the client entrypoint to `optimizeDeps.include` diff --git a/.changeset/smart-ties-hear.md b/.changeset/smart-ties-hear.md new file mode 100644 index 000000000000..0921ff671819 --- /dev/null +++ b/.changeset/smart-ties-hear.md @@ -0,0 +1,5 @@ +--- +'@astrojs/react': patch +--- + +Removes react-specific entrypoints in `optimizeDeps.include` and rely on `@vitejs/plugin-react` to add diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts index b1effa27a044..46da29c7b9fd 100644 --- a/packages/integrations/react/src/index.ts +++ b/packages/integrations/react/src/index.ts @@ -54,20 +54,10 @@ function getViteConfiguration( ) { return { optimizeDeps: { - include: [ - reactConfig.client, - 'react', - 'react/jsx-runtime', - 'react/jsx-dev-runtime', - 'react-dom', - 'react-compiler-runtime', - ], + include: [reactConfig.client], exclude: [reactConfig.server], }, plugins: [react({ include, exclude, babel }), optionsPlugin(!!experimentalReactChildren)], - resolve: { - dedupe: ['react', 'react-dom', 'react-dom/server'], - }, ssr: { external: reactConfig.externals, noExternal: [ diff --git a/packages/integrations/solid/src/index.ts b/packages/integrations/solid/src/index.ts index 60680ff9c3de..f39dffed59b5 100644 --- a/packages/integrations/solid/src/index.ts +++ b/packages/integrations/solid/src/index.ts @@ -51,6 +51,7 @@ function getViteConfiguration( ) { const config: UserConfig = { optimizeDeps: { + include: ['@astrojs/solid-js/client.js'], exclude: ['@astrojs/solid-js/server.js'], }, plugins: [solid({ include, exclude, ssr: true })], diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index fc54a5f99a98..c454d913a329 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -116,7 +116,7 @@ async function getViteConfiguration( const config: UserConfig = { optimizeDeps: { - include: ['@astrojs/vue/client.js', 'vue'], + include: ['@astrojs/vue/client.js'], exclude: ['@astrojs/vue/server.js', VIRTUAL_MODULE_ID], }, plugins: [vue(vueOptions), virtualAppEntrypoint(vueOptions)], From 5f05c9ee28113085831854f0ef3c0512202e5f06 Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 8 Jan 2025 00:06:46 +0800 Subject: [PATCH 2/2] Revert vue change --- .changeset/brown-flies-repeat.md | 5 ----- packages/integrations/vue/src/index.ts | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 .changeset/brown-flies-repeat.md diff --git a/.changeset/brown-flies-repeat.md b/.changeset/brown-flies-repeat.md deleted file mode 100644 index a19bfcdd106b..000000000000 --- a/.changeset/brown-flies-repeat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/vue': patch ---- - -Removes vue-specific entrypoints in `optimizeDeps.include` and rely on `@vitejs/plugin-vue` to add diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index c454d913a329..d9e42a6dd248 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -116,7 +116,9 @@ async function getViteConfiguration( const config: UserConfig = { optimizeDeps: { - include: ['@astrojs/vue/client.js'], + // We add `vue` here as `@vitejs/plugin-vue` doesn't add it and we want to prevent + // re-optimization if the `vue` import is only encountered later. + include: ['@astrojs/vue/client.js', 'vue'], exclude: ['@astrojs/vue/server.js', VIRTUAL_MODULE_ID], }, plugins: [vue(vueOptions), virtualAppEntrypoint(vueOptions)],