Skip to content

feat: dynamically load export converters from jsdelivr CDN#3558

Open
mitre88 wants to merge 1 commit into
tscircuit:mainfrom
mitre88:feat/dynamic-jsdelivr-converters
Open

feat: dynamically load export converters from jsdelivr CDN#3558
mitre88 wants to merge 1 commit into
tscircuit:mainfrom
mitre88:feat/dynamic-jsdelivr-converters

Conversation

@mitre88

@mitre88 mitre88 commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Fixes tscircuit/tscircuit#1539

/claim tscircuit/tscircuit#1539

Instead of bundling heavy converter packages into the standalone bundle, each converter is now lazy-loaded on demand from pinned jsdelivr CDN URLs when the user requests an export.

What changed

  • Added lib/optional-features/exporting/dynamic-converters.ts with typed dynamic loaders, pinned jsdelivr ESM URLs, singleton-promise cache, and retry-after-failure behavior.
  • Replaced static converter imports and @tscircuit/internal-dynamic-import converter calls in export paths.
  • Replaced BomTable's static BOM converter import with the dynamic loader.
  • Removed 6 converter packages from devDependencies.
  • Added focused tests for pinned CDN URLs, cache behavior, retry behavior, and static import guardrails.

Notes

This intentionally leaves export-pinout-svg.ts unchanged because it loads circuit-to-svg, not one of the circuit-json-to-* converter packages targeted by the issue.

Validation

bun test
bun run format:check
bun run build:lib
bun run build:standalone
bun run build:standalone-preview
git diff --check

Results:

  • bun test: 25/25 passed
  • format:check: clean
  • build:lib: success
  • build:standalone: success
  • build:standalone-preview: success
  • git diff --check: clean

Risk

If jsdelivr is unavailable, export actions that need these converters will fail until the CDN recovers. The URLs are pinned to exact versions to keep behavior reproducible.

@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
runframe Ready Ready Preview, Comment Jun 14, 2026 10:11pm

Request Review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae3e5e384b

ℹ️ 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".

projectName: string
}) => {
const { circuitJsonToStep } = await importer("circuit-json-to-step")
const { circuitJsonToStep } = await loadStepConverter()

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 Register the GLTF converter before STEP export

When users export STEP with components (this flow always passes includeComponents: true below), circuit-json-to-step@0.0.33 delegates component mesh generation to circuit-json-to-gltf via a dynamic import and falls back to globalThis.tscircuitDynamicModules. This new loader only imports the STEP module, so the browser/CDN path has no registered GLTF module to fall back to and STEP exports with components can fail before producing a file. Please preload/register the GLTF converter for the STEP path or use a STEP bundle that includes that dependency.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

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

@mitre88

mitre88 commented Jun 5, 2026

Copy link
Copy Markdown
Author

Rebased this PR on current main to resolve the merge conflict from upstream dependency updates. The diff is still scoped to dynamic jsdelivr converter loading/removing bundled converter deps.\n\nCurrent validation after rebase:\n- bun install\n- bun test tests/dynamic-converters.test.ts\n- bun run format:check\n- bun run build:lib\n- git diff --check\n\nGitHub checks are green again and the PR is mergeable.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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

@mitre88

mitre88 commented Jun 9, 2026

Copy link
Copy Markdown
Author

Rebased this PR again on current main after the latest upstream package/version updates. The conflict was limited to package.json/bun.lock; the PR still only removes the bundled converter deps and dynamically loads the pinned converter modules from jsdelivr.\n\nValidation after the rebase:\n- bun install\n- bun test tests/dynamic-converters.test.ts\n- bun run format:check\n- bun run build:lib\n- git diff --check origin/main...HEAD\n\nGitHub checks are green and the PR is mergeable again.

@mitre88

mitre88 commented Jun 10, 2026

Copy link
Copy Markdown
Author

Rebased once more on current main (d48ead15) after upstream dependency updates touched package.json/bun.lock again. The PR remains scoped to removing the bundled converter deps and loading the pinned converter modules dynamically from jsdelivr.

Validation after this rebase:

  • bun install
  • bun test tests/dynamic-converters.test.ts (8 passed)
  • bun run format:check
  • bun run build:lib
  • git diff --check origin/main...HEAD

GitHub checks are green again (test, format-check, type-check, Vercel) and the PR is clean/mergeable.

@mitre88

mitre88 commented Jun 12, 2026

Copy link
Copy Markdown
Author

Rebased again on current main (ac4302ee) after the latest upstream package updates. The only conflict was again in package.json/bun.lock; the PR still only removes the bundled converter deps and loads pinned converter modules dynamically from jsdelivr.

Local validation on this commit (01208b4f):

  • bun install
  • bun test tests/dynamic-converters.test.ts (8 passed)
  • bun run format:check
  • bun run build:lib
  • git diff --check origin/main...HEAD

Vercel is green. The GitHub Actions workflows (test, format-check, type-check) are currently marked action_required, so they appear to need maintainer approval to run for the updated fork commit.

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.

Dynamically load converters like circuit-json-to-gerber etc. on-the-fly using jsdelivr instead of bundling, remove as dependency

1 participant