Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Tailwind CSS V2 Support #7

Open
colinaaa opened this issue Nov 10, 2024 · 5 comments
Open

[Feature] Tailwind CSS V2 Support #7

colinaaa opened this issue Nov 10, 2024 · 5 comments

Comments

@colinaaa
Copy link
Collaborator

Support using this plugin with both tailwindcss@v3 and tailwindcss@v2.

@colinaaa
Copy link
Collaborator Author

Pending on web-infra-dev/rslib#413

@fi3ework
Copy link
Member

👀 Does this issue rely on web-infra-dev/rslib#413 to build this package itself?

@colinaaa
Copy link
Collaborator Author

Yes, I'm going to check tailwindcss/package.json#version and use a different Rspack plugin for Tailwind CSS V2. And currently this will give an error since Rslib removes the Import Attributes.

But there is another way to support Tailwind CSS V2. By publishing a different version of this plugin for Tailwind CSS V2.

@chenjiahan
Copy link
Member

How about using fs and require.resovle to read tailwindcss/package.json?

@colinaaa
Copy link
Collaborator Author

Yeah, we should go this way. I just checked that Import Attributes is not supported in NodeJS 16 :)

> import('./package.json', { with: {type: 'json'} })
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 255,
  [Symbol(trigger_async_id_symbol)]: 5
}
> Uncaught:
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///root/package.json" needs an import assertion of type "json"
    at __node_internal_captureLargerStackTrace (node:internal/errors:478:5)
    at new NodeError (node:internal/errors:387:5)
    at validateAssertions (node:internal/modules/esm/assert:82:15)
    at defaultLoad (node:internal/modules/esm/load:84:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}
> process.version
'v16.20.0'

github-merge-queue bot pushed a commit that referenced this issue Dec 28, 2024
### Summary

Support Tailwind CSS v3.1 and Tailwind CSS v3.2.

---

### Details

Since Tailwind CSS support using ESM configuration in V3.3, we need to
use CJS configuration before that.

As mentioned in
#7 (comment),
we use `readFile` + `require.resolve` to get the version of
`tailwindcss/package.json`.

- If `satisfies(version, ^3.3.0)`, we will generate ESM configuration to
support both ESM and CJS.
- Else, we generate CJS configuration.

---

### Test plan

We setup two new entries in the testing matrix

- tailwindcss v3.1.0 with Ubuntu
- tailwindcss v3.1.0 with Windows

As you can see, the test is failing at
[0e05c6a](0e05c6a).

And after the fix is landed in
[e783415](e783415),
the test for old tailwindcss is passing.

---

### Related links

close: #18 

- Tailwind CSS v3.3:
  - https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.3.0
  - tailwindlabs/tailwindcss#10785
- Tailwind CSS v3.2
  - https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.2.0
- Tailwind CSS v3.1
  - https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants