Skip to content

feat(bundle): bundle the entire project + deps to one file to easier installation for devs#21

Merged
kfirstri merged 5 commits intomainfrom
bundle-deps
Jan 14, 2026
Merged

feat(bundle): bundle the entire project + deps to one file to easier installation for devs#21
kfirstri merged 5 commits intomainfrom
bundle-deps

Conversation

@kfirstri
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.1-pr.21.b84b124

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.1-pr.21.b84b124"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.1-pr.21.b84b124"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Jan 14, 2026

PR Review: Bundle CLI to Single File

Summary

This PR moves all runtime dependencies to devDependencies and bundles them into a single file using tsdown. It also replaces jsonc-parser with json5 for JSON parsing. While the bundling approach is valid, there are several concerns that should be addressed.


🔴 Critical Issues

1. Breaking Change: Lost JSONC Support

  • Issue: The PR removes jsonc-parser which explicitly supported JSONC features (comments, trailing commas) and replaces it with json5
  • Impact: While json5 does support comments and trailing commas, the error handling has changed significantly
  • Location: src/core/utils/fs.ts:47-50
  • Evidence:
    • Old implementation had detailed error messages with offset information from jsonc-parser
    • New implementation only provides generic SyntaxError messages
    • README.md:54-64 shows the project explicitly advertises JSONC support with comments in examples
  • Recommendation: Either keep jsonc-parser as a bundled dependency or ensure json5 provides equivalent functionality and error messages

2. Only One Dependency Remains

  • Issue: Moving everything to devDependencies leaves only jsonc-parser as a runtime dependency
  • Question: If the goal is to bundle all dependencies, why keep jsonc-parser? Was this intentional or an oversight?
  • Location: package.json:35
  • Recommendation: Clarify the bundling strategy - should ALL dependencies be bundled, or only some?

⚠️ Major Concerns

3. No Bundle Verification

  • Issue: The PR doesn't demonstrate that the bundled output actually works
  • Missing:
    • No verification that all dependencies are properly bundled
    • No check that the bundled CLI can run independently
    • No validation of bundle size
  • Recommendation:
    • Test the built CLI in a fresh directory without node_modules
    • Add bundle size reporting to CI
    • Document expected bundle size

4. Incomplete Migration

  • Issue: Changed from jsonc-parser to json5 but didn't verify compatibility
  • Concerns:
    • jsonc-parser had specific error handling with ParseError types
    • json5 has different error handling and may have different parsing rules
    • No tests verify the migration maintains existing behavior
  • Test Case: tests/fixtures/invalid-json/config.jsonc - does this still fail appropriately?
  • Recommendation: Add tests that verify:
    • Comments in JSONC files still work
    • Trailing commas still work
    • Error messages are still helpful

5. Templates Directory Handling

  • Issue: tsdown.config.mjs has copy: ["templates"] but there's no verification that this works with the bundled output
  • Location: tsdown.config.mjs:10
  • Recommendation: Verify templates are accessible at runtime in the bundled CLI

📝 Code Quality Issues

6. Unclear Commit Messages

  • Issue: Second commit message "no need to no external" is unclear
  • Impact: Makes it hard to understand what changed and why
  • Recommendation: Use clear, descriptive commit messages

7. Missing Documentation

  • Issue: No documentation about the bundling approach or why this change was made
  • Missing:
    • Why bundle dependencies?
    • What's the installation benefit?
    • Are there any trade-offs?
  • Recommendation: Update README.md or add comments explaining the bundling strategy

🎯 Testing Concerns

8. No New Tests

  • Issue: Major change to dependency management and JSON parsing with no new tests
  • Risk: Breaking changes may not be caught
  • Recommendation: Add tests for:
    • JSONC comment support
    • JSONC trailing comma support
    • Error message quality
    • Bundle functionality

9. Test Coverage for Error Cases

  • Issue: Changed error handling in fs.ts but existing test at project.test.ts:51-55 only checks that it throws, not the error message quality
  • Risk: Users may get worse error messages without noticing
  • Recommendation: Strengthen error message tests

