Replies: 5 comments 9 replies
-
Similar issue. Waiting for the answer... |
Beta Was this translation helpful? Give feedback.
-
I also have a similar issue. I've been trying to use Preact Material Component but I've had no luck. The furthest I've gotten is
I don't know if I am doing something wrong or if it just isn't supported... |
Beta Was this translation helpful? Give feedback.
-
There are multiple CDNs that you can try to use to import NPM modules but, in my experience, there are a lot of packages that don't work through any of the CDNs, or you have to try and find clever ways to structure the URLs to get certain packages to import. You can read about options for CDNs here: https://deno.land/manual/node/cdns I can see you've already tried esm.sh the one that seems to work the next most often for me is skypack.dev. |
Beta Was this translation helpful? Give feedback.
-
You need to alias - import Container from 'https://esm.sh/@mui/material/Container';
- import Typography from 'https://esm.sh/@mui/material/Typography/Typography.js';
- import Box from 'https://esm.sh/@mui/material/Box/Box.js';
+ import Container from 'https://esm.sh/@mui/material/Container?alias=react:preact/compat&external=preact/compat';
+ import Typography from 'https://esm.sh/@mui/material/Typography/Typography.js?alias=react:preact/compat&external=preact/compat';
+ import Box from 'https://esm.sh/@mui/material/Box/Box.js?alias=react:preact/compat&external=preact/compat'; |
Beta Was this translation helpful? Give feedback.
-
I managed to get it working, that is, I can render Material UI Components in a Deno/Fresh stack using Preact. However, when I started to use more complex components (Drawer's, Accordions), things started to fall over. I've published a Git repo with the demo here in case anybody is interested. If anybody has ideas why things start to fall over, and how to fix them, let me know. I'd be happy to put together a MUI/Fresh showcase, if that's even possible. https://github.com/irbull/fresh-mui I deployed the demo to Deno Deploy. |
Beta Was this translation helpful? Give feedback.
-
Is there a general approach to use NPM packages with Fresh?
I have tried pulling from a CDN but had compile errors, which I assume was due to dependencies of the package (react-json-view).
I'd love to use the MUI components as well.
So before I invested too much time in this, I thought I'd ask if there was a general approach to using NPM packages. Any examples also appreciated!!
Thanks!
This morning I tried a number of things. This came the closest to working. This is the index.tsx file:
No matter what I did, I would get errors like this:
Beta Was this translation helpful? Give feedback.
All reactions