Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
new init that includes a build command, tsup is a dep
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Apr 19, 2024
1 parent 14e0490 commit 7fbaa95
Show file tree
Hide file tree
Showing 5 changed files with 1,072 additions and 22 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions lib/cmd-fns/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const initCmd = async (ctx: AppContext, args: any) => {
packageJson.scripts ??= {}
packageJson.scripts.start = "npm run dev"
packageJson.scripts.dev = "tsci dev"
packageJson.scripts.build = "tsup ./index.ts --sourcemap --dts"
writeFileSync("package.json", JSON.stringify(packageJson, null, 2))

console.log(`Adding ".tscircuit" to .gitignore`)
Expand Down
39 changes: 31 additions & 8 deletions lib/cmd-fns/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,38 @@ export const publish = async (ctx: AppContext, args: any) => {
)
}

await esbuild.build({
entryPoints: ["index.ts"], // TODO dynamically determine entrypoint
bundle: true,
platform: "node",
packages: "external",
outdir: "dist",
})
// This works but doesn't emit types, we're just going to build somewhat
// normally for now
// await esbuild.build({
// entryPoints: ["index.ts"], // TODO dynamically determine entrypoint
// bundle: true,
// platform: "node",
// packages: "external",
// outdir: "dist",
// })
await $`npm run build`

if (packageJson.module) {
console.log(kleur.yellow("package.json module field detected. Removing..."))
delete packageJson.module
await fs.writeFile(
Path.join(ctx.cwd, "package.json"),
JSON.stringify(packageJson, null, 2)
)
}

// Publish to npm??
if (packageJson.main !== "./dist/index.cjs") {
console.log(
kleur.yellow(
`package.json main field is not set to "./dist/index.cjs". Setting it...`
)
)
packageJson.main = "./dist/index.cjs"
await fs.writeFile(
Path.join(ctx.cwd, "package.json"),
JSON.stringify(packageJson, null, 2)
)
}

// Upload to tscircuit registry
// 1. Get the package name and version from package.json
Expand Down
Loading

0 comments on commit 7fbaa95

Please sign in to comment.