✅ Positive Aspects

  1. Valid Approach: Bundling dependencies can simplify installation and reduce dependency conflicts
  2. Clean Diff: The changes are focused and easy to review
  3. Existing Tests: The project has tests that should catch major breakage

🔧 Recommendations

Before merging:

  1. Verify the bundling works:

    npm run build
    cd /tmp/test-cli
    /path/to/cli/dist/cli/index.js --help
  2. Test JSONC features still work:

    • Create a config with comments
    • Create a config with trailing commas
    • Verify both parse correctly
  3. Check bundle size: Ensure the bundle isn't excessively large

  4. Update documentation: Explain why bundling was chosen

  5. Add tests: Verify JSONC support and error messages

  6. Clarify dependency strategy: Should jsonc-parser also be bundled? Or should it become json5?

  7. Consider keeping jsonc-parser: It was likely chosen for a reason (better JSONC support, better errors). If switching to json5, document why it's better.


Security Review

✅ No security concerns identified. The changes don't introduce any obvious vulnerabilities.

Performance Considerations

  • Positive: Bundled CLI may start faster (fewer module resolutions)
  • Consideration: Bundle size should be monitored
  • Question: Does bundling affect template copying performance?

Overall Assessment: This PR needs more work before merging. The bundling approach is sound, but the migration from jsonc-parser to json5 needs verification, testing, and documentation.

@claude
Copy link

claude bot commented Jan 14, 2026

Pull Request Review: Bundle Dependencies for Zero-Dependency Distribution

Summary

This PR implements a zero-dependency distribution strategy by moving all runtime dependencies to devDependencies and relying on bundling with tsdown. The goal is to improve installation speed and avoid dependency conflicts by shipping a single bundled JavaScript file.

✅ Strengths

Architecture & Design

  • Clear vision: Zero-dependency distribution is a solid approach for CLI tools, similar to successful tools like esbuild
  • Good documentation: AGENTS.md and plan.md are well-updated with the new distribution strategy
  • Simplified installation: Users will benefit from faster installs with no dependency resolution

Code Quality

  • Clean refactoring: The switch from jsonc-parser to json5 is simpler and more intuitive
  • Better error messages: Error handling in fs.ts:49-50 now provides clearer feedback for JSON syntax errors
  • Consistent patterns: The code follows the established project conventions well

⚠️ Critical Issues

1. Missing Bundle Configuration (High Priority)

The tsdown.config.mjs is missing the noExternal configuration that's documented in plan.md:202:

// Current config is missing this:
noExternal: [/.*/]  // Bundle ALL dependencies

Impact: Without this setting, tsdown may not bundle all dependencies by default, which would break the zero-dependency promise.

Recommendation: Add the noExternal configuration to tsdown.config.mjs to explicitly bundle all dependencies:

export default defineConfig({
  entry: ["src/cli/index.ts"],
  format: ["esm"],
  platform: "node",
  outDir: "dist/cli",
  clean: true,
  tsconfig: "tsconfig.json",
  copy: ["templates"],
  noExternal: [/.*/],  // Bundle all dependencies
});

2. Missing Runtime Dependency (Critical)

The package.json now has only one runtime dependency: jsonc-parser: "^3.3.1"

However, the code at src/core/utils/fs.ts:10 imports:

import JSON5 from "json5";

But json5 is in devDependencies, not dependencies. This means:

  • If bundling fails or is incomplete, the CLI will crash at runtime
  • Users installing from source would get runtime errors

Recommendation: Either:

  1. Keep jsonc-parser as the only runtime dependency (so it works unbundled)
  2. OR remove ALL dependencies (including jsonc-parser) if you're confident bundling works 100%

3. Lack of Bundle Verification

There's no test or CI check to verify:

  • That the bundle actually includes all dependencies
  • That the bundled output works correctly
  • The bundle size is reasonable

Recommendation: Add a post-build verification step:

"scripts": {
  "build": "tsdown",
  "postbuild": "node scripts/verify-bundle.js",
  "test:bundle": "node dist/cli/index.js --version"
}

⚡ Performance Considerations

