S
SolidJS2mo ago
mark

Certain ts import methods not supported?

Are there specific limitations to what "style" of imports can be used with solid.js? I ran into an issue while using the get method from the lodash package. Basically, all of the following ways of importing seem to cause errors with solid, even though (I think?) all these are valid ways to import lodash:
import { get } from 'lodash';
import { get as lodashGet } from 'lodash';
import * lodash from 'lodash';
import { get } from 'lodash';
import { get as lodashGet } from 'lodash';
import * lodash from 'lodash';
For me only this seems to actually work:
import lodash from 'lodash';
import lodash from 'lodash';
See this example: https://stackblitz.com/edit/github-pqy8j7-a5flwd4v?file=src%2Fcomponents%2FPage.tsx Note that I ran into this issue while using lodash inside an pre-built npm package (which I forked and added to the repository and added as linked dependency). In that package I was using one of the "wrong" import methods, which was causing hard to debug Hydration Mismatch errors in my application. Interestingly, these errors only occurred on refreshes of pages that were using the affected logic from the prebuilt package, the initial render of those pages would work fine... I'm new to solid (and not a big expert on bundlers) so figured I'd ask here before filing an issue, but I was surprised that an way of importing dependencies in a prebuilt dependency could have such side-effects. Are there specific build configurations/instructions for packages with solid.js logic?
StackBlitz
Hydratation Mismatch (forked) - StackBlitz
An Astro project based on @astrojs/node, @astrojs/solid-js, @tanstack/solid-query, astro, lodash, solid-js and @types/lodash
2 Replies
Madaxen86
Madaxen862mo ago
GitHub
TypeError: __vite_ssr_import_0__ is not a function on dayjs() · ...
I am switching this project from Jest to Vitest. The tests for dayjs() were running fine in Jest, but I don't know why they are giving this error in Vitest: TypeError: vite_ssr_import_0 is ...
mark
markOP2mo ago
Rrright, that's why we were using lodash-es in vite apps. Thanks!

Did you find this page helpful?