Skip to content

Commit a39e8ca

Browse files
committed
feat: build dist/ and bin/ with tsup instead of shipping source
Build the package the way @cldmv/vitest-runner does, replacing the placeholder build script: - tsup.config.mjs bundles src/ into dist/index.mjs (ESM), dist/index.cjs (CJS) and bin/fix-headers.mjs (CLI); dist/ and bin/ are build artifacts (gitignored) and prepack rebuilds them before npm pack/publish - package.json: main/exports/bin point at the build output, with a fix-headers-dev export condition that resolves to src/; files ships dist/, types/ and bin/ (no sourcemaps) instead of src/ - scripts: build (clear dist/ + bin/, then tsup) and build:ci (lint, format:check, types:build, build); ci.yml's coverage jobs now run build:ci before measuring src/** - the CJS build comes from src/index.cjs.mjs with cjsInterop, so require('@cldmv/fix-headers') still returns the function itself, as the removed root index.cjs shim did; the root index.mjs shim is gone too - detectors are imported statically instead of discovered by reading src/detectors/ at runtime, which a bundle can't do (and which needed a top-level await that CJS output can't express) The integration test that exercised the root shims now builds with the repo's tsup config into its fixture workspace and checks the ESM import, the CJS require() shape and the built CLI against a fixture project. 136/136 tests pass, coverage 100%. Fixes #18
1 parent 2529d83 commit a39e8ca

12 files changed

Lines changed: 1742 additions & 262 deletions

File tree

‎.configs/tsconfig.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"resolveJsonModule": true,
1717
"forceConsistentCasingInFileNames": true
1818
},
19-
"include": ["../index.mjs", "../src/**/*.mjs", "../src/*.mjs"],
20-
"exclude": ["../node_modules", "../tests", "../coverage"]
19+
"include": ["../src/**/*.mjs", "../src/*.mjs"],
20+
"exclude": ["../node_modules", "../tests", "../coverage", "../src/index.cjs.mjs"]
2121
}

‎.configs/vitest.config.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default defineConfig({
3939
coverage: {
4040
provider: "v8",
4141
reporter: ["text", "json", "json-summary", "html"],
42-
include: ["src/**/*.mjs", "index.mjs", "index.cjs"],
42+
include: ["src/**/*.mjs"],
4343
exclude: ["reference/**"],
4444
all: true
4545
}

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ jobs:
227227
# Requires: the coverage_command produces coverage/coverage-summary.json
228228
enable_coverage_badge: ${{ github.event.inputs.enable_coverage_badge != 'false' }}
229229
default_branch: ${{ github.event.inputs.default_branch || 'master' }} # Badge only pushed when a push lands on this branch
230+
# build:ci (lint + format:check + types:build + the tsup build into dist/ and bin/)
231+
# leaves src/ in place, so coverage still measures src/** after the build runs.
232+
coverage_build_command: "npm run build:ci"
230233
coverage_command: ${{ github.event.inputs.coverage_command || 'npm run ci:coverage' }}
231234
coverage_summary_path: ${{ github.event.inputs.coverage_summary_path || 'coverage/coverage-summary.json' }}
232235
badges_branch: ${{ github.event.inputs.badges_branch || 'badges' }}

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ trash/
55
other_drivers/
66
dist
77
dist/
8+
# tsup CLI output (package.json "bin"); a build artifact like dist/
9+
/bin/
810
types/dist
911
types/dist/
1012
build/

‎index.cjs‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎index.mjs‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)