ardeora/solid-toast

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

MarByteBeep opened this issue · 2 comments

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?

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.

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