@@ -6,38 +6,14 @@ import {
66 getCacheDir ,
77 getCachePath ,
88 getConfigPath ,
9- getDevConfigPath ,
109} from "../utils/path-helpers" ;
11- import { createLoaderConfig } from "../utils/config-factory" ;
10+ import { createLingoConfig } from "../utils/config-factory" ;
1211import { logger } from "../utils/logger" ;
1312import { startTranslationServer } from "../translation-server" ;
14- import { CookieConfig , LoaderConfig } from "../types" ;
15- import { TurbopackOptions } from "next/dist/server/config-shared" ;
16-
17- export type LingoNextPluginOptions = {
18- /**
19- * File patterns to skip during transformation
20- * @default [/node_modules/, /\.spec\./, /\.test\./]
21- */
22- skipPatterns ?: RegExp [ ] ;
23-
24- /**
25- * Cookie configuration for locale persistence
26- * Shared between client-side LocaleSwitcher and server-side locale resolver
27- * @default { name: 'locale', maxAge: 31536000 }
28- */
29- cookieConfig ?: CookieConfig ;
30- } & Pick <
31- LoaderConfig ,
32- | "dev"
33- | "prompt"
34- | "models"
35- | "useDirective"
36- | "targetLocales"
37- | "sourceLocale"
38- | "lingoDir"
39- | "sourceRoot"
40- > ;
13+ import type { PartialLingoConfig } from "../types" ;
14+ import type { TurbopackOptions } from "next/dist/server/config-shared" ;
15+
16+ export type LingoNextPluginOptions = PartialLingoConfig ;
4117
4218/**
4319 * Check if Next.js supports stable turbopack config (Next.js 16+)
@@ -93,10 +69,7 @@ function buildLingoConfig(
9369 userNextConfig : NextConfig ,
9470 lingoOptions : LingoNextPluginOptions ,
9571) : NextConfig {
96- const lingoConfig = createLoaderConfig ( {
97- ...lingoOptions ,
98- framework : "next" ,
99- } ) ;
72+ const lingoConfig = createLingoConfig ( lingoOptions ) ;
10073
10174 // Prepare Turbopack loader configuration
10275 const loaderConfig = {
@@ -106,7 +79,6 @@ function buildLingoConfig(
10679 lingoDir : lingoConfig . lingoDir ,
10780 sourceLocale : lingoConfig . sourceLocale ,
10881 useDirective : lingoConfig . useDirective ,
109- framework : lingoConfig . framework ,
11082 } ,
11183 } ;
11284
@@ -118,15 +90,14 @@ function buildLingoConfig(
11890 } ) ,
11991 // TODO (AleksandrSl 02/12/2025): We can also inject default resolvers for locale based on the framework
12092 {
121- pattern : "**/dev-config.ts " ,
93+ pattern : "**/dev-config.mjs " ,
12294 config : {
12395 loaders : [
12496 {
12597 loader : "@lingo.dev/_compiler/dev-server-loader" ,
12698 options : {
12799 sourceRoot : lingoConfig . sourceRoot ,
128100 lingoDir : lingoConfig . lingoDir ,
129- cacheDir : getCacheDir ( lingoConfig ) ,
130101 dev : lingoConfig . dev ,
131102 sourceLocale : lingoConfig . sourceLocale ,
132103 } ,
@@ -140,7 +111,6 @@ function buildLingoConfig(
140111 const mergedResolveAlias = {
141112 ...existingResolveAlias ,
142113 "@lingo.dev/_compiler/config" : getConfigPath ( lingoConfig ) ,
143- "@lingo.dev/_compiler/dev-config" : getDevConfigPath ( lingoConfig ) ,
144114 } ;
145115
146116 // Build Turbopack config (handles Next.js 16+ vs <16)
@@ -191,7 +161,7 @@ function buildLingoConfig(
191161 | undefined ;
192162 try {
193163 translationServer = await startTranslationServer ( {
194- startPort : 60000 ,
164+ startPort : lingoConfig . dev ?. serverStartPort ,
195165 onError : ( err ) => {
196166 logger . error ( "Translation server error:" , err ) ;
197167 } ,
@@ -267,7 +237,6 @@ function buildLingoConfig(
267237 sourceLocale : lingoConfig . sourceLocale ,
268238 useDirective : lingoConfig . useDirective ,
269239 skipPatterns : lingoConfig . skipPatterns ,
270- framework : lingoConfig . framework ,
271240 } ,
272241 } ,
273242 ] ,
0 commit comments