fix: resolve ES build importing .less source files (fix #2844)#2850
fix: resolve ES build importing .less source files (fix #2844)#2850
Conversation
The issue is that when using babel transformer for ESM build, the extraBabelPlugins configuration for CSS handling was missing. This causes the built ES module to import .less files directly instead of inlining the compiled CSS. This fix adds the extraBabelPlugins configuration to ensure CSS is properly inlined during build, matching the behavior in v2.23.x.
|
There was a problem hiding this comment.
Code Review
This pull request updates the .fatherrc.ts configuration for the @antv/l7-component package to include extra Babel plugins for inlining CSS and GLSL files. A review comment points out that the babel-plugin-inline-import for .glsl files is likely unnecessary for this specific package, as it primarily contains UI components that do not utilize shaders, and recommends its removal to reduce build complexity.
| [ | ||
| // import glsl as raw text | ||
| 'babel-plugin-inline-import', | ||
| { extensions: '.glsl' }, | ||
| ], |
There was a problem hiding this comment.
The babel-plugin-inline-import for .glsl files appears to be unnecessary for the @antv/l7-component package. This package primarily contains UI components (Markers, Popups, Controls) which do not seem to use GLSL shaders. Adding unused plugins can slightly increase build times and adds unnecessary complexity to the configuration. If this was copied from another package like l7-layers, it should be removed here.
// import css as inline
'transform-import-css-l7',
修复内容
修复 Issue #2844: @antv/l7-component ES build imports .less source files since v2.24.0
问题描述
@antv/l7-component/es/index.js中直接导入了.less文件:less预处理器的项目构建失败问题原因
extraBabelPlugins配置来正确处理 CSS 内联解决方案
.fatherrc.ts中添加extraBabelPlugins配置,包含transform-import-css-l7插件受影响版本
测试
@antv/l7-component包,确认 ES 模块产物不再包含.less导入Related: #2844