Skip to content

Commit

Permalink
chore: use universal-env
Browse files Browse the repository at this point in the history
  • Loading branch information
HomyeeKing committed Mar 18, 2024
1 parent ce0bee0 commit 98f5dff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"postinstall": "node ./scripts/postinstall.mjs"
},
"devDependencies": {
"@remix-run/web-fetch": "^4.3.3",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"regenerator-runtime": "^0.13.9",
"@remix-run/web-fetch": "^4.3.3"
"regenerator-runtime": "^0.13.9"
},
"sideEffects": [
"./esm/polyfills/signal.js",
Expand All @@ -62,7 +62,8 @@
"htmlparser2": "^8.0.1",
"react-router-dom": "6.21.3",
"semver": "^7.4.0",
"source-map": "^0.7.4"
"source-map": "^0.7.4",
"universal-env": "^3.3.3"
},
"peerDependencies": {
"react": "^18.1.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/runtime/src/dynamic.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { ReactNode } from 'react';
import React, { Suspense, lazy } from 'react';
import { isNode } from 'universal-env';
import useMounted from './useMounted.js';

const isServer = import.meta.renderer === 'server';

type ComponentModule<P = {}> = { default: React.ComponentType<P> };

export type LoaderComponent<P = {}> = Promise<React.ComponentType<P> | ComponentModule<P>>;
Expand Down Expand Up @@ -36,7 +35,7 @@ export function dynamic<P = {}>(loader: Loader<P>, option?: DynamicOptions) {
if (!realLoader) return DefaultFallback;
const Fallback = fallback;

if (!ssr && isServer) {
if (!ssr && isNode) {
return () => <Fallback />;
}

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98f5dff

Please sign in to comment.