Repository navigation
Closed
Labels
area: coreTouches core library / runtime source codepriority: lowMinor issue or improvement that can be deferred without impactstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: bugSomething is broken or not behaving as expected
Description
Problem
The thin CommonJS entry is src/cjs/index.cjs, a folder holding one file. It exists only so tsup's publicDir: "src/cjs" can copy it into dist/. The file does require("./index.mjs").default, but there's no src/index.mjs next to it (the ESM entry is src/fix-header.mjs). So it only resolves once copied into dist/, and it can't be loaded or tested from source.
The CLDMV library convention (as in CLDMV/llm-translator, and proposed for CLDMV/vitest-runner#98) is one name for both source and output:
src/index.mjsis the ESM entry, bundled todist/index.mjs.src/index.cjsis the CJS entry, copied verbatim todist/index.cjsby a tsuponSuccesscopyFileSync.require("./index.mjs")resolves to the sibling insrc/and indist/, so the CJS entry can also be tested from source.
Proposal
git mv src/fix-header.mjs src/index.mjsandgit mv src/cjs/index.cjs src/index.cjs(keeps history); remove the emptysrc/cjs/. Runnpm run fix:headersto update the@Filenameheaders.- Update imports of
fix-header.mjs(src/cli.mjs, tests), thefix-headers-devexport condition inpackage.json, andtsup.config.mjs'sentry({ index: "src/index.mjs" }). tsup.config.mjs: droppublicDir: "src/cjs"; addonSuccess() { copyFileSync("src/index.cjs", "dist/index.cjs"); }. Update the file comments intsup.config.mjsand the CJS entry that describepublicDir.- Optionally add
require: "./src/index.cjs"to thefix-headers-devcondition, as stubborn-tcp, wisp and mxnet-control do. Then add a source-level vitest test that the CJS entry matches the ESM default export. - Regenerate
types/and checktypes/index.d.mtsstill resolves the entry declaration. - Check that
dist/index.cjsis byte-identical to before and thattests/cjs/entry.test.cjsand the full suite pass. - Update any README/docs layout notes; leave
docs/changelog/**history alone.
Non-goals
- Changing what the CJS entry does (the
require_moduleguard +require("./index.mjs").default).
Related
- CLDMV/vitest-runner#98, and the matching
src/cjs-shim.cjs→src/index.cjsissues in stubborn-tcp, wisp and mxnet-control.
Metadata
Metadata
Assignees
Labels
area: coreTouches core library / runtime source codepriority: lowMinor issue or improvement that can be deferred without impactstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: bugSomething is broken or not behaving as expected
Activity
fix: entry files are src/index.mjs and src/index.cjs, with a devcheck…
fix: entry files are src/index.mjs and src/index.cjs, with a devcheck…
release: v2.2.4 - find and keep # headers in CRLF and byte-order-mark…