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

Add dom subpath export #11851

Merged
merged 7 commits into from
Jul 30, 2024
Merged

Add dom subpath export #11851

merged 7 commits into from
Jul 30, 2024

Conversation

brophdawg11
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Jul 29, 2024

🦋 Changeset detected

Latest commit: 1185365

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
react-router Major
@react-router/architect Major
@react-router/cloudflare Major
@react-router/dev Major
react-router-dom Major
@react-router/express Major
@react-router/node Major
@react-router/serve Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -0,0 +1,3 @@
export type { RouterProviderProps } from "./lib/dom-export/dom-router-provider";
export { RouterProvider } from "./lib/dom-export/dom-router-provider";
export { HydratedRouter } from "./lib/dom-export/hydrated-router";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming of this file may be temporary - went with dom-export to avoid ambiguity with the existing dom/ folder containing the old react-router-dom implementation - but open to suggestions

@@ -338,32 +337,70 @@ export type {
///////////////////////////////////////////////////////////////////////////////

/** @internal */
export { ErrorResponseImpl as UNSAFE_ErrorResponseImpl } from "./lib/router/utils";
export {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to export a bunch of stuff as UNSAFE here to consume from the subpath export file to avoid duplicating any implementations

*/
export function RouterProvider({
router,
flushSync: reactDomFlushSyncImpl,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same implementation as before, copied into here but with flushSync dependency injected via a prop

Comment on lines +234 to +254
warnOnce(
flushSync === false || reactDomFlushSyncImpl != null,
"You provided the `unstable_flushSync` option to a router update, " +
"but you are not using the `<RouterProvider>` from `react-router/dom` " +
"so `ReactDOM.flushSync()` is unavailable. Please update your app " +
'to `import { RouterProvider } from "react-router/dom"` and ensure ' +
"you have `react-dom` installed as a dependency to use the " +
"`unstable_flushSync` option."
);

let isViewTransitionAvailable =
router.window != null &&
router.window.document != null &&
typeof router.window.document.startViewTransition === "function";

warnOnce(
viewTransitionOpts == null || isViewTransitionAvailable,
"You provided the `unstable_viewTransition` option to a router update, " +
"but you do not appear to be running in a DOM environment as " +
"`window.startViewTransition` is not available."
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Helpful warnings we didn't have before

await setup({ base: "/mybase/", basename: "/mybase/app/" });
await workflowDev({ page, cwd, port, basename: "/mybase/app/" });
await setup({ base: "/mybase/", basename: "/mybase/dashboard/" });
await workflowDev({ page, cwd, port, basename: "/mybase/dashboard/" });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to avoid ambiguity between the app URL path and the app folder in requests in vite dev mode

@brophdawg11 brophdawg11 merged commit 626bc84 into dev Jul 30, 2024
8 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/dom-export branch July 30, 2024 16:18
Copy link
Contributor

🤖 Hello there,

We just published version 6.28.2-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

Successfully merging this pull request may close these issues.

1 participant