denoland / deno-vite-plugin

Vite plugin to enable Deno resolution inside vite.
MIT License
44 stars 2 forks source link

[postcss] file name contained an unexpected NUL byte #17

Closed redabacha closed 1 month ago

redabacha commented 1 month ago

when importing a css file using a resolver alias, i encounter an error like this:

[vite] Pre-transform error: [postcss] file name contained an unexpected NUL byte: stat 'deno::JavaScript::./app/tailwind.css::/home/reda/Documents/Projects/remix-deno-template/app/tailwind.css'
[vite] Error when evaluating SSR module /app/root.tsx:
|- TypeError: [postcss] file name contained an unexpected NUL byte: stat 'deno::JavaScript::./app/tailwind.css::/home/reda/Documents/Projects/remix-deno-template/app/tailwind.css'
    at Object.statSync (ext:deno_fs/30_fs.js:412:3)
    at Object.statSync (ext:deno_node/_fs/_fs_stat.ts:159:25)
    at trackModified (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/tailwindcss@3.4.13/node_modules/tailwindcss/lib/lib/setupContextUtils.js:659:55)
    at getContext (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/tailwindcss@3.4.13/node_modules/tailwindcss/lib/lib/setupContextUtils.js:1282:30)
    at file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/tailwindcss@3.4.13/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:118:81
    at file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/tailwindcss@3.4.13/node_modules/tailwindcss/lib/processTailwindFeatures.js:46:11
    at plugins (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/tailwindcss@3.4.13/node_modules/tailwindcss/lib/plugin.js:38:69)
    at LazyResult.runOnRoot (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/postcss@8.4.47/node_modules/postcss/lib/lazy-result.js:329:16)
    at LazyResult.runAsync (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/postcss@8.4.47/node_modules/postcss/lib/lazy-result.js:258:26)
    at LazyResult.async (file:///home/reda/Documents/Projects/remix-deno-template/node_modules/.deno/postcss@8.4.47/node_modules/postcss/lib/lazy-result.js:160:30)

this can be reproduced from this branch here after running deno install and deno task dev or deno task build.

i notice that if i remove the null bytes (\0) from the ids by editing the plugin (specifically the isDenoSpecifier and toDenoSpecifier functions) in my node_modules folder, the builds on both dev and prod will work but there will be a flash of unstyled content in dev which isn't ideal.

redabacha commented 1 month ago

ah nevermind i figured it out, i just had the vite resolve.alias in the config setup incorrectly. however i did notice that the tailwind.css file was actually being parsed by deno info successfully (because it happened to also be valid js syntax) which in turn was giving the responsibility of loading it to the plugin instead of vite.