From f964011af120187c004a58f313f8d3678f888d93 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 13 Jan 2022 10:45:01 +0700 Subject: [PATCH] fixed next module loading and undefined document --- next.config.js | 5 +++++ package.json | 1 + src/containers/main/SidebarRouter/index.tsx | 4 ++++ yarn.lock | 10 +++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 next.config.js diff --git a/next.config.js b/next.config.js new file mode 100644 index 00000000..e49faa13 --- /dev/null +++ b/next.config.js @@ -0,0 +1,5 @@ +const withTM = require('next-transpile-modules')(['ramda']); + +module.exports = withTM({ + /* Your Next.js config */ +}); diff --git a/package.json b/package.json index 582a3b4c..c28d574c 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "craco-alias": "^2.3.1", "husky": "^7.0.4", "lint-staged": "^12.1.6", + "next-transpile-modules": "^9.0.0", "prettier": "^1.18.2" }, "lint-staged": { diff --git a/src/containers/main/SidebarRouter/index.tsx b/src/containers/main/SidebarRouter/index.tsx index b25e3fd0..9b2c8adc 100644 --- a/src/containers/main/SidebarRouter/index.tsx +++ b/src/containers/main/SidebarRouter/index.tsx @@ -9,6 +9,10 @@ interface IProps { } const SidebarRouter: FC = ({ prefix = '', isLab }) => { + if (typeof document === 'undefined') { + return null; + } + return createPortal( diff --git a/yarn.lock b/yarn.lock index f9f85b5f..8c3c1ca2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4448,7 +4448,7 @@ encoding@0.1.13: dependencies: iconv-lite "^0.6.2" -enhanced-resolve@^5.8.3: +enhanced-resolve@^5.7.0, enhanced-resolve@^5.8.3: version "5.8.3" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz#6d552d465cce0423f5b3d718511ea53826a7b2f0" integrity sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA== @@ -7307,6 +7307,14 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +next-transpile-modules@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/next-transpile-modules/-/next-transpile-modules-9.0.0.tgz#133b1742af082e61cc76b02a0f12ffd40ce2bf90" + integrity sha512-VCNFOazIAnXn1hvgYYSTYMnoWgKgwlYh4lm1pKbSfiB3kj5ZYLcKVhfh3jkPOg1cnd9DP+pte9yCUocdPEUBTQ== + dependencies: + enhanced-resolve "^5.7.0" + escalade "^3.1.1" + next@^12.0.7: version "12.0.7" resolved "https://registry.yarnpkg.com/next/-/next-12.0.7.tgz#33ebf229b81b06e583ab5ae7613cffe1ca2103fc"