Skip to content

fix: resolve ES build importing .less source files (fix #2844)#2850

Open
lzxue wants to merge 1 commit intomasterfrom
fix/l7-component-less-import-weavefox
Open

fix: resolve ES build importing .less source files (fix #2844)#2850
lzxue wants to merge 1 commit intomasterfrom
fix/l7-component-less-import-weavefox

Conversation

@lzxue
Copy link
Copy Markdown
Contributor

@lzxue lzxue commented Apr 20, 2026

修复内容

修复 Issue #2844: @antv/l7-component ES build imports .less source files since v2.24.0

问题描述

  • 从 v2.24.0 开始,@antv/l7-component/es/index.js 中直接导入了 .less 文件:
    import "./css/index.less";
  • 这会导致没有安装 less 预处理器的项目构建失败

问题原因

  • 当使用 babel transformer 构建 ESM 时,缺少 extraBabelPlugins 配置来正确处理 CSS 内联

解决方案

  • .fatherrc.ts 中添加 extraBabelPlugins 配置,包含 transform-import-css-l7 插件
  • 这确保 CSS 在构建时被正确内联到产物中,而不是直接引用 less 源文件

受影响版本

  • 2.24.0 – 2.25.4 (latest)

测试

  • 构建 @antv/l7-component 包,确认 ES 模块产物不再包含 .less 导入

Related: #2844

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.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

⚠️ No Changeset found

Latest commit: 62a9b8f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +12 to +16
[
// import glsl as raw text
'babel-plugin-inline-import',
{ extensions: '.glsl' },
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant