Open lpkobamn opened 4 weeks ago
Same with remix-run npx create-remix@latest try to import ThemeProvider
For both project you need to pass {ssr: {noExtrenal: ['@gravity-ui/*']}}
to vite config. Note that Start supports this option since version 1.77.6
For both project you need to pass
{ssr: {noExtrenal: ['@gravity-ui/*']}}
to vite config. Note that Start supports this option since version 1.77.6
Thank you for your help. There is a minor error in the "External" word in your response. Here is the complete configuration:
// app.config.ts
import { defineConfig } from "@tanstack/start/config";
export default defineConfig({
server: {
preset: "node-server",
},
vite: { ssr: { noExternal: ["@gravity-ui/*"] } },
});
Despite the fact that so far everything is working, an error is already appearing
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. Thi
s will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used
in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
at ThemeProvider (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@gravity-ui/uikit/build/esm/components/theme/ThemePr
ovider.js:21:33)
at div
at body
at Body (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/client/Meta.js:201:17)
at html
at Html (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/client/Meta.js:187:17)
at RootDocument (C:/Users/noder/Desktop/tanstackstart-react-vite/app/routes/__root.tsx:44:25)
at RootComponent
at MatchInnerImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Match.js:75
:3)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at MatchImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Match.js:18:3)
at CatchBoundaryImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/CatchBou
ndary.js:24:5)
at CatchBoundary (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/CatchBoundar
y.js:4:32)
at renderHostElement (C:\Users\noder\Desktop\tanstackstart-react-vite\node_modules\react-dom\cjs\react-dom-server.node.development.
js:5708:3)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at Matches (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Matches.js:21:18)
at RouterContextProvider (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Rout
erProvider.js:5:3)
at RouterProvider (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/RouterProvi
der.js:24:27)
at StartServer (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/server/StartServer.js:16:9)
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. Thi
s will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used
in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
at PrivateLayoutProvider (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@gravity-ui/uikit/build/esm/components/layou
t/LayoutProvider/LayoutProvider.js:13:34)
at ThemeProvider (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@gravity-ui/uikit/build/esm/components/theme/ThemePr
ovider.js:21:33)
at div
at body
at Body (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/client/Meta.js:201:17)
at html
at Html (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/client/Meta.js:187:17)
at RootDocument (C:/Users/noder/Desktop/tanstackstart-react-vite/app/routes/__root.tsx:44:25)
at RootComponent
at MatchInnerImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Match.js:75
:3)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at MatchImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Match.js:18:3)
at CatchBoundaryImpl (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/CatchBou
ndary.js:24:5)
at CatchBoundary (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/CatchBoundar
y.js:4:32)
at renderHostElement (C:\Users\noder\Desktop\tanstackstart-react-vite\node_modules\react-dom\cjs\react-dom-server.node.development.
js:5708:3)
at SafeFragment (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/SafeFragment.
js:3:58)
at Matches (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Matches.js:21:18)
at RouterContextProvider (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/Rout
erProvider.js:5:3)
at RouterProvider (file:///C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/react-router/dist/esm/RouterProvi
der.js:24:27)
at StartServer (C:/Users/noder/Desktop/tanstackstart-react-vite/node_modules/@tanstack/start/dist/esm/server/StartServer.js:16:9)
I checked with other @gravity-ui libraries, the config above will not work, you need to set each library separately.
// app.config.ts
import { defineConfig } from "@tanstack/start/config";
export default defineConfig({
server: {
preset: "node-server",
},
vite: {
ssr: {
noExternal: [
"@gravity-ui/uikit",
"@gravity-ui/components",
"@gravity-ui/icons",
],
},
},
});
Hello,
I'm experiencing an import error when trying to use
@gravity-ui/uikit
in my project. Upon starting the dev server, I encounter the following errors:Steps to Reproduce:
@gravity-ui/uikit
via npm:@gravity-ui/uikit
in the__root.tsx
file:Expected Behavior:
The dev server starts without errors, and components from
@gravity-ui/uikit
are successfully imported and used in the project.Actual Behavior:
I receive a syntax error when importing the module, indicating
Unexpected token 'export'
. There's also a warning suggesting to set"type": "module"
inpackage.json
or to use the.mjs
extension.Additional Information:
package.json File:
import "../index.css";
export const Route = createRootRoute({ meta: () => [ { charSet: "utf-8", }, { name: "viewport", content: "width=device-width, initial-scale=1", }, { title: "TanStack Start Starter", }, ], component: RootComponent, });
function RootComponent() { return (
); }
function RootDocument({ children }: { children: React.ReactNode }) { return (
); }
function RootProvider({ children }: { children: React.ReactNode }) { return{children} ;
}