Bundle Size

  • Question: What's the bundle size after including all dependencies?
  • The PR description should include before/after metrics
  • Large bundles could negate installation speed benefits

Tree Shaking

  • tsdown (Rolldown) should tree-shake unused code
  • Verify that large dependencies like zod and @clack/prompts are optimally bundled

🔒 Security Concerns

Supply Chain

  • Reduced attack surface ✅: Bundling means fewer packages in node_modules for end users
  • Development risk ⚠️: All devDependencies can still introduce vulnerabilities during build
  • Consider using npm audit in CI for devDependencies

Dependency Pinning

  • Moving to devDeps means more frequent updates needed
  • Consider pinning exact versions for reproducible builds

🧪 Test Coverage

Existing Tests

  • ✅ Good: Existing tests in tests/core/project.test.ts cover config reading
  • ⚠️ Gap: No tests specifically for the JSON5 migration

Missing Tests

  1. JSON5 parsing tests: Verify comments and trailing commas work

    it("parses JSON5 with comments", async () => {
      // Test file with // and /* */ comments
    });
  2. Bundle integration tests: Verify the built CLI actually works

    it("bundled CLI runs without node_modules", async () => {
      // Run the built CLI in an isolated environment
    });
  3. Error handling: Test invalid JSON5 syntax error messages

📝 Additional Recommendations

Documentation

  1. Add a "How bundling works" section to AGENTS.md
  2. Document the build and publish process
  3. Add bundle size to release notes

Package.json Improvements

Consider adding:

{
  "dependencies": {},  // Explicitly show zero deps
  "bundledDependencies": [],  // Or list what's bundled
  "publishConfig": {
    "access": "public"
  }
}

Future Considerations

  1. Source maps: Consider including source maps for better error debugging
  2. Watch mode: Ensure dev mode works with unbundled code
  3. Upgrade path: Document how to upgrade for users with existing installations

🎯 Action Items

Before Merging:

  1. ✅ Add noExternal: [/.*/] to tsdown.config.mjs
  2. ✅ Remove jsonc-parser from dependencies OR keep it as a fallback
  3. ✅ Add bundle verification tests
  4. ✅ Test the built CLI in an isolated environment (no node_modules)
  5. ✅ Measure and document bundle size
  6. ✅ Add tests for JSON5 parsing edge cases

Nice to Have:

  • Performance benchmarks (installation time comparison)
  • Bundle analysis report
  • Documentation on debugging bundled code

Verdict

This is a well-intentioned refactor with clear benefits, but it has critical implementation gaps that must be addressed before merging. The missing bundle configuration and incomplete dependency migration could cause runtime failures.

Recommendation: Request changes to add proper bundle configuration and verification tests.


Great work on improving the installation experience! The direction is solid, just needs a few technical adjustments to ensure reliability. 🚀

@claude
Copy link

claude bot commented Jan 14, 2026

Pull Request Review: Bundle Dependencies for Zero-Dependency Distribution

Summary

This PR implements a zero-dependency distribution strategy by moving all runtime dependencies to devDependencies and replacing jsonc-parser with json5. The goal is to bundle everything into a single JavaScript file for faster installation.

Critical Issues

🔴 Missing Bundle Configuration

Severity: High | tsdown.config.mjs:3

The tsdown configuration is missing the noExternal option required to bundle all dependencies. According to the plan.md documentation (line 202), the config should include noExternal: [/.*/] to bundle all packages.

Current config:

export default defineConfig({
  entry: ["src/cli/index.ts"],
  format: ["esm"],
  platform: "node",
  outDir: "dist/cli",
  clean: true,
  tsconfig: "tsconfig.json",
  copy: ["templates"],
});

Expected config:

export default defineConfig({
  entry: ["src/cli/index.ts"],
  format: ["esm"],
  platform: "node",
  outDir: "dist/cli",
  clean: true,
  tsconfig: "tsconfig.json",
  copy: ["templates"],
  noExternal: [/.*/], // Bundle all dependencies
});

Impact: Without this configuration, dependencies won't be bundled, defeating the entire purpose of the PR. Users will still need to install dependencies at runtime.

