Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8d9649e
feat: improve Lingo.dev Compiler init
davidturnbull Oct 9, 2025
2e2b8c5
feat: rename to withLingo
davidturnbull Oct 9, 2025
07acc0d
chore: format
davidturnbull Oct 9, 2025
9b49e9c
chore: format
davidturnbull Oct 20, 2025
547c19d
fix: type error
davidturnbull Oct 21, 2025
c3d9c8f
docs: changeset
davidturnbull Oct 22, 2025
2691834
fix: ts errors
davidturnbull Oct 22, 2025
1bd83fd
fix: vite types
davidturnbull Oct 22, 2025
fe93e6d
Merge origin/main into davidt-compiler-init-api
davidturnbull Oct 22, 2025
35ed2d8
chore: downgrade vite to v6 for Node 20.12.2 compatibility
davidturnbull Oct 22, 2025
1fd597b
fix: use dynamic import for node-machine-id to resolve ESM/CommonJS i…
davidturnbull Oct 22, 2025
5153629
fix: resolve vite type incompatibilities across monorepo
davidturnbull Oct 22, 2025
d8b65b7
fix: resolve vite type incompatibilities by enforcing single @types/n…
davidturnbull Oct 22, 2025
57a0278
fix: use any return type for vite plugin to avoid cross-package type …
davidturnbull Oct 22, 2025
e45f5b8
fix: add @noble/hashes override for Node 20.12.2 compatibility
davidturnbull Oct 22, 2025
5bd0773
fix: formatting
davidturnbull Oct 22, 2025
587fc6c
fix: add dependency overrides to prevent incompatible upgrades
davidturnbull Oct 22, 2025
74f6973
test(compiler): mock CI env in vite/next specs
davidturnbull Oct 22, 2025
ad0b7f1
chore: ignore generated compiler dictionary cache file
davidturnbull Oct 22, 2025
e452427
refactor(compiler/next): drop lingo alias export; tests already use w…
davidturnbull Oct 22, 2025
bfd4a4a
Revert "fix: formatting"
davidturnbull Oct 26, 2025
b0ff598
refactor(workspace): remove pnpm overrides
davidturnbull Oct 26, 2025
71b28ec
chore: merge origin/main
davidturnbull Oct 26, 2025
721f150
chore(lockfile): update pnpm-lock.yaml after merge
davidturnbull Oct 26, 2025
254b668
chore: update format check
davidturnbull Oct 26, 2025
41f400e
fix(compiler): normalize @babel/traverse import for SSR interop
davidturnbull Oct 26, 2025
6ad70f2
fix(compiler): normalize @babel/generator import for SSR interop
davidturnbull Oct 26, 2025
b306819
feat(compiler): restore Next alias export 'lingo'; relax Vite peer to…
davidturnbull Oct 26, 2025
6841979
chore(compiler): remove unused Next alias export to avoid API churn
davidturnbull Oct 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/compiler-init-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lingo.dev/_compiler": minor
"lingo.dev": minor
---

Improved compiler initialization with dedicated framework exports and renamed Next.js integration to `withLingo`
16 changes: 14 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,20 @@ jobs:
- name: Configure Turbo cache
uses: dtinth/setup-github-actions-caching-for-turbo@v1

