You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Michael/Ryan both seem to recall the only reason react-router-dom/server was broken out was at one point it was using a node-only API and couldn't be exported through the main bundle. That's not the case anymore though so with ESM working and tree-shaking we're inclined to just export StaticRouter out through the main bundle so you could:
import{StaticRouter}from"react-router-dom";
This would be a great way to simplify the API. It would also have benefits for Typescript usage.
While the original comment suggests to just export StaticRouter from the main file, I think this would create a circular dependency, because react-router-dom/server also depends on react-router-dom. To avoid a circular dependency, StaticRouter should be moved to the main file.
If backwards compatibility is desired, server.js and server.mjs could have some equivalent of:
Also, I suspect there is also a separate issue with Node.js in ESM mode related to internal imports between different files, but it is difficult to demonstrate right now. This change would simplify the internal imports, hopefully resolving all issues. Even if some issues remain, it would make it easier to test, investigate, understand and follow up on those issues separately.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As discussed in #8268, there are some rough edges when using React Router in ES Module mode in a Node.js application.
As proposed in this comment: #8268 (comment)
This would be a great way to simplify the API. It would also have benefits for Typescript usage.
While the original comment suggests to just export StaticRouter from the main file, I think this would create a circular dependency, because
react-router-dom/server
also depends onreact-router-dom
. To avoid a circular dependency, StaticRouter should be moved to the main file.If backwards compatibility is desired,
server.js
andserver.mjs
could have some equivalent of:Also, I suspect there is also a separate issue with Node.js in ESM mode related to internal imports between different files, but it is difficult to demonstrate right now. This change would simplify the internal imports, hopefully resolving all issues. Even if some issues remain, it would make it easier to test, investigate, understand and follow up on those issues separately.
Beta Was this translation helpful? Give feedback.
All reactions