tailwindcss: v4 alpha does not work on Stackblitz
What version of Tailwind CSS are you using?
4.0.0-alpha.6
What build tool (or framework if it abstracts the build tool) are you using?
Vite 5.1.5
What version of Node.js are you using?
v18.18.0
What browser are you using?
Chrome
What operating system are you using?
StackBlitz
Reproduction URL
https://stackblitz.com/edit/vitejs-vite-bhcbjy?file=vite.config.js&terminal=dev
A Tailwind Play link or public GitHub repo that includes a minimal reproduction of the bug. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn’t matter if your real project is private/confidential, since we want a link to a separate, isolated reproduction anyways.
A reproduction is required when filing an issue — any issue opened without a reproduction will be closed and you’ll be asked to create a new issue that includes a reproduction. We’re a small team and we can’t keep up with the volume of issues we receive if we need to reproduce each issue from scratch ourselves.
Describe your issue
~/projects/vitejs-vite-bhcbjy 3s
❯ npm run dev
> vite-starter@0.0.0 dev
> vite
failed to load config from /home/projects/vitejs-vite-bhcbjy/vite.config.js
error when starting dev server:
Error: Cannot load native addon because loading addons is disabled: /home/projects/vitejs-vite-bhcbjy/node_modules/@tailwindcss/oxide-linux-x64-musl/tailwindcss-oxide.linux-x64-musl.node
at process.dlopen (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:352:49789)
at Module._extensions..node (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:54:15934)
at Module.load (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:54:13457)
at Module._load (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:54:10535)
at Module.require (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:54:13775)
at i (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:98:2198)
at _0x271448 (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:352:193624)
at Object.eval (file:///home/projects/vitejs-vite-bhcbjy/node_modules/@tailwindcss/oxide/index.js:177:31)
at Object.function (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:352:194402)
at Module._compile (https://vitejsvitebhcbjy-emlm.w-credentialless-staticblitz.com/blitz.8e1c3ef8.js:54:14871)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 22 (4 by maintainers)
Update: @adamwathan and I are in touch & getting our teams connected to make this happen! Sounds like we might be able to get this started as soon as next week 🙌 Will circle back with updates as we progress
Hi all- cofounder of StackBlitz/Bolt here! We’d love to help in any way here, whether providing guidance, funding work on this, etc. As others have noted Wasm support for Tailwind v4 is not just an issue for StackBlitz/Bolt users but also other envs that may not be able to load non-Wasm addons (Deno, Node.js when security flags are set, etc).
@adamwathan what would be the best way to proceed here?
In v3, we used to share a stackblitz to our users to reproduce bugs easily. We provide a tailwind based design system with custom themes (we reset some namespaces, such as colors, spacing, etc with our own semantic). This is no longer possible with v4 unless tailwind support WASM like @laktek said above.
I have to agree with @huntabyte. Using the CDN is not a valid option for many of us who use Stackblitz for bug reproductions. I am an Astro maintainer, and like many other OSS projects we use Stackblitz to allow users to create bug reproductions. The lack of WASM support means that users can’t do this with any issue that involves Tailwind. Loading from the CDN isn’t an option, because it would not be testing the same code. Our users have had several issues with Tailwind 4, and this has prevented our users from providing working reproductions of these issues, making it harder for us to fix the issues. This issue should be reopened, because it is not fixed and the CDN option is not a valid workaround for many of the most common use cases.
I totally get that a wasm build might be a bigger lift and that the CDN is a workable solution for some cases.
That said, I think there’s still a bit of a gap for library maintainers who rely heavily on StackBlitz and web containers for repros, as well as all of the Bolt.new users. Vite-based setups are dominant, and guidance being to switch to the PlayCDN doesn’t feel right.
It’d be amazing if there was a smoother path forward that didn’t require rethinking the setup just for these environments, especially since StackBlitz offered help to make this happen.
Doesn’t closing the issue reduce the chances someone from the community may help resolve this?
A WASM build would also be great for making Tailwind V4 work with Deno compiled binaries (currently, NAPI builds of Oxide doesn’t work when included in a Deno-compiled binary)
Hey!
I think the better solution to use Tailwind CSS in environments like StackBlitz might be to use the CDN directly. This is just an unpkg.com link (or any CDN provider that pulls from npm). Setup: https://tailwindcss.com/docs/installation/play-cdn
For real projects, you should still setup Tailwind CSS properly.
We could still try to setup a wasm build to make this all work, but a solution that works today is the CDN.
Going to close this issue for now since I don’t think there is a lot we can/should do, and I think the CDN is a good solution for these environments.
We can re-open this if we really want to push the wasm build though.
I often use StackBlitz to quickly launch projects directly from GitHub using the Project URL. It would be awesome if Tailwind was supported in this case.
Hello, someone sent me this earlier today: https://x.com/boltdotnew/status/1912149005674615272?s=61
Thank you very much for the hard work 👏
I still have one blocking issue: I tried to update my stackblitz to work with my design system (which is using Tailwind), and unfortunately it seems the
@sourcedirective of the v4 is unable to parse thenode_modulesdirectory (only in stackblitz). I need to be able to parse./node_modules/@spark-uiin my case, as it is my component library. Fun fact: the@importdirective works when targetting thenode_modules, it is only@sourcethat does not work.node_modules🔴It is already better (thanks @adamwathan), but we are using Stackblitz to provide a bug-reproduction environement for our users, and they can’t use it still because of that.
Any idea why ? Should I open a separate issue for this ?
Here is a minimal stackblitz with the issue: https://stackblitz.com/edit/stackblitz-starters-wpsedvj7?file=app%2Fcontent.tsx
Hey 👋 Thanks for pinging me @devongovett 🙏
@adamwathan Indeed, you cannot load native addons in WebContainer because arbitrary native binaries cannot be executed in the browser. Therefore, for this to work it requires a Wasm package. Here’s a good example for a setup that I’d suggest: https://github.com/Brooooooklyn/Image/blob/95c248a04fa0b748a280be0d9936be18d744221f/packages/binding/index.js#L338-L355.
Essentially, you need to define another platform-specific dependency that targets
wasm32. For that package you have to set thecputowasm32(see this example). This means that if you runnpm installlocally, it would just install the dependency that matches your local architecture and in WebContainer it would download and install the Wasm package because we are going to roll out a change to WebContainer’s architecture and flip it fromx64towasm32. This is the most ideal setup and something I’d also like to change forlightningcssandparcel-watcher(cc @devongovett).What we have done for
lightningcssis to use a Wasm package that is registered as a “polyfill” on our side which means that when you installlightningcssit will auto-magically install the Wasm package. You can try that out on StackBlitz and inspectnode_modules. However, given that we are about to change the architecture for WebContainer, like I said, I’d recommend the former approach now. For the polyfill route to work, it really has to be an exact drop-in replacement and any additional dependencies have to becomebundledDependenciesas those won’t be seen by the package manager.I’d recommend taking a look at napi-rs or napi-wasm.
Let me know if I can help any further. Happy to collaborate if you need more input or direction. It’s important to us to ensure that tailwindcss continues to work in WebContainer.
Another option is to switch to unocss after it gets tailwind 4 support: https://github.com/unocss/unocss/issues/4411
For lightning css we have a separate WASM package (
lightningcss-wasm), which shims the exact API of the node package. I worked with @d3lm from the stackblitz team to get this automatically aliased in their environment so whenever someone installslightningcssit actually installslightningcss-wasminside stackblitz. In order to reuse thenapicode in WASM, I wrote napi-wasm, which shims the napi API in browsers. Here’s the source for the wasm package in lightningcss in case it helps.Hi! I found something, but i’m not sure how its work, https://www.npmjs.com/package/@windpress/oxide-parser-wasm
https://github.com/yomaytk/elfconv 😄