Skip to content

Rename the CJS entry source src/cjs-shim.cjs to src/index.cjs #63

Closed

Description

@Shinrai

Problem

The thin CommonJS entry is authored as src/cjs-shim.cjs and published as dist/index.cjs (tsup's onSuccess copies it under a new name). It sits next to src/index.mjs, the ESM entry it loads, so there's no reason for the names to differ.

The CLDMV library convention (as in CLDMV/llm-translator, and proposed for CLDMV/vitest-runner#98) gives the source and output the same name: src/index.mjs + src/index.cjs, published as dist/index.mjs + dist/index.cjs.

Proposal

  • git mv src/cjs-shim.cjs src/index.cjs (keeps history), then npm run fix:headers for the @Filename header.
  • tsup.config.mjs: copyFileSync("src/index.cjs", "dist/index.cjs"), and update the file comment (lines ~20–26).
  • package.json: change the wisp-dev condition's require to ./src/index.cjs.
  • tests/cjs-entry.test.vitest.mjs: update the require.resolve / require paths, the describe title and the file overview.
  • Update any coverage exclude / README / docs mention of cjs-shim.cjs; leave docs/changelog/** history alone.
  • Check that dist/index.cjs is byte-identical to before and the full suite passes.

Check before merging: caller resolution

pickPrimaryBaseFile() in src/lib/resolve-from-caller.mjs finds the real caller by watching stack frames leave src//dist/ and leave index.* entry files (see #12). Today a CJS caller loading the package in dev mode (wisp-dev) has a src/cjs-shim.cjs frame, which doesn't match index.*. After the rename it will be src/index.cjs, which does. Add a test that resolves the caller through the CJS entry, in dev mode (src/index.cjs) and built (dist/index.cjs), and confirm it still returns the user's file.

Non-goals

Related

Activity

  1. added
    type: enhancement
    priority: low
    area: core
    status: not started
    on Oct 25, 2026
  2. added
    status: in progress
    and removed
    status: not started
    on Nov 1, 2026
  3. added
    status: implemented
    and removed
    status: in progress
    on Nov 1, 2026
  4. cldmv-bot commented on Nov 1, 2026

    @cldmv-bot
    Contributor

    Marked status: implemented — resolved by #65, merged into next. This issue closes automatically when that work ships to the default branch.

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

    area: corepriority: lowstatus: implementedtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions