T
TanStack7mo ago
flat-fuchsia

How to transpile packages in monorepo without dedicated build step?

In our mono repo we hava a shared components package written in typescript. in our other apps (vite and nextjs based) we can just import it - however in tanstack start as soon as I import something in the __root.tsx I get an error:
TypeError: (0 , __vite_ssr_import_1__.default) is not a function
at eval (repo/packages/components/src/AppFrame.tsx:5:52)
at async ESModulesEvaluator.runInlinedModule (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1049:5)
at async SSRCompatModuleRunner.directRequest (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1271:61)
at async SSRCompatModuleRunner.directRequest (file://repo/tanstack-app/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:30895:23)
at async SSRCompatModuleRunner.cachedRequest (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1167:76)
// ...
TypeError: (0 , __vite_ssr_import_1__.default) is not a function
at eval (repo/packages/components/src/AppFrame.tsx:5:52)
at async ESModulesEvaluator.runInlinedModule (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1049:5)
at async SSRCompatModuleRunner.directRequest (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1271:61)
at async SSRCompatModuleRunner.directRequest (file://repo/tanstack-app/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:30895:23)
at async SSRCompatModuleRunner.cachedRequest (file://repo/tanstack-app/node_modules/vite/dist/node/module-runner.js:1167:76)
// ...
With defaultSsr: false it works except in __root.tsx Is there a way to enable transpilation for local packages in ssr?
4 Replies
correct-apricot
correct-apricot7mo ago
No clue if this applies at all, but have you tried playing around with optimzeDeps in your vite config?
flat-fuchsia
flat-fuchsiaOP7mo ago
Yes tried adding it there and tried adding it to ssr.noExternal as well, didn't change the behaviour.
ssr: {
noExternal: ["@share/components"],
},
ssr: {
noExternal: ["@share/components"],
},
stormy-gold
stormy-gold7mo ago
can you provide a full example repository?

Did you find this page helpful?