ardeora / solid-toast

Customizable Toast Notifications for SolidJS
https://www.solid-toast.com
MIT License
815 stars 25 forks source link

Syntax error when including solid-toast in latest version of SolidJS #96

Closed MarByteBeep closed 10 months ago

MarByteBeep commented 10 months ago

When trying to import solid_toast with the latest version of SolidJS like this

import toast, { Toaster } from 'solid-toast';

I get the following error

Error when evaluating SSR module module.tsx: failed to import "solid-toast"
|- \node_modules\solid-toast\dist\esm\index.js:1
import { createSignal, untrack, createRoot, createEffect, onCleanup, For, Switch, Match, createMemo, onMount } from 'solid-js';
^^^^^^

SyntaxError: Cannot use import statement outside a module      
    at internalCompileFunction (node:internal/vm:73:18) 

I'm using these versions

"solid-js": "^1.8.3",
"solid-start": "^0.3.10",
"solid-toast": "^0.5.0"
"solid-start-node": "^0.3.10",
"tailwindcss": "^3.3.3",
"typescript": "^4.9.5",
"vite": "^4.4.9"

Any thoughts?

MarByteBeep commented 10 months ago

Turned out to be a mismatch between CJS and MJS files in the setup. Rename vite.config.ts to vite.config.mts and postcss.config.js to postcss.config.mjs, and remove type: "module" from package.json, and this error should be gone.

ardeora commented 10 months ago

Ah makes sense! Thank you. Please let me know if you run into any issues!