mdbootstrap / TW-Elements

𝙃π™ͺπ™œπ™š collection of Tailwind MIT licensed (free) components, sections and templates 😎

Home Page:https://tw-elements.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vue + Inertia, SSR not working, the requested module does not provide

rinoj opened this issue Β· comments

When running Inertia SSR, the modules are not found.

The error is as follows:

import { initTE, Collapse, Ripple } from "tw-elements";
SyntaxError: The requested module 'tw-elements' does not provide an export named 'Collapse'

The generated build file has this import file

import { initTE, Collapse, Ripple } from "tw-elements";

which leads to this file.
/node_modules/tw-elements/types/tw-elements.d.ts

declare module "tw-elements";

Hi, try importing tw-elemets package dynamically. It should fix this error. Check out also our Troubleshooting section in Vue Integration tutorial.

onMounted(async () => {
  const { Collapse, Ripple, initTE } = await import("tw-elements");
  initTE({ Collapse, Ripple });
});

That fixed it, thank you.