Recommendation: Add noExternal: [/.*/] to the tsdown config and verify the build produces a self-contained bundle.


🟡 Unverified Build Process

Severity: Medium

The PR doesn't include evidence that the build was tested or that the bundling actually works. Before merging:

  1. Run npm run build to verify successful bundling
  2. Check the output dist/cli/index.js file size (should be larger with bundled deps)
  3. Test the CLI in a fresh directory without node_modules to confirm zero-dependency operation
  4. Verify that json5 is properly bundled and not imported as an external dependency

Code Quality

✅ Clean Dependency Migration

Location: src/core/utils/fs.ts:10,47

The migration from jsonc-parser to json5 is well-executed:

  • Import statement is clean and conventional
  • Error handling is improved with more specific error messages
  • The simplified parsing logic is easier to maintain

Before:

const errors: ParseError[] = [];
const result = parse(fileContent, errors, { allowTrailingComma: true });
if (errors.length > 0) {
  // Complex error handling...
}

After:

return JSON5.parse(fileContent);

Much cleaner! The error handling in the catch block is also more straightforward.


✅ Documentation Updates

Location: AGENTS.md, README.md, plan.md

Excellent documentation of the new zero-dependency strategy:

  • Clear explanation of the bundling approach
  • Updated dependency list with rationale
  • Proper warnings in the "10 Commandments" section

⚠️ Potential Breaking Change

Severity: Low | src/core/utils/fs.ts:48-50

The error message format changed from:

`File contains invalid JSONC: ${filePath} (${errorMessages})`

to:

`File contains invalid JSON: ${filePath} (${error.message})`

Considerations:

  1. Any code parsing these error messages might break
  2. Error message quality might differ (json5 vs jsonc-parser error messages)
  3. The term "JSONC" is more specific than "JSON" for config files that support comments

Recommendation: Test error messages with invalid JSON to ensure they're user-friendly. Consider keeping "JSONC" terminology for clarity.


Test Coverage

⚠️ No Tests for JSON5 Parsing

Location: tests/core/project.test.ts

The existing test file has a test case for invalid JSON syntax (line 51-55), but it doesn't verify:

  1. JSONC/JSON5 specific features work (comments, trailing commas)
  2. The migration from jsonc-parser to json5 didn't break anything
  3. Error messages are helpful for users

