-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
feat(remix): Add dynamic loading of @remix-run/router
module.
#10458
Conversation
size-limit report 📦
|
try { | ||
pkg = await import(moduleName); | ||
} catch (e) { | ||
pkg = await import(`${cwd()}/node_modules/${moduleName}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work in CJS right? Can you confirm that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a little research, but could not produce a case where this breaks. It looks like it works fine on both CJS and ESM. Not in worker environments though.
But, while checking the previous discussions (#5897), the main reason we need this was our TS version and it's up to date now, so we can just try making @remix-run/router
a dependency and stop doing this anyways? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we can just try making @remix-run/router a dependency and stop doing this anyways? WDYT
Let's do that instead!! Less dynamic imports the better.
Backports #10479 to v7 branch Original PR Description: > Fixes: #10349 > Related: #5860 > Related: #10458 > > Removes dynamic loading of `react-router-dom` and makes `@remix-run/router` a peer dependency. > > We don't need to dynamically load `react-router-dom` as our TypeScript version is now up-to-date.
Potentially fixes: #10349
Added dynamic loading support for
@remix-run/router
package as a provider ofmatchRoutes
.matchRoutes
fromreact-router-dom
and@remix-run/router
can be used interchangeably for our use case.Also updated integration tests' Remix version to
1.19.3
which is the latest1.x
version.Don't have the reproduction of the original issue, but I expect this PR to resolve that problem.