-
-
Notifications
You must be signed in to change notification settings - Fork 600
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
fix: remove LightningCssMinimizerRspackPlugin exclude option default value #7811
fix: remove LightningCssMinimizerRspackPlugin exclude option default value #7811
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
related to parcel-bundler/lightningcss#792 |
Should check if this is considered as a breaking change. |
cca58b2
to
255fcdb
Compare
首先可以确定的是,已经配置了 exclude 的,不会收到影响。 移除 exclude 默认配置后,压缩后的 css 兼容性将会与 targets 保持一致,兼容性更大。 除了产物变大,应该没有其他影响。 |
LightningCssMinimizerRspackPlugin adds the Currently the |
Our goal is to ensure that the "LightningCssMinimizerRspackPlugin" does not transform CSS syntax but only performs CSS compression. This is the issue discussed in parcel-bundler/lightningcss#792. We do not want to require users to configure a suitable There are several reasons for this:
我们的目标是让「LightningCssMinimizerRspackPlugin」不 transform CSS 语法,只进行 CSS 压缩。这也是 parcel-bundler/lightningcss#792 里试图解决的问题。 我们不想要求用户必须配置一个合适的 原因有几点:
|
实际上,使用 esbuild 进行压缩,默认情况下也会对 css 、js 语法进行调整。默认会转成更简洁的 js/css 语法。 这一点,至少 esbuild 文档中指出来了。 https://esbuild.github.io/api/#minify 另外,对于你所说的几点,可能都不会发生。原因如下:
因此,不光是 exclude 需要删除默认值,targets 也需要删除默认值。 |
esbuild minify 的时候调整语法是为了减小体积,不是为了语法降级。而且这个默认行为并不合适,我们内部有一些项目因为这个行为而遇到了兼容性问题。
这一点跟我说的不冲突,正是因为 postcss-loader 已经做了降级,所以 LightningCssMinimizerRspackPlugin 不应该引入预期之外的语法版本调整。
LightningCssMinimizerRspackPlugin 并不会默认读取 browserslist,所以必须得手动指定。
这一点还不能确定是否为 LightningCSS 的 bug 还是 by design,所以我上面说了要等 Lightning CSS 给出回复。 |
好的,另外,targets 的默认值是不是应该调整成 browserslist. |
According to the discussion in parcel-bundler/lightningcss#792, Rspack will remove the default I think we can merge this PR, @ahabhgk what do you think? |
Looks good to me, and since this will only downgrade syntax, instead of upgrading syntax, I think this is ok to consider as a non breaking change |
如果同意此 PR,那么 |
Agreed.
I think this is reasonable. |
LightningCssMinimizerRspackPlugin can set
|
@noshower I think we can modify the default behavior of the |
我试试 |
57fa4e6
to
3cb67f8
Compare
Remove the default value of the lightningcss exclude option to make it consistent with the default of the lightningcss Playground.
In addition, if the default value is not removed, the CSS backward compatibility will fail. The transition from rspack.SwcCssMinimizerRspackPlugin to rspack.LightningCssMinimizerRspackPlugin will cause CSS compatibility issues.
For example, the original CSS code of top:0;right:0;bottom:0;left:0; becomes inset:0 after being compressed by LightningCssMinimizerRspackPlugin.
The inset property is a newer CSS property.
移除 lightningcss exclude 选项的默认值,使其与 lightningcss Playground 默认情况保持一致。
另外,不移除默认值,会导致 css 向下兼容失败,从 rspack.SwcCssMinimizerRspackPlugin 过渡到 rspack.LightningCssMinimizerRspackPlugin 会出现 css 兼容性问题。
例如,原先是 top:0;right:0;bottom:0;left:0; 的 css 代码,再经过 LightningCssMinimizerRspackPlugin 压缩后,变成 inset:0。
而 inset 属性是较新的 css 属性。
演示链接:https://lightningcss.dev/playground/index.html#%7B%22minify%22%3Afalse%2C%22customMedia%22%3Atrue%2C%22cssModules%22%3Afalse%2C%22analyzeDependencies%22%3Afalse%2C%22targets%22%3A%7B%22chrome%22%3A5046272%7D%2C%22include%22%3A0%2C%22exclude%22%3A1048575%2C%22source%22%3A%22%5Cn%5Cn.foo%20%7B%5Cn%20%20position%3Aabsolute%3B%5Cn%20%20top%3A0%3B%5Cn%20%20right%3A0%3B%5Cn%20%20left%3A0%3B%5Cn%20%20bottom%3A0%3B%5Cn%7D%5Cn%5Cn%5Cn%22%2C%22visitorEnabled%22%3Afalse%2C%22visitor%22%3A%22%7B%5Cn%20%20Color(color)%20%7B%5Cn%20%20%20%20if%20(color.type%20%3D%3D%3D%20'rgb')%20%7B%5Cn%20%20%20%20%20%20color.g%20%3D%200%3B%5Cn%20%20%20%20%20%20return%20color%3B%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%22%2C%22unusedSymbols%22%3A%5B%5D%2C%22version%22%3A%22local%22%7D