-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): always alias React/ReactDOM to site dependency so that importing MDX from anywhere works #10391
Conversation
⚡️ Lighthouse report for the deploy preview of this PR
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
Size Change: +1.62 kB (+0.01%) Total Size: 11.6 MB
ℹ️ View Unchanged
|
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
FWIW, webpack itself advertises against this kind of aliasing, because it couples the build output to the file location and moving the file would bust the cache, generate different hashes, etc. Doesn't seem like a big deal though. |
Note for history: Next.js is doing something quite similar here: https://github.com/vercel/next.js/pull/69142/files |
Motivation
This implements the suggestion here: #9027 (comment)
Using aliases ensures that when importing MDX partials from anywhere, React will always resolve to the site version instead of the local version.
Maybe it will cause problems for some sites so I'm including a secret env variable to disable this behavior, just in case. If you use it, please let us know why.
Test Plan
Dogfood test:
Test links
https://deploy-preview-10391--docusaurus-2.netlify.app/tests/docs/tests/import-bad-package