Skip to content

langs: unused imports in generated src/index.ts (e.g. objectiveC) #761

Description

@EurFelux

Problem

The generated extensions/langs/src/index.ts contains unused imports. For example:

import { csharp, dart, kotlin, objectiveC, objectiveCpp, scala, squirrel } from '@codemirror/legacy-modes/mode/clike';

objectiveC is imported but never referenced in the langs map — only objectiveCpp is used (for the .mm extension).

Root Cause

In gen-langs-map.cjs, parseLoadSpec() calls addNamed() as a side effect during AST parsing, which adds symbols to the import list immediately. Later, when multiple languages share the same file extension (e.g. Objective-C and Octave both use .m), the dedup step (mapObj.set(k, v) — last one wins) drops the losing entry's expression from the output, but the import was already registered and persists.

Impact

  • Minor: unused imports bloat the generated file and may trigger linter warnings
  • No runtime breakage — the unused symbols are simply dead code

Potential Fix

Defer addNamed calls until after the dedup step, so only symbols actually referenced in the final langs map get imported. This would require restructuring the generation flow to separate "parse specs" from "collect imports".

Related: #760

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions