From 7ecec9dab64a2b801b606293f52a205b9ebdcbc9 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 10 Sep 2026 10:42:53 +0100 Subject: [PATCH] fix: build config stays plain JS, not TS The prepare script (pnpm run build) failed installing as a git dependency in CI: Node's native TS-stripping refuses to process a .ts file located under node_modules, and a git-dependency install always resolves into exactly such a path while its prepare script runs. tsdown.config.ts needed no TS syntax at all, so it stays tsdown.config.js instead of fighting the restriction with a --config-loader flag. Verified against the actual failure mode, not just locally: copied the package into a node_modules-nested path and ran the build from there. --- eslint.config.ts | 2 ++ tsconfig.node.json | 2 +- tsdown.config.ts => tsdown.config.js | 2 ++ turbo.json | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) rename tsdown.config.ts => tsdown.config.js (59%) diff --git a/eslint.config.ts b/eslint.config.ts index db9aa98..928814f 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -12,6 +12,8 @@ export default exadevConfig( ".turbo", "vendor", "test/fixtures/generated", + // Plain JS (not TS), specifically so it never needs Node's native type-stripping to load -- see tsdown.config.js's own comment for why. Nothing here needs type-aware linting. + "tsdown.config.js", ], }, { diff --git a/tsconfig.node.json b/tsconfig.node.json index aff3744..8914a61 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -3,6 +3,6 @@ "compilerOptions": { "allowImportingTsExtensions": true }, - "include": ["src/cli.ts", "tsdown.config.ts", "eslint.config.ts", "test/**/*.ts"], + "include": ["src/cli.ts", "eslint.config.ts", "test/**/*.ts"], "exclude": ["test/fixtures/generated/protocol.ts"] } diff --git a/tsdown.config.ts b/tsdown.config.js similarity index 59% rename from tsdown.config.ts rename to tsdown.config.js index 56e3540..be697b4 100644 --- a/tsdown.config.ts +++ b/tsdown.config.js @@ -1,5 +1,7 @@ import { defineConfig } from "tsdown"; +// Plain JS, not TS: this file is loaded via Node's native module loader when cddl.js is installed as a git dependency (its own "prepare" script runs `pnpm run build`, which needs this config before any of it can typecheck or strip anything). Node's native TS-stripping refuses to process a .ts file located under node_modules, and a git-dependency install always resolves into exactly such a path during `prepare` -- a real CI failure this project already hit, not a hypothetical one. A tiny defineConfig() call gains nothing from TS here, so it stays plain JS to route around the restriction entirely rather than fight it with a config-loader flag. +// // src/emitter.ts (emitModule/mergeRules), src/runtime.ts (cborDecodesAs), and src/parse.ts (parse, re-exported from the vendored parser) are the library's public surface, built directly as separate entries rather than through a re-exporting index.ts -- the project's barrel-policy lint rule requires importing straight from the module that owns each export. Each is built dual ESM/CJS with declarations so it resolves correctly under every module system; attw verifies that claim directly rather than trusting it. src/cli.ts (a script, not library surface) is deliberately not part of this build; vendor/cddl is compiled separately via its own tsc step (see package.json's _vendor:build), which src/parse.ts's own bundling depends on. export default defineConfig({ entry: ["src/emitter.ts", "src/runtime.ts", "src/parse.ts"], diff --git a/turbo.json b/turbo.json index e8efd0c..af08fe7 100644 --- a/turbo.json +++ b/turbo.json @@ -9,7 +9,7 @@ }, "_build": { "dependsOn": ["_vendor:build"], - "inputs": ["src/emitter.ts", "src/runtime.ts", "src/parse.ts", "tsdown.config.ts", "tsconfig.json"], + "inputs": ["src/emitter.ts", "src/runtime.ts", "src/parse.ts", "tsdown.config.js", "tsconfig.json"], "outputs": ["dist/**"] }, "_generate": {