Skip to content

Use runtime project config in build, export, and simulate flows#3157

Merged
techmannih merged 1 commit into
tscircuit:mainfrom
techmannih:feat/runtime-project-config-build-export-simulate
Jun 2, 2026
Merged

Use runtime project config in build, export, and simulate flows#3157
techmannih merged 1 commit into
tscircuit:mainfrom
techmannih:feat/runtime-project-config-build-export-simulate

Conversation

@techmannih
Copy link
Copy Markdown
Member

Summary

This PR wires runtime project config into the actual CLI command flows for:

  • build
  • export
  • simulate

It allows tscircuit.config.ts / tscircuit.config.js to affect these command paths after the loader foundation from the previous PR.

Why

The previous PR added runtime project config loading, .env hydration, and JSON + module config merging.

That established the config loader foundation, but it did not yet make the actual CLI command handlers consume the new runtime config.

This PR is the next step: making the real command flows use the runtime config, especially platformConfig, so custom project-level behavior can reach command execution.

This follows the review direction to take the simplest path:

  • allow user config to provide platformConfig
  • merge it on top of the default eval platform config
  • validate through actual CLI command paths

What changed

Build command flow

Files:

  • cli/build/build-ci.ts
  • cli/build/get-build-entrypoints.ts
  • cli/build/register.ts

Changes:

  • build --ci now reads runtime project config via loadRuntimeProjectConfig(...)
  • build entrypoint discovery now respects runtime includeBoardFiles
  • build entrypoint discovery now respects runtime:
    • previewComponentPath
    • siteDefaultComponentPath
  • build now merges:
    • projectConfig.platformConfig
    • CLI override config from flags like:
      • --disable-pcb
      • --routing-disabled
      • --disable-parts-engine

Export command flow

File:

  • cli/export/register.ts

Changes:

  • export now loads runtime project config
  • merges user platformConfig with CLI disable-parts-engine override
  • passes merged config into export generation

Simulate command flow

File:

  • cli/simulate/register.ts

Changes:

  • simulate analog now loads runtime project config
  • merges user platformConfig with CLI disable-parts-engine override
  • passes merged config into circuit generation for simulation

Shared board-file discovery

File:

  • lib/shared/find-board-files.ts

Changes:

  • adds findBoardFilesAsync(...)
  • runtime config can now provide includeBoardFiles through tscircuit.config.ts/js
  • existing sync findBoardFiles(...) path is preserved

Shared platform config merging

File:

  • lib/shared/platform-config-utils.ts

Changes:

  • adds mergePlatformConfigs(...)
  • merges multiple PlatformConfig objects without losing nested maps like:
    • footprintLibraryMap
    • footprintFileParserMap
    • staticFileLoaderMap
    • autorouterMap
    • spiceEngineMap

Files changed

  • cli/build/build-ci.ts
  • cli/build/get-build-entrypoints.ts
  • cli/build/register.ts
  • cli/export/register.ts
  • cli/simulate/register.ts
  • lib/shared/find-board-files.ts
  • lib/shared/platform-config-utils.ts
  • tests/cli/runtime-project-config-command-flows.test.ts

Tests

Added focused runtime command-flow coverage for:

  • build entrypoints
  • export
  • simulate

Test file:

  • tests/cli/runtime-project-config-command-flows.test.ts

These tests use tscircuit.config.ts with a fake function-valued platformConfig.footprintLibraryMap.ti so the command paths exercise runtime project config, not just config parsing.

Validation

Passed locally:

  • bun test tests/cli/runtime-project-config-command-flows.test.ts for build-entrypoint coverage

Blocked locally for full export / simulate command validation by an existing repo/package issue:

  • the currently installed circuit-json-to-kicad package does not export resolveAndLoadKicad3dModelFiles
  • that causes command startup to fail before the runtime-config changes are fully exercised in those two command paths

Scope intentionally excluded

This PR does not include:

  • snapshot flow wiring
  • dev / runFrame / tsci dev runtime config wiring
  • kicadLibraryName runtime-config support
  • broader cloud/runtime design changes

Those can be handled in follow-up PRs.

@techmannih techmannih requested review from imrishabh18 and seveibar and removed request for seveibar June 2, 2026 17:52
@techmannih techmannih marked this pull request as ready for review June 2, 2026 17:52
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

platformConfig,

P1 Badge Avoid sending platformConfig functions to workers

When tscircuit.config.ts supplies a runtime platformConfig with function-valued maps such as footprintLibraryMap (the new tests use exactly this shape), tsci build --concurrency 2 routes buildOptions through worker.postMessage in buildFilesWithWorkerPool. Worker messages are structured-cloned, so those functions cannot be cloned and the build fails before any worker can use the config; this affects any parallel build that relies on runtime platform config.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/export/register.ts
},
) => {
const formatOption = options.format ?? "json"
const projectConfig = await loadRuntimeProjectConfig(process.cwd())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve export config from the input file

Loading runtime config from process.cwd() means tsci export /path/to/project/index.circuit.tsx ignores /path/to/project/tscircuit.config.ts whenever the command is invoked from another directory, even though the file argument and output location are already based on that project path. In that scenario custom footprints/platform settings silently disappear; resolve the project dir from file as the build flow does before loading the config.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

@techmannih techmannih merged commit 3f2b1b4 into tscircuit:main Jun 2, 2026
10 checks passed
@techmannih techmannih deleted the feat/runtime-project-config-build-export-simulate branch June 2, 2026 19:43
@tscircuitbot
Copy link
Copy Markdown
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐
Impact: Minor

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

4 participants