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

feat(remix): Add dynamic loading of @remix-run/router module. #10458

Closed
wants to merge 1 commit into from

Conversation

onurtemizkan
Copy link
Collaborator

Potentially fixes: #10349

Added dynamic loading support for @remix-run/router package as a provider of matchRoutes. matchRoutes from react-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 latest 1.x version.

Don't have the reproduction of the original issue, but I expect this PR to resolve that problem.

Copy link
Contributor

github-actions bot commented Feb 1, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 78.14 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.38 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 73.3 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.99 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.38 KB (0%)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 33.25 KB (0%)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.33 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.34 KB (0%)
@sentry/browser - Webpack (gzipped) 22.6 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 76.1 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.66 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.5 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.66 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 213.5 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 101.49 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 74.01 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.63 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.73 KB (+0.01% 🔺)
@sentry/react - Webpack (gzipped) 22.63 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.5 KB (+0.01% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.8 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (0%)

try {
pkg = await import(moduleName);
} catch (e) {
pkg = await import(`${cwd()}/node_modules/${moduleName}`);
Copy link
Member

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?

Copy link
Collaborator Author

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?

Copy link
Member

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.

@onurtemizkan onurtemizkan deleted the onur/remix-load-remix/router branch February 2, 2024 14:38
AbhiPrasad pushed a commit that referenced this pull request Feb 21, 2024
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.
onurtemizkan added a commit that referenced this pull request Feb 21, 2024
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.
AbhiPrasad pushed a commit that referenced this pull request Feb 21, 2024
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.
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.

Unable to initialize on server infrastructure (backend use-case)
2 participants