tw-to-css icon indicating copy to clipboard operation
tw-to-css copied to clipboard

Not able to import in SvelteKit

Open jerriclynsjohn opened this issue 2 years ago • 3 comments

import { tailwindToCSS } from 'tw-to-css';

If I try to import tw-to-css under the lib folder it just breaks with the following error. This is under dev mode

11:38:02 PM [vite] Error when evaluating SSR module /src/lib/emails/render.ts: failed to import "tw-to-css"
|- /svelte-test/node_modules/tw-to-css/dist/index.mjs.js:45
`;function vp(t){let e=I.parse(t);return en.objectify(e)}var sb=(t,e)=>{var i,s;let r=(s=(i=e==null?void 0:e.corePlugins)==null?void 0:i.preflight)!=null?s:!1,n=(e==null?void 0:e.corePlugins)||{};return gp({config:{...e,corePlugins:{...n,preflight:r}},content:t})},bp=({config:t,options:e})=>({twi:xa(t,e),twj:Sp(t,e)}),xp=(...t)=>{let e="";return typeof t[0]=="string"?e=t[0]:Array.isArray(t[0])?e=t.flat(1/0).map(r=>xp(r)).join(" "):typeof t[0]=="object"&&(e=Object.entries(t[0]).filter(r=>!!r[1]).map(r=>r[0]).join(" ")),e=e.replace(/\s+/g," "),e},xa=(t,e)=>(...r)=>{let n=xp(r),{1:i}=r||{},a={...{merge:!0,minify:!0,ignoreMediaQueries:!0},...e,...i},o=_a(sb(n,t));return a!=null&&a.ignoreMediaQueries?o.removeMediaQueries():(o.removeUndefined(),o.combineMediaQueries()),o.fixRGB(),a!=null&&a.merge&&o.merge(),a!=null&&a.minify&&o.minify(),o.get()},Sp=(t,e)=>(...r)=>vp(xa(t,e)(r)),wp=xa(),ab=Sp(),ob=bp;export{bp as tailwindToCSS,ob as twToCSS,wp as twi,ab as twj};
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)

jerriclynsjohn avatar May 31 '23 18:05 jerriclynsjohn

Hey @jerriclynsjohn, was wondering if you were able to resolve this or find a workaround? I am running into the same problem myself

bergermaestro avatar Aug 27 '23 05:08 bergermaestro

Nope I'm waiting for a resolution.

jerriclynsjohn avatar Aug 27 '23 07:08 jerriclynsjohn

Hey @bergermaestro and @jerriclynsjohn, thanks for reporting, and sorry for the update delay. Finding time can be challenging as a working father of two young children. It looks like this is a build error on this pkg. I should work on a fix ASAP.

vinicoder avatar Aug 31 '23 14:08 vinicoder