Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.28-pr.198.1b295baPrefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.28-pr.198.1b295ba"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.28-pr.198.1b295ba"
}
}
Preview published to npm registry — try new features instantly! |
Code ReviewFound 1 issue: Missing initial build in watch modeFile: In watch mode, no initial build is performed. The When running Suggested fix: Add an initial await cp("./templates", path.join(distDir, "templates"), { recursive: true });
if (args.includes("--watch")) {
console.log("Watching for changes...");
// Perform initial build
const initialBuild = await runBuild();
console.log(initialBuild.outputs.map((o) => o.path).join(", "));
// Watch for changes
for await (const _event of watch("./src", { recursive: true })) {
const build = await runBuild();
console.log(build.outputs.map((o) => o.path).join(", "));
}
await new Promise(() => {});
}Context: Lines 17 to 27 in 768e53e |
build.ts
Outdated
| if (process.argv.includes("--watch")) { | ||
| console.log("\nWatching for changes..."); | ||
|
|
||
| for (const dir of ["./src"]) { |
There was a problem hiding this comment.
do we need this? future proofing?
There was a problem hiding this comment.
yes, there will be another entry directory.
I need to build Deno code, so I prefer not to put it together with Node
build.ts
Outdated
| for (const dir of ["./src"]) { | ||
| watch(dir, { recursive: true }, async (event, filename) => { | ||
| const cliBuild = await runBuild(); | ||
| console.log(cliBuild.outputs.map((o) => o.path).join(", ")); |
kfirstri
left a comment
There was a problem hiding this comment.
Love that we're extracting it out
| const runBuild = async () => { | ||
| const result = await Bun.build({ | ||
| entrypoints: ["./src/cli/index.ts"], | ||
| outdir: "./dist/cli", |
There was a problem hiding this comment.
Moving pure cli code into dedicated folder in dist.
This way we can safely add another output in dist (like for additional entries) without concerning with files overriding each other.
| ); | ||
| }; | ||
|
|
||
| await runBuild(); |
There was a problem hiding this comment.
Watch mode should start with fully building the code, otherwise it will wait for the first change to happen.
|
|
||
| // After bundling, import.meta.url points to dist/cli/index.js | ||
| // Templates are copied to dist/cli/templates/ | ||
| // Templates are copied to dist/templates/ |
There was a problem hiding this comment.
Comment was originally incorrect. templates were always in dist/templates/
|
|
||
| export function getTemplatesDir(): string { | ||
| return join(__dirname, "templates"); | ||
| return join(__dirname, "../templates"); |
There was a problem hiding this comment.
Since cli code is now in dist/cli - this path should change
There was a problem hiding this comment.
we just need to make sure it's working fine in dev + in dist
There was a problem hiding this comment.
when you say dev, what do you mean?
aren't templates used only for creation of the new app?
I tested it for creation and it works fine.
| "dev": "./bin/dev.ts", | ||
| "start": "./bin/run.js", | ||
| "clean": "rm -rf dist", | ||
| "clean": "rm -rf dist && mkdir -p dist", |
There was a problem hiding this comment.
recreating dist folder, so I could copy templates folder before running bun build
| @@ -1,5 +1,5 @@ | |||
| #!/usr/bin/env node | |||
| import { runCLI } from "../dist/index.js"; | |||
| import { runCLI } from "../dist/cli/index.js"; | |||
There was a problem hiding this comment.
See comments about output changes below
|
@claude review |
|
Claude finished @artemdemo's task in 1m 9s —— View job Code ReviewThis is a solid refactoring that improves the build process organization and adds useful watch mode functionality. The code is well-structured and the changes are mostly straightforward. Here are my findings: ✅ StrengthsGood architectural decisions:
Clean code:
🔍 Issues Found1. Inconsistent array iteration pattern (
|
package.json
Outdated
| "scripts": { | ||
| "build": "rm -rf dist && bun build src/cli/index.ts --outdir dist --target node --format esm --sourcemap=inline && cp -r templates dist/", | ||
| "build": "npm run clean && cp -r templates dist/ && bun run infra/build.ts", | ||
| "build:watch": "npm run clean && cp -r templates dist/ && bun run infra/build.ts --watch", |
There was a problem hiding this comment.
just for the sake of being aligned, can we use bun run clean in both commands?
kfirstri
left a comment
There was a problem hiding this comment.
I think it should be fine, just worried that this
export function getTemplatesDir(): string {
return join(__dirname, "../templates");Collapse comment
}
might break stuff between dev/release version?
other than that - awesome 💪
Note
Description
Refactors the build process by extracting build logic into a standalone
build.tsscript in the newinfra/directory. This improves maintainability and enables a new watch mode that automatically rebuilds when source files change, significantly improving the development experience. The build output structure is also updated to better organize bundled CLI code (dist/cli/) and template files (dist/templates/).Related Issue
None
Type of Change
Changes Made
infra/build.tsscript with explicit Bun build configuration and colored console output--watchflag) that monitors./srcdirectory and automatically rebuilds on changesdist/cli/index.js(bundled code) anddist/templates/(template files)build:watchnpm script for development workflowbin/run.jsto import from newdist/cli/index.jspathsrc/core/config.tsto match new structure (../templatesinstead oftemplates)CLITestkit.tsto reference new bundled file locationTesting
npm test)Checklist
Additional Notes
The watch mode uses Node.js
fs.watchwith recursive monitoring since Bun.build doesn't provide a programmatic watch API. Build output includes colored console messages using chalk for better visibility (green checkmarks for success, red for errors, cyan for file paths, yellow for watch mode status).Note: This changes the internal build output structure but does not affect the public API - the npm package still works identically for end users since
bin/run.jscorrectly imports from the new location.🤖 Generated by Claude | 2026-02-05 21:42 UTC