Recommendation: Add test cases for:

  • Files with comments (// comment and /* comment */)
  • Files with trailing commas
  • Verify error messages are user-friendly

Example test:

it("parses JSON5 with comments and trailing commas", async () => {
  const result = await readProjectConfig(
    resolve(FIXTURES_DIR, "json5-features")
  );
  expect(result.project.name).toBe("Test Project");
});

Security Considerations

✅ No Security Issues

The changes don't introduce security vulnerabilities:

  • json5 (2.2.3) is a well-maintained package with no known vulnerabilities
  • File system operations remain unchanged
  • No changes to authentication or API handling

Performance Considerations

✅ Improved Installation Performance

The zero-dependency approach will significantly improve npm install times:

  • No dependency resolution needed
  • Smaller package size on npm
  • No potential for version conflicts

⚠️ Bundle Size Impact

Consideration: Bundling all dependencies will increase the single file size. While this improves installation, it means:

  • Larger download for the initial package
  • All code loaded into memory even if not used

Recommendation: After implementing the noExternal config, verify the bundle size is reasonable (likely 500KB-2MB is acceptable for a CLI).


Best Practices

✅ Follows Repository Conventions

The changes align with patterns established in AGENTS.md:

  • Maintains the ES modules setup
  • Follows the zero-dependency commandment
  • Updates documentation appropriately

⚠️ Missing Changelog Entry

If this repo maintains a CHANGELOG.md, this significant architectural change should be documented there.


Action Items

Must fix before merge:

  1. ✅ Add noExternal: [/.*/] to tsdown.config.mjs
  2. ✅ Test the build process and verify bundling works
  3. ✅ Verify the built CLI works without node_modules

Should fix:
4. Add tests for JSON5-specific features (comments, trailing commas)
5. Verify error message quality for invalid JSON
6. Document bundle size after building

Nice to have:
7. Add CHANGELOG entry if applicable
8. Consider keeping "JSONC" terminology in error messages


Overall Assessment

Concept: ⭐⭐⭐⭐⭐ Excellent idea that will improve user experience

Implementation: ⭐⭐⭐ Good code changes, but missing critical bundling configuration

Recommendation: Request changes - The noExternal configuration is essential for this PR to work as intended. Once added and tested, this will be a great improvement to the CLI.


Great work on the dependency migration and documentation! The code changes are clean and well-thought-out. Just need that bundling config to make it complete. 🚀

@claude
Copy link

claude bot commented Jan 14, 2026

Pull Request Review: Bundle Dependencies for Zero-Dependency Distribution

Summary

This PR successfully implements a zero-dependency distribution strategy by bundling all runtime dependencies into a single JavaScript file. The changes align well with the stated goals and follow the project's architecture patterns.

✅ Strengths

1. Architecture & Design

  • Clear separation of concerns: Moving all dependencies to devDependencies is the correct approach for a bundled CLI
  • Consistent with project goals: Zero-dependency distribution significantly improves installation speed and reduces version conflicts
  • Well-documented: The changes to AGENTS.md, plan.md, and README.md properly document the new distribution strategy

2. Code Quality

  • Clean dependency swap: The replacement of jsonc-parser with json5 is straightforward and maintains functionality
  • Error handling preserved: The new implementation in src/core/utils/fs.ts:49-50 properly handles SyntaxError and provides clear error messages
  • Type safety maintained: TypeScript types are preserved throughout

3. Documentation

  • Comprehensive updates: All relevant documentation files updated
  • Clear user messaging: README.md now prominently features "Zero dependencies - installs in seconds"
  • Developer guidance: AGENTS.md rule feat(login): implement login flow with http #10 clearly states the bundling approach

⚠️ Issues & Recommendations

1. Error message change (Minor) - src/core/utils/fs.ts:50

The error message changed from "invalid JSONC" to "invalid JSON" but the file could be JSON5/JSONC (with comments). Consider changing to "invalid JSON5" for accuracy.

2. Test coverage for JSON5 features (Medium Priority)

The existing test at tests/core/project.test.ts:51-55 tests invalid JSON syntax but there are no tests for valid JSON5 syntax (comments, trailing commas). Add test fixtures that use JSON5-specific features.

3. json5 version (Low Priority) - package.json:51

Consider updating to json5@^2.2.4 for the latest security patches (current is 2.2.3 from April 2021).

4. Bundling verification missing (Medium Priority)

Add a post-build verification script to ensure zero runtime dependencies and that the bundled file is executable.

🔒 Security

No significant security concerns. The json5 package is well-maintained. Consider running npm audit periodically to check bundled dependencies.

🚀 Performance

Positive impacts: Faster installation, efficient bundle size, potentially faster startup. Negligible: JSON5 parsing is marginally slower but imperceptible for config files.

📊 Test Coverage

Current state: Existing tests should pass. Gaps: No tests for JSON5-specific syntax or bundled output verification.

🎯 Overall Assessment

Verdict: ✅ Approve with minor recommendations

This PR successfully achieves its goals and follows best practices. The migration from jsonc-parser to json5 is clean.

Recommended before merge:

  1. Update error message to say "JSON5" instead of "JSON" (src/core/utils/fs.ts:50)
  2. Upgrade to json5@^2.2.4 for security fixes
  3. Add test coverage for JSON5 syntax features

Recommended post-merge:

  1. Add bundle verification script to CI/CD
  2. Monitor bundle size and startup performance
  3. Run npm audit on bundled dependencies periodically

🏆 Nice Work!

The zero-dependency approach is a great developer experience improvement. Users will appreciate the fast installation times, and the bundled distribution eliminates dependency conflicts.

@kfirstri kfirstri merged commit 66f9301 into main Jan 14, 2026
5 checks passed
@kfirstri kfirstri deleted the bundle-deps branch January 14, 2026 09:37
@github-project-automation github-project-automation bot moved this from Backlog to Done in CLI Development Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant