Skip to content

feat: parse .kicad_mod imports to circuit JSON#1836

Closed
bimakw wants to merge 1 commit intotscircuit:mainfrom
bimakw:feat/kicad-mod-import-parsing
Closed

feat: parse .kicad_mod imports to circuit JSON#1836
bimakw wants to merge 1 commit intotscircuit:mainfrom
bimakw:feat/kicad-mod-import-parsing

Conversation

@bimakw
Copy link

@bimakw bimakw commented Jan 30, 2026

Summary

Parse .kicad_mod files at import time and export circuit JSON directly, enabling:

import footprint from "./my-footprint.kicad_mod"
<chip footprint={footprint} name="U1" />

Changes

  • Modify lib/shared/register-static-asset-loaders.ts to parse .kicad_mod files using kicad-component-converter (already a dependency)
  • Update TypeScript declaration to return AnyCircuitElement[] instead of string
  • Add tests for the new behavior

How It Works

The existing Bun plugin for static assets now has special handling for .kicad_mod:

  1. Reads the file content at import time
  2. Parses it using parseKicadModToCircuitJson()
  3. Exports the circuit JSON array directly

Other static assets (.gltf, .step, etc.) continue to export file paths as before.

Test Plan

  • Test that plugin exports circuit JSON array
  • Test that circuit JSON contains pcb_smtpad elements
  • Test that circuit JSON has valid structure
  • Test that footprint can be used directly

Closes tscircuit/tscircuit#768
/claim tscircuit/tscircuit#768

- Modify register-static-asset-loaders.ts to parse .kicad_mod files
  using kicad-component-converter instead of just exporting file paths
- Update TypeScript declaration to return AnyCircuitElement[]
- Add tests for kicad_mod import parsing

This enables direct import of .kicad_mod files as circuit JSON:
```tsx
import footprint from "./my-footprint.kicad_mod"
<chip footprint={footprint} name="U1" />
```

Closes tscircuit/tscircuit#768
@bimakw
Copy link
Author

bimakw commented Jan 31, 2026

Hey @seveibar, this PR adds kicad_mod import support directly in the CLI's asset loader.

Instead of creating a separate Bun plugin, I modified register-static-asset-loaders.ts to parse the file at import time using the existing kicad-component-converter dependency.

This approach keeps the parsing logic in CLI where the dev server handles it, rather than in core or the main tscircuit package. Let me know if you'd prefer a different approach!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@bimakw
Copy link
Author

bimakw commented Feb 3, 2026

Hey @seveibar, just checking in on this one. All CI checks are passing and the implementation is complete.

Quick recap of what this PR does:

  • Parses .kicad_mod files at import time using kicad-component-converter
  • Returns circuit JSON array directly (instead of file path)
  • Enables import footprint from "./my-footprint.kicad_mod" syntax

Happy to make any changes if you have feedback on the approach!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@bimakw
Copy link
Author

bimakw commented Feb 6, 2026

Still active on this. All CI green, no conflicts. This adds .kicad_mod import parsing in the CLI asset loader — converts to circuit JSON at import time so no changes needed in core.

@seveibar would love your take on the approach when you get a chance. Happy to adjust if needed.

@guptadeepak8
Copy link

@bimakw Send your pr to Discord to get approval from maintainers

@techmannih techmannih requested review from imrishabh18 and seveibar and removed request for seveibar February 7, 2026 15:29
@seveibar
Copy link
Contributor

seveibar commented Feb 7, 2026

This is implemented already via platformConfig no?

@seveibar seveibar closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support direct import of kicad_mod files

3 participants