Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

React is not externaled when optimizing deps #4

Closed
csr632 opened this issue May 21, 2020 · 0 comments · Fixed by vitejs/vite#218 or #5
Closed

React is not externaled when optimizing deps #4

csr632 opened this issue May 21, 2020 · 0 comments · Fixed by vitejs/vite#218 or #5

Comments

@csr632
Copy link
Member

csr632 commented May 21, 2020

image

Reproduce:

https://github.com/csr632/test-vite/tree/debug-plugin-react
After optimize, go to node_modules/.vite_opt_cache/styled-components, search for react.development.js in it. You can see react is bundled.

Investigate

When optimizing styled-components, react is resolved into @pika/react/source.development.js:
https://github.com/vitejs/vite-plugin-react/blob/a37f540ab16bfe256273b7719e9432a4b3b4efdf/src/resolver.ts#L7

but the rollup external config is @pika/react
image

Fix

vitejs/vite#218 and vitejs/vite-plugin-react#5 fix this.
I resolve the rollup external config with resolver before calling rollup to optimize. So that the rollup external config will be @pika/react/source.development.js instead of @pika/react.

@csr632 csr632 changed the title React is bundled when optimizing deps React is not externaled when optimizing deps May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant