Skip to content

fix(parser): 修正资源去重和构建配置#972

Open
A-kirami wants to merge 3 commits into
OpenWebGAL:mainfrom
A-kirami:fix/parser-asset-dedup-and-build-config
Open

fix(parser): 修正资源去重和构建配置#972
A-kirami wants to merge 3 commits into
OpenWebGAL:mainfrom
A-kirami:fix/parser-asset-dedup-and-build-config

Conversation

@A-kirami
Copy link
Copy Markdown
Contributor

@A-kirami A-kirami commented Jun 8, 2026

背景

packages/parser 当前同时存在两类问题:

  1. 场景资源预加载的去重逻辑依赖 lodash/uniqWith,但没有显式比较语义,重复资源去重不稳定。
  2. parser 包的构建配置残留了一些未使用依赖和额外的 tsconfig,增加了维护和发布成本。

本次改动

  • 用本地 deduplicateAssets 替代 lodash/uniqWith,按 type + url 对资源去重,并保留首次出现的资源记录。
  • 清理 packages/parser/package.json 中未使用的构建相关依赖,补充 rimraf,保留 tsx 作为调试用开发依赖。
  • 简化 packages/parser/tsconfig.json,移除 tsconfig.node.json,同步更新 .npmignore
  • 为 UMD 构建补充 exports: "named",统一不同产物的导出行为。
  • 更新 yarn.lock 以反映依赖收敛结果。

影响范围

  • packages/parser 的资源预加载去重逻辑
  • packages/parser 的打包与发布配置
  • 根目录 yarn.lock

验证建议

  • yarn parser:test --run
  • yarn parser:build
  • 如需对齐 CI,再执行一次 yarn build
  • 准备一个包含重复资源引用的场景脚本,确认 assetsList 中相同 type + url 只保留一条
  • 确认 ES / CJS / UMD 产物均可正常导出

风险与注意事项

  • 当前去重语义改为 type + url。如果上层未来需要区分同 URL 但不同 namelineNumber 的记录,需要进一步明确接口边界。
  • 这次依赖清理默认假设 parser 运行时不再依赖被移除的包;若后续有独立发布场景,建议再核对产物依赖边界。

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 cleans up the dependencies and configuration of the packages/parser package. It removes unused dependencies like lodash and chevrotain, deletes tsconfig.node.json, and updates tsconfig.json and package.json accordingly. Additionally, it replaces the lodash uniqWith utility in sceneParser.ts with a custom deduplicateAssets helper. A review comment suggests adding defensive checks in this new helper to prevent potential runtime errors when accessing properties of potentially null or undefined assets.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/parser/src/sceneParser.ts
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.

1 participant