Files
composiohq__composio/tsdown.config.base.ts
T
Alberto Schiabel 6e7fc24d93 fix(ts): disable publint pack under Turbo to fix flaky build ENOENT (#3661)
This PR:

- fixes the intermittent `E2E Test CLI (scratch)` → **Build** failure
seen on the changeset release PR #3616, where
`@composio/anthropic#build` died with:
  ```
Error: ENOENT: no such file or directory, open
'/tmp/tsdown-pack-XXXXXX/composio-anthropic-0.10.0.tgz'
  ```
- gates `publint` with `!isTurboTask` in `tsdown.config.base.ts`,
mirroring the existing ATTW workaround, so neither publish-readiness
check packs a tarball under Turbo

## Root cause

`tsdown.config.base.ts` already disabled **ATTW** under Turbo to dodge a
"tarball path bug for scoped packages", but left **publint** enabled
with `pack: 'pnpm'`. In tsdown the pack is shared and runs whenever
*either* check is enabled:

```js
if (publintConfigs.length || attwConfigs.length) {
  const tarball = await packTarball(pkg.packageJsonPath); // pnpm pack → temp dir → readdir → readFile
  ...
}
```

So disabling ATTW alone did **not** stop the pack — publint kept
triggering it, and with it the intermittent `readdir`-then-`readFile`
race where the packed `.tgz` is gone by the time `readFile` runs. It's
flaky: this run it hit `@composio/anthropic` while 14 sibling scoped
packages packed fine.

## Fix

`publint.enabled: true` → `publint.enabled: !isTurboTask`. With both
ATTW and publint disabled under Turbo, `packTarball()` is never called
in workspace/CI builds, eliminating the race. Direct package builds (no
`TURBO_HASH`) keep running both checks with packing — where the bug does
not occur.

## Verification (local, `--force` to bypass cache)

- **Turbo build before:** `[publint]` runs for every package (packs the
tarball) → race surface present.
- **Turbo build after:** `0` publint runs, `3 successful, 3 total`, all
`🙏 Build succeeded!` → pack step gone.
- **Direct build after** (`env -u TURBO_HASH pnpm build` in
`providers/anthropic`): both `✔ [attw]` and `✔ [publint]` run and pass →
coverage retained off-Turbo.
2026-06-25 04:31:27 +04:00

99 lines
2.5 KiB
TypeScript

import type { UserConfig } from 'tsdown';
// Turbo task execution triggers a tsdown tarball-pack path bug for scoped packages:
// an intermittent ENOENT while reading the packed `.tgz` (e.g. composio-anthropic-*.tgz).
// tsdown packs the tarball once and shares it between ATTW and publint, and only runs the
// pack when at least one of them is enabled — so BOTH must be disabled to skip the pack
// under Turbo. Keep both checks for direct package builds; disable them for workspace builds.
const isTurboTask = Boolean(process.env.TURBO_HASH);
/**
* tsdown config with shared defaults.
* Package-specific options (e.g., entry, outDir, outExtensions) can be overridden by the caller.
* Paths are relative to the closest `tsdown.config.ts` file that imports this config.
*/
export const baseConfig = {
/**
* Entry points for the build.
*/
entry: ['src/index.ts'],
/**
* Output directory for the build.
*/
outDir: 'dist',
outExtensions: () => ({
js: '.mjs',
dts: '.d.mts',
}),
/**
* Configures the output formats for the build.
* - 'esm' generates ESM (ECMAScript Module) output
*/
format: ['esm'],
/**
* Generates TypeScript declaration files (.d.mts, .d.ts)
*/
dts: true,
/**
* Clean `outDir` before each build.
*/
clean: true,
/**
* Compress code to reduce bundle size.
*/
minify: false,
/**
* Target ECMAScript version for the output.
*/
target: 'es2022',
/**
* Callback function to execute after a successful build.
*/
onSuccess() {
console.info('🙏 Build succeeded!');
},
/**
* External dependencies that should not be bundled, but provided by the consumer.
*/
external: ['zod', '@composio/core', /^node:/],
/**
* Control how Node.js built-in module imports are handled.
* When true, imports like `fs` are transformed to `node:fs`.
*/
nodeProtocol: true,
/**
* Configuration for @arethetypeswrong/cli.
* Uses '.' entrypoint to check the package root via the exports field,
* since src/index.ts is only used during development and not exported.
* Uses the ESM-only profile because packages no longer publish CJS entrypoints.
*/
attw: {
entrypoints: ['.'],
enabled: !isTurboTask,
level: 'error',
profile: 'esm-only',
ignoreRules: [
/* Node.js 10 only, attw doesn't automatically exclude it despite the selected profile */ 'internal-resolution-error',
],
},
/**
* Configuration for publint.
*/
publint: {
enabled: !isTurboTask,
level: 'error',
pack: 'pnpm',
},
} satisfies UserConfig;