rspack-contrib / rsbuild-plugin-tailwindcss

An Rsbuild plugin to integrate with Tailwind CSS
MIT License
12 stars 1 forks source link

[Feature] Tailwind CSS V2 Support #7

Open colinaaa opened 1 week ago

colinaaa commented 1 week ago

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

colinaaa commented 1 week ago

Pending on https://github.com/web-infra-dev/rslib/issues/413

fi3ework commented 1 week ago

👀 Does this issue rely on https://github.com/web-infra-dev/rslib/issues/413 to build this package itself?

colinaaa commented 1 week ago

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 commented 1 week ago

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

colinaaa commented 1 week ago

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'