- name: Check formatting
run: pnpm format:check
- name: Check formatting (changed files only)
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.sha }}"
echo "Base: $BASE_SHA"
echo "Head: $HEAD_SHA"
# List changed files (added/copied/modified/renamed); exclude deletions
mapfile -t files < <(git diff --name-only --diff-filter=ACMR "$BASE_SHA...$HEAD_SHA")
if [ ${#files[@]} -eq 0 ]; then
echo "No changed files. Skipping Prettier check."
exit 0
fi
echo "Checking formatting for ${#files[@]} changed files."
pnpm exec prettier --check --ignore-unknown "${files[@]}"

- name: Build
run: pnpm turbo build --force
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ yarn-error.log*
.DS_Store
*.pem
i18n.cache
packages/compiler/src/lingo/dictionary.js
1 change: 0 additions & 1 deletion demo/adonisjs/bin/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
|
*/

// @ts-expect-error 2540
process.env.NODE_ENV = 'test'

import 'reflect-metadata'
Expand Down
2 changes: 1 addition & 1 deletion demo/adonisjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"prettier": "^3.5.3",
"ts-node-maintained": "^10.9.5",
"typescript": "~5.8.3",
"vite": "^6.3.5"
"vite": "^6.0.0"
},
"dependencies": {
"@adonisjs/auth": "^9.4.0",
Expand Down
29 changes: 14 additions & 15 deletions demo/adonisjs/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ import { getDirname } from '@adonisjs/core/helpers'
import inertia from '@adonisjs/inertia/client'
import adonisjs from '@adonisjs/vite/client'
import react from '@vitejs/plugin-react'
import lingoCompiler from 'lingo.dev/compiler'
import { type UserConfig, type PluginOption } from 'vite'
import { lingo } from 'lingo.dev/compiler/vite'
import { type UserConfig } from 'vite'

const viteConfig: UserConfig = {
plugins: [
lingo({
sourceRoot: 'inertia',
lingoDir: 'lingo',
sourceLocale: 'en',
targetLocales: ['es'],
rsc: false,
useDirective: false,
debug: false,
models: 'lingo.dev',
}),
inertia({
ssr: {
enabled: true,
Expand All @@ -17,7 +27,7 @@ const viteConfig: UserConfig = {
adonisjs({
entrypoints: ['inertia/app/app.tsx'],
reload: ['resources/views/**/*.edge'],
}) as unknown as PluginOption,
}),
],
resolve: {
alias: {
Expand All @@ -26,15 +36,4 @@ const viteConfig: UserConfig = {
},
}

const withLingo = lingoCompiler.vite({
sourceRoot: 'inertia',
lingoDir: 'lingo',
sourceLocale: 'en',
targetLocales: ['es'],
rsc: false,
useDirective: false,
debug: false,
models: 'lingo.dev',
})

export default withLingo(viteConfig)
export default viteConfig
4 changes: 2 additions & 2 deletions demo/next-app/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { NextConfig } from "next";
import lingoCompiler from "lingo.dev/compiler";
import { withLingo } from "lingo.dev/compiler/next";

const nextConfig: NextConfig = {
/* config options here */
};

export default lingoCompiler.next({
export default withLingo({
sourceLocale: "en",
targetLocales: ["es", "ja", "fr", "ru", "de", "zh", "ar", "ko"],
models: "lingo.dev",
Expand Down
2 changes: 1 addition & 1 deletion demo/react-router-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@types/react-dom": "^19.1.2",
"tailwindcss": "^4.1.4",
"typescript": "^5.8.3",
"vite": "^6.3.3",
"vite": "^6.0.0",
"vite-tsconfig-paths": "^5.1.4"
}
}
27 changes: 14 additions & 13 deletions demo/react-router-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { reactRouter } from "@react-router/dev/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { lingo } from "lingo.dev/compiler/vite";

// Compiler: import
import lingoCompiler from "lingo.dev/compiler";

export default defineConfig(({ isSsrBuild }) =>
lingoCompiler.vite({
sourceRoot: "app",
targetLocales: ["es", "fr", "de"],
useDirective: false,
models: "lingo.dev",
})({
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
}),
);
export default defineConfig(({ isSsrBuild }) => ({
plugins: [
lingo({
sourceRoot: "app",
targetLocales: ["es", "fr", "de"],
useDirective: false,
models: "lingo.dev",
}),
tailwindcss(),
reactRouter(),
tsconfigPaths(),
],
}));
2 changes: 1 addition & 1 deletion demo/vite-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"lingo.dev": "workspace:*",
"typescript": "~5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.3.5"
"vite": "^6.0.0"
}
}
29 changes: 11 additions & 18 deletions demo/vite-project/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";

// Compiler: add import
import lingoCompiler from "lingo.dev/compiler";

const viteConfig = {
plugins: [react()],
};
import { lingo } from "lingo.dev/compiler/vite";

// https://vite.dev/config/
export default defineConfig(() =>
// Compiler: add lingoCompiler.vite
lingoCompiler.vite({
sourceRoot: "src",
targetLocales: ["es", "fr", "ru", "de", "ja", "zh", "ar", "ko"],
models: "lingo.dev",
})(viteConfig),
);
// export default defineConfig({
// plugins: [react()],
// })
export default defineConfig(() => ({
plugins: [
lingo({
sourceRoot: "src",
targetLocales: ["es", "fr", "ru", "de", "ja", "zh", "ar", "ko"],
models: "lingo.dev",
}),
react(),
],
}));
19 changes: 17 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
"import": "./build/compiler.mjs",
"require": "./build/compiler.cjs"
},
"./compiler/vite": {
"types": "./build/compiler/vite.d.ts",
"import": "./build/compiler/vite.mjs",
"require": "./build/compiler/vite.cjs"
},
"./compiler/next": {
"types": "./build/compiler/next.d.ts",
"import": "./build/compiler/next.mjs",
"require": "./build/compiler/next.cjs"
},
"./react": {
"types": "./build/react.d.ts",
"import": "./build/react.mjs",
Expand Down Expand Up @@ -84,6 +94,12 @@
"compiler": [
"./build/compiler.d.ts"
],
"compiler/vite": [
"./build/compiler/vite.d.ts"
],
"compiler/next": [
"./build/compiler/next.d.ts"
],
"react": [
"./build/react.d.ts"
],
Expand Down Expand Up @@ -144,7 +160,6 @@
"@markdoc/markdoc": "^0.5.4",
"@modelcontextprotocol/sdk": "^1.5.0",
"@openrouter/ai-sdk-provider": "^0.7.1",
"@paralleldrive/cuid2": "^2.2.2",
"@types/ejs": "^3.1.5",
"ai": "^4.3.15",
"bitbucket": "^2.12.0",
Expand Down Expand Up @@ -233,7 +248,7 @@
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.17.16",
"@types/mdast": "^4.0.4",
"@types/node": "^22.10.2",
"@types/node": "^20.19.23",
"@types/node-gettext": "^3.0.6",
"@types/object-hash": "^3.0.6",
"@types/plist": "^3.0.5",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/compiler/next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type * from "@lingo.dev/_compiler/next";
export { default, withLingo } from "@lingo.dev/_compiler/next";
2 changes: 2 additions & 0 deletions packages/cli/src/compiler/vite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type * from "@lingo.dev/_compiler/vite";
export { default, lingo } from "@lingo.dev/_compiler/vite";
2 changes: 2 additions & 0 deletions packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default defineConfig({
"react/rsc": "src/react/rsc.ts",
"react/react-router": "src/react/react-router.ts",
compiler: "src/compiler/index.ts",
"compiler/vite": "src/compiler/vite.ts",
"compiler/next": "src/compiler/next.ts",
"locale-codes": "src/locale-codes/index.ts",
},
outDir: "build",
Expand Down
34 changes: 30 additions & 4 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@
"main": "build/index.cjs",
"types": "build/index.d.ts",
"module": "build/index.mjs",
"exports": {
".": {
"types": "./build/index.d.ts",
"import": "./build/index.mjs",
"require": "./build/index.cjs"
},
"./vite": {
"types": "./build/vite.d.ts",
"import": "./build/vite.mjs",
"require": "./build/vite.cjs"
},
"./next": {
"types": "./build/next.d.ts",
"import": "./build/next.mjs",
"require": "./build/next.cjs"
}
},
"files": [
"build"
],
Expand All @@ -35,7 +52,8 @@
"next": "15.2.4",
"tsup": "^8.3.5",
"typescript": "^5.4.5",
"vitest": "^2.1.4"
"vite": "^6.0.0",
"vitest": "^3.1.2"
},
"dependencies": {
"@ai-sdk/google": "^1.2.19",
Expand All @@ -55,13 +73,21 @@
"fast-xml-parser": "^5.0.8",
"ini": "^5.0.0",
"lodash": "^4.17.21",
"node-machine-id": "^1.1.12",
"object-hash": "^3.0.0",
"ollama-ai-provider": "^1.2.0",
"posthog-node": "^5.5.1",
"prettier": "^3.4.2",
"unplugin": "^2.1.2",
"zod": "^3.25.76",
"posthog-node": "^5.5.1",
"node-machine-id": "^1.1.12"
"zod": "^3.25.76"
},
"peerDependencies": {
"vite": "^5.0.0 || ^6.0.0"
},
"peerDependenciesMeta": {
"vite": {
"optional": true
}
},
"packageManager": "pnpm@9.12.3"
}
3 changes: 2 additions & 1 deletion packages/compiler/src/_base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import generate, { GeneratorResult } from "@babel/generator";
import generate from "./utils/babel-generator";
import type { GeneratorResult } from "./utils/babel-generator";
import * as t from "@babel/types";
import * as parser from "@babel/parser";
import { LocaleCode } from "@lingo.dev/_spec";
Expand Down
1 change: 1 addition & 0 deletions packages/compiler/src/core/unplugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { unplugin } from "../unplugin";
Loading
Loading