Skip to content
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

version on react + run prettier #537

Merged
merged 3 commits into from
Aug 18, 2023
Merged

version on react + run prettier #537

merged 3 commits into from
Aug 18, 2023

Conversation

rishi-raj-jain
Copy link
Contributor

@rishi-raj-jain rishi-raj-jain commented Aug 17, 2023

fix #534
/claim #534

Please describe the changes this PR makes and why it should be merged:

Status

  • Code changes have been tested against prettier, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the codebase
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
    • This PR changes the internal workings with no modifications to the external API (bug fixes, performance improvements)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@vercel
Copy link

vercel bot commented Aug 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
million-kitchen-sink ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 17, 2023 6:43am
sink ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 17, 2023 6:43am

@CLAassistant
Copy link

CLAassistant commented Aug 17, 2023

CLA assistant check
All committers have signed the CLA.

@rishi-raj-jain
Copy link
Contributor Author

So found that the errors in react 16 & 17 were of using createRoot (as it's not available in those versions).

Tested with all the versions, react 16, 17 and 18 with a vite project, by replacing the node_modules/million/dist with the locally built one (by pnpm build)

@rishi-raj-jain
Copy link
Contributor Author

@aidenybai

Do I need to do anymore changes?

@aidenybai
Copy link
Owner

good work!

@aidenybai aidenybai merged commit 76c244e into aidenybai:main Aug 18, 2023
: (parent[REACT_ROOT] = createRoot(parent));
root.render(vnode);
if (version.startsWith('18')) {
import('react-dom/client')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break Webpack which will attempt to import react-dom/client even if using react 17 because bundlers are not smart enough to evaluate version.startsWith('18').

I tested with and got the following error on https://github.com/getsentry/sentry (which uses React 17).

ERROR in ../node_modules/million/dist/chunks/utils.mjs 46:6-32
Module not found: Error: Can't resolve 'react-dom/client' in '/Users/abhijeetprasad/workspace/sentry/node_modules/million/dist/chunks'
resolve 'react-dom/client' in '/Users/abhijeetprasad/workspace/sentry/node_modules/million/dist/chunks'
  Parsed request is a module
  using description file: /Users/abhijeetprasad/workspace/sentry/node_modules/million/package.json (relative path: ./dist/chunks)

IMO the more holistic solution is to actually not do this built time - but instead split up the renderReactScope function into renderReactScopev17andbelow and renderReactScope and inject different one's depending on what version of react you're using, so we take care of this at built time instead of run time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried adding million to https://github.com/romansndlr/react-vite-realworld-example-app with this patch (vite app using React 17) and things broke during build as well.

[vite]: Rollup failed to resolve import "react-dom/client" from ".yalc/million/dist/chunks/utils.mjs".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "react-dom/client" from ".yalc/million/dist/chunks/utils.mjs".
This is most likely unintended because it can break your application at runtime.

.yalc comes from https://github.com/wclr/yalc - which is what I used to test million locally.

Copy link
Contributor Author

@rishi-raj-jain rishi-raj-jain Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think million new version containing this fix is yet to be released. Can you try replacing the node_modules/million/dist folder with the node_modules/million/dist folder from this PR's build?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worthwhile to also test Next 12 - which many folks are still using because they can't upgrade to Next 13 yet, and Next 12 uses React 17 by default.

Next.js and it's webpack setup might also cause issues here.

Copy link
Contributor

@AbhiPrasad AbhiPrasad Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think million new version containing this fix is yet to be released. Can you try replacing the dist folder with the dist folder from this?

I'm using the most recent version on master branch! I built the repo locally and directly imported it into my project via yalc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, appreciate the feedback and you reaching out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[$35] Support React 16 + 17
4 participants