1 import { mkdir, writeFile } from "fs/promises"
2 import path from "path"
3
4 // This package is `"type": "module"`, so the CommonJS output of
5 // `tsconfig.cjs.json` needs its own `package.json` to be treated as CJS by
6 // Node and bundlers.
7 const cjsDir = path.join(process.cwd(), "dist", "cjs")
8
9 await mkdir(cjsDir, { recursive: true })
10 await writeFile(
11 path.join(cjsDir, "package.json"),
12 `${JSON.stringify({ type: "commonjs" }, undefined, 2)}\n`
13 )