Skip to content

feat: add playground and refactor code structure#358

Merged
jonaslagoni merged 15 commits intomainfrom
playground
Apr 26, 2026
Merged

feat: add playground and refactor code structure#358
jonaslagoni merged 15 commits intomainfrom
playground

Conversation

@jonaslagoni
Copy link
Copy Markdown
Contributor

@jonaslagoni jonaslagoni commented Apr 19, 2026

Note

Medium Risk
Medium risk because it refactors the generation pipeline from writing files during generation to returning GeneratedFile[] and moves filesystem writes into the CLI, which can affect output paths/deduplication and downstream integrations.

Overview
Adds a browser build + API for in-browser codegen. Introduces src/browser entrypoints (generate, parseConfig, BrowserOutput) plus an esbuild browser bundling setup with Node polyfills and targeted shims for fs, @asyncapi/parser/browser, swagger-parser, and json-schema-ref-parser (including lodash-to-lodash-es redirection and a SlowBuffer patch).

Refactors core generation to be I/O-free. Generators and renderGraph now return GeneratedFile[] (path+content) instead of filesWritten paths, with shared Modelina generation via generateModels() and new portable path helpers (joinPath, relativePath); the CLI generate command now writes results to disk via writeGeneratedFiles() and updates verbose/JSON output accordingly.

Tests and tooling updated. Adds comprehensive browser generation tests (AsyncAPI/OpenAPI/JSON Schema, $ref cases, dependency ordering) and updates snapshots/path handling; adds esbuild tooling and typecheck steps to lint.

Reviewed by Cursor Bugbot for commit c972979. Bugbot is set up for automated code reviews on this repo. Configure here.

@jonaslagoni jonaslagoni requested a review from ALagoni97 as a code owner April 19, 2026 07:43
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 19, 2026

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

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Apr 26, 2026 4:07pm
the-codegen-project-mcp Ready Ready Preview, Comment Apr 26, 2026 4:07pm

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

Deploy Preview for the-codegen-project ready!

Name Link
🔨 Latest commit 916f445
🔍 Latest deploy log https://app.netlify.com/projects/the-codegen-project/deploys/69ee380bf130de00085429af
😎 Deploy Preview https://deploy-preview-358--the-codegen-project.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c972979. Configure here.

Comment thread src/browser/config.ts
Comment thread src/browser/shims/asyncapi-parser.ts
Comment thread src/browser/adapters/output.ts
…inputs

When 'from' is absolute and 'to' is relative (or vice versa), resolve
the relative path against process.cwd() in Node so the result no longer
depends on how deep the absolute path is from the filesystem root.
Previously the mixed-mode branch stripped the root prefix from the
absolute path and treated both as relative, producing different import
paths depending on where CI checked the repo out.

Browser environments (no process.cwd) retain the previous strip-prefix
fallback, since real absolute filesystem paths shouldn't appear there.

Refresh channels snapshots to the restored 5-level import depth.
Docusaurus executes client modules during the server-side build to
prerender pages. The playground page statically imported Monaco Editor
and the suppressResizeObserver client module, both of which touch
window/document at module init and blew up the SSR pass with
'ReferenceError: window is not defined'.

- Wrap the playground page body in BrowserOnly so Monaco, the codegen
  browser bundle, and their dependencies are only evaluated on the
  client. The content lives in a new PlaygroundContent component that is
  required lazily inside the BrowserOnly render function.
- Guard the suppressResizeObserver client module with typeof window so
  it's a no-op during SSR.
…ode in extracted playground

Keeps behavioural parity with the pre-refactor index.tsx.
Netlify's build just OOMed in a worker ('Worker terminated due to
reaching memory limit: JS heap out of memory') while webpack minified
the client bundle (Monaco Editor + playground + JSON schemas). Bump
NODE_OPTIONS so the build stays within headroom on Netlify/Vercel (both
Linux). The Windows variant is unchanged since it's only used locally.
@jonaslagoni jonaslagoni merged commit 3e722c5 into main Apr 26, 2026
20 checks passed
@jonaslagoni jonaslagoni deleted the playground branch April 26, 2026 16:10
@jonaslagoni
Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 0.71.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant