Skip to content

Resolve module ambiguity: rename source.ts to base-source.ts - #2802

Merged
lzxue merged 6 commits into
masterfrom
copilot/rename-source-file-to-base-source
Jan 22, 2026
Merged

Resolve module ambiguity: rename source.ts to base-source.ts#2802
lzxue merged 6 commits into
masterfrom
copilot/rename-source-file-to-base-source

Conversation

Copilot AI commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Module resolution ambiguity exists when import './source' can resolve to either source.ts or source/index.ts. Some bundlers and frameworks handle this inconsistently.

Changes

  • Renamed: packages/source/src/source.tspackages/source/src/base-source.ts
  • Updated import: packages/source/src/index.ts now imports from './base-source'
// Before
import Source from './source';  // Ambiguous: source.ts or source/index.ts?

// After  
import Source from './base-source';  // Unambiguous

Impact

Internal refactoring only. Public API unchanged - external consumers still use import Source from '@antv/l7-source'.

Original prompt

问题描述

packages/source/src/ 目录下同时存在:

  • source.ts 文件(包含 Source 类)
  • source/ 目录(包含 VectorSource 相关代码)

当在 packages/source/src/index.ts 中使用 import Source from './source' 时,某些框架和打包工具可能会产生模块解析歧义:

  • 可能解析为 ./source.ts 文件
  • 也可能解析为 ./source/index.ts 文件

这会导致在某些环境下出现模块导入冲突。

解决方案

packages/source/src/source.ts 重命名为 packages/source/src/base-source.ts,并更新相关的导入语句。

需要修改的文件

1. 重命名文件

packages/source/src/source.ts 重命名为 packages/source/src/base-source.ts

2. 更新 packages/source/src/index.ts

将:

import Source from './source';

改为:

import Source from './base-source';

当前 index.ts 完整内容

import { registerParser, registerTransform } from './factory';
import csv from './parser/csv';
import geojson from './parser/geojson';
import geojsonVTTile from './parser/geojsonvt';
import image from './parser/image';
import json from './parser/json';
import jsonTile from './parser/jsonTile';
import mapboxVectorTile from './parser/mvt';
import raster from './parser/raster';
import rasterTile, { rasterDataTypes } from './parser/raster-tile';
import ndi from './parser/raster/ndi';
import rgb from './parser/raster/rgb';
import rasterRgb from './parser/rasterRgb';
import testTile from './parser/testTile';
import Source from './source';
import { cluster } from './transform/cluster';
import { filter } from './transform/filter';
import { aggregatorToGrid } from './transform/grid';
import { pointToHexbin } from './transform/hexagon';
import { join } from './transform/join';
import { map } from './transform/map';
export { getParser, getTransform, registerParser, registerTransform } from './factory';
export * from './interface';
export * from './source/index';
export * from './utils/relative-coordinates';
export { rasterDataTypes };

registerParser('rasterTile', rasterTile);
registerParser('mvt', mapboxVectorTile);
registerParser('geojsonvt', geojsonVTTile);
registerParser('testTile', testTile);
registerParser('geojson', geojson);
registerParser('jsonTile', jsonTile);
registerParser('image', image);
registerParser('csv', csv);
registerParser('json', json);
registerParser('raster', raster);
registerParser('rasterRgb', rasterRgb);
registerParser('rgb', rgb);
registerParser('ndi', ndi);
registerTransform('cluster', cluster);
registerTransform('filter', filter);
registerTransform('join', join);
registerTransform('map', map);
registerTransform('grid', aggregatorToGrid);
registerTransform('hexagon', pointToHexbin);

export default Source;

注意事项

  • 由于 Source 类是通过 @antv/l7-source 包导出的,外部使用者通过 import Source from '@antv/l7-source' 导入,不会受到此次重命名的影响
  • 这是一个纯内部重构,不会破坏任何公共 API
  • 这个改动将消除潜在的模块解析歧义,提高代码的可维护性和兼容性

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot

changeset-bot Bot commented Jan 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4e8edea

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

Co-authored-by: lzxue <4366658+lzxue@users.noreply.github.com>
Copilot AI changed the title [WIP] Rename source.ts to base-source.ts to resolve module ambiguity Resolve module ambiguity: rename source.ts to base-source.ts Jan 22, 2026
Copilot AI requested a review from lzxue January 22, 2026 08:06
Copilot AI and others added 4 commits January 22, 2026 18:57
* Initial plan

* style: fix Prettier formatting issues in 8 files

Co-authored-by: lzxue <4366658+lzxue@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lzxue <4366658+lzxue@users.noreply.github.com>
* Initial plan

* style: fix Prettier formatting issues in 8 files



---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lzxue <4366658+lzxue@users.noreply.github.com>
@lzxue
lzxue marked this pull request as ready for review January 22, 2026 11:42
@lzxue
lzxue merged commit 7507c0a into master Jan 22, 2026
6 checks passed
@lzxue
lzxue deleted the copilot/rename-source-file-to-base-source branch January 22, 2026 11:43
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

Successfully merging this pull request may close these issues.

2 participants