-
Notifications
You must be signed in to change notification settings - Fork 662
feat: improve Lingo.dev Compiler initialization API #1210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davidturnbull
wants to merge
29
commits into
main
Choose a base branch
from
davidt-compiler-init-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vrcprl
approved these changes
Oct 21, 2025
Resolved conflicts in packages/compiler/src/index.ts by keeping the refactored structure that moves implementation to separate files (unplugin.ts, vite.ts, next.ts) while maintaining backward-compatible API.
- Align all packages to use vite ^6.0.0 - Add pnpm override to enforce single vite version - Cast lingo plugin in adonisjs demo to avoid type conflicts from multiple @types/node versions
…ode version The root cause was multiple @types/node versions (22.x and 24.x) in the monorepo causing pnpm to install vite multiple times with different type definitions. TypeScript treats Plugin types from different vite installations as incompatible. Solution: - Added @types/node: ^22.0.0 to pnpm overrides - Removed workaround 'as any' cast from adonisjs vite.config.ts - All packages now use unified @types/node@22.18.12 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
249b1ab to
101aaab
Compare
…conflicts Root cause: Different packages in the monorepo have different @types/node versions, causing pnpm to install multiple vite instances with incompatible Plugin type definitions. TypeScript treats these as different types even when structurally identical. Solution: Export vite plugin with `any` return type to avoid cross-package type conflicts while maintaining full internal type safety through explicit parameter typing. This is the idiomatic solution for plugin packages consumed across a monorepo with varying dependency versions. No dependency version changes needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
101aaab to
57a0278
Compare
Prevents pnpm from upgrading @noble/hashes from 1.5.0 to 2.0.1, which requires Node >= 20.19.0. CI runs Node 20.12.2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
When vite was added as devDependency to packages/compiler, pnpm re-resolved all dependencies and upgraded: - @noble/hashes 1.5.0 → 2.0.1 (requires Node >= 20.19.0, we have 20.12.2) - @paralleldrive/cuid2 2.2.2 → 2.3.0 (ESM-only, breaks CJS builds) Overrides force compatible versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 5bd0773.
- Compiler: Vitest ^3, Vite ^6 - Compiler: add peerDependencies vite ^6 - SDK: replace cuid2 with crypto.randomUUID - CLI/SDK: remove cuid2 dependency - Core: align @types/node to ^20.19.23 - Root: drop overrides for vite, @noble/hashes, cuid2 Verified: compiler and sdk build; compiler tests pass
- Add wrapper to handle CJS/ESM default - Use wrapper in runtime code to avoid SSR crash - Keep types via typeof default
… ^5 || ^6 (optional)
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor Lingo.dev Compiler API with dedicated framework-specific export paths for Vite and Next.js, improving developer experience with clearer imports and plugin usage patterns.
What changed
New framework-specific export paths
The compiler now provides dedicated, publicly-documented export paths instead of requiring framework-specific method access on a default export:
Before (old pattern):
After (new pattern):
Structural changes
packages/compiler/src/vite.ts: Exportslingo()function that returns a Vite-compatible plugin. Automatically detects React Router and emits appropriate build events.packages/compiler/src/next.ts: ExportswithLingo()function with Next.js-specific configuration handling (Webpack, Turbopack, etc).packages/compiler/src/unplugin.ts: Extracted core unplugin logic that was previously inindex.ts.packages/compiler/src/index.ts: Now maintains backward compatibility by delegating to the new framework-specific modules../compiler/viteand./compiler/nextexport paths in bothpackages/cli/package.jsonandpackages/compiler/package.json.packages/cli/tsup.config.tsto build the new export paths.Demo updates
All demo projects have been updated to use the new API:
demo/vite-project/vite.config.ts: Now useslingo()as a regular plugin instead of the curried wrapper patterndemo/react-router-app/vite.config.ts: Simplified to inline plugin formatdemo/adonisjs/vite.config.ts: Uses new import path with cleaner plugin arraydemo/next-app/next.config.ts: UseswithLingo()instead oflingoCompiler.next()Why
Testing
To verify the new API works correctly:
Verify package exports are built correctly:
Test Vite integration with demo project:
Test Next.js integration with demo project:
Test React Router demo:
Verify backward compatibility:
lingoCompiler.vite()andlingoCompiler.next()API should continue working