Skip to content

fix: prevent deno.lock creation during extension bundling#491

Merged
stack72 merged 1 commit intomainfrom
fix/no-lock-extension-bundling
Feb 26, 2026
Merged

fix: prevent deno.lock creation during extension bundling#491
stack72 merged 1 commit intomainfrom
fix/no-lock-extension-bundling

Conversation

@stack72
Copy link
Copy Markdown
Contributor

@stack72 stack72 commented Feb 26, 2026

Summary

Fixes #490.

PR #452 introduced deno bundle for extension model transpilation. The subprocess inherits the user's CWD and Deno's default lockfile behavior creates/updates a deno.lock in the user's project root — polluting their repo with an unexpected file.

Why --no-lock is the right fix

The --no-lock flag tells Deno to skip lockfile auto-discovery entirely. This is correct for swamp's bundling use case because:

  1. Bundling is a build step, not a dependency install. Swamp bundles extensions at startup as an internal transpilation step. The user didn't ask Deno to manage their dependencies — swamp is doing it behind the scenes. Creating a deno.lock in their project is a side effect they never opted into.

  2. npm resolution still works without a lockfile. Packages are fetched from the registry and fully inlined into the bundle. The lockfile only pins versions across runs — it doesn't enable resolution.

  3. Version pinning is handled at the source level instead. Since there's no lockfile, users should pin explicit versions in their import specifiers (e.g., npm:[email protected]). The skill docs and examples are updated to reflect this guidance. This is actually more explicit and portable than relying on a lockfile that lives outside the extension source.

  4. Alternative approaches are worse:

    • Setting cwd on the subprocess to a temp dir would break relative imports in extensions
    • Cleaning up deno.lock after bundling is fragile and races with other processes
    • Using --lock=<temp-path> still creates a lockfile (just elsewhere) for no benefit

Changes

  • src/domain/models/bundle.ts — Add --no-lock to deno bundle args
  • src/domain/models/bundle_test.ts — Add test: bundles npm imports successfully and verifies no deno.lock is created in the source directory
  • .claude/skills/swamp-extension-model/SKILL.md — Add version pinning rule to Key Rules section
  • .claude/skills/swamp-extension-model/references/examples.md — Pin versions in import examples table and text analyzer example

Test plan

  • New test passes: deno run test src/domain/models/bundle_test.ts (4/4 pass)
  • Full test suite passes: 2167 passed, 0 failed
  • deno check — type checking passes
  • deno lint — linting passes
  • deno fmt — formatting passes
  • deno run compile — binary compiles successfully

🤖 Generated with Claude Code

Add --no-lock to the deno bundle subprocess to prevent Deno from
auto-discovering and creating/modifying a lockfile in the user's CWD.

Without this flag, every time swamp bundles an extension model at
startup, Deno's default lockfile behavior creates or updates a
deno.lock in whatever directory the user runs swamp from — polluting
their repo with an unexpected file.

The --no-lock flag disables lockfile auto-discovery entirely, which is
the correct behavior for swamp's use case: extensions are bundled as a
build step, not as a user-facing dependency install. npm resolution
still works normally — packages are fetched from the registry and
inlined into the bundle. The only tradeoff is that without a lockfile,
version resolution is not pinned across runs, which is addressed by
updating the extension model skill docs to require explicit version
pinning on npm imports (e.g., npm:[email protected] instead of
npm:lodash-es).

Changes:
- Add --no-lock flag to deno bundle args in bundle.ts
- Add test verifying npm imports resolve without creating deno.lock
- Add version pinning guidance to extension model skill docs
- Update example imports to use pinned versions

Co-authored-by: Blake Irvin <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
@stack72 stack72 force-pushed the fix/no-lock-extension-bundling branch from 725a27d to 45e20eb Compare February 26, 2026 17:38
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approved ✅

This PR cleanly fixes the deno.lock pollution issue (#490) with a minimal, well-targeted change.

What I Reviewed

Code Quality

  • ✅ TypeScript strict mode compliant - no any types
  • ✅ Named exports used per CLAUDE.md guidelines
  • ✅ AGPLv3 copyright headers present
  • ✅ Code passes deno check, deno lint, and deno fmt

Test Coverage

  • ✅ New test in bundle_test.ts verifies both bundle success AND lockfile absence
  • ✅ Proper cleanup with finally block
  • ✅ Test file location follows convention (next to source)

Domain-Driven Design

  • bundleExtension remains a clean stateless service
  • ✅ No DDD concerns - appropriate infrastructure code

Security

  • --no-lock flag is safe
  • ✅ No injection risks introduced

Documentation

  • ✅ SKILL.md updated with version pinning guidance
  • ✅ Examples updated to use pinned versions
  • ✅ Clear explanation of why npm:zod@4 is excepted (externalized)

No Blocking Issues

The implementation is clean and follows project conventions. The PR description thoroughly explains why --no-lock is the right approach over alternatives like temp directories or lockfile cleanup.

@stack72 stack72 merged commit 0a12c9f into main Feb 26, 2026
4 checks passed
@stack72 stack72 deleted the fix/no-lock-extension-bundling branch February 26, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide guidance on deno.lock file management

1 participant