1- /**
2- * Universal Plugin for Lingo.dev Compiler
3- *
4- * Built with unplugin to support:
5- * - Vite
6- * - Webpack
7- *
8- * Provides:
9- * 1. Dev server with translation server for on-demand translation generation
10- * 2. Babel transformation of JSX
11- */
121import { createUnplugin } from "unplugin" ;
132import { transformComponent } from "./transform" ;
143import type {
@@ -59,6 +48,8 @@ function tryLocalOrReturnVirtual(
5948/**
6049 * Single source of truth for virtual modules
6150 * Each entry defines both resolver (import path → virtual ID) and loader (virtual ID → code)
51+ *
52+ * If customFileCheck is defined, the specified file will be first searched for, and if not found virtual module will be used.
6253 */
6354const virtualModules = {
6455 "@lingo.dev/compiler/dev-config" : {
@@ -69,13 +60,11 @@ const virtualModules = {
6960 "@lingo.dev/compiler/locale/server" : {
7061 virtualId : "\0virtual:locale-resolver.server" as const ,
7162 loader : ( config : LingoConfig ) => generateServerLocaleModule ( config ) ,
72- // Custom file resolver - allows user overrides
7363 customFileCheck : "locale-resolver.server.ts" as const ,
7464 } ,
7565 "@lingo.dev/compiler/locale/client" : {
7666 virtualId : "\0virtual:locale-resolver.client" as const ,
7767 loader : ( config : LingoConfig ) => generateClientLocaleModule ( config ) ,
78- // Custom file resolver - allows user overrides
7968 customFileCheck : "locale-resolver.client.ts" as const ,
8069 } ,
8170} as const ;
@@ -101,7 +90,7 @@ const virtualModulesLoaders = Object.fromEntries(
10190
10291/**
10392 * Universal plugin for Lingo.dev compiler
104- * Supports Vite, Webpack, Rollup, and esbuild
93+ * Supports Vite, Webpack
10594 */
10695export const lingoUnplugin = createUnplugin <
10796 LingoPluginOptions & Partial < Pick < LingoConfig , LingoInternalFields > >
@@ -262,8 +251,7 @@ export const lingoUnplugin = createUnplugin<
262251 // This is more efficient than checking in the handler
263252 code : config . useDirective ? useI18nRegex : undefined ,
264253 } ,
265- handler : async ( code , id ) => {
266- // TODO (AleksandrSl 13/12/2025): It's weird we don't have any this.getOptions() here
254+ async handler ( code , id ) {
267255 try {
268256 // Transform the component
269257 const result = transformComponent ( {
@@ -272,8 +260,6 @@ export const lingoUnplugin = createUnplugin<
272260 config,
273261 } ) ;
274262
275- logger . debug ( `Transforming ${ result . code } ` ) ;
276-
277263 // If no transformation occurred, return original code
278264 if ( ! result . transformed ) {
279265 logger . debug ( `No transformation needed for ${ id } ` ) ;
@@ -283,17 +269,11 @@ export const lingoUnplugin = createUnplugin<
283269
284270 // Update metadata with new entries (thread-safe)
285271 if ( result . newEntries && result . newEntries . length > 0 ) {
286- logger . debug (
287- `Updating metadata with ${ result . newEntries . length } new entries` ,
288- ) ;
289-
290272 await metadataManager . saveMetadataWithEntries ( result . newEntries ) ;
291273
292- if ( isDev ) {
293- logger . info (
294- `Found ${ result . newEntries . length } translatable text(s) in ${ id } ` ,
295- ) ;
296- }
274+ logger . debug (
275+ `Found ${ result . newEntries . length } translatable text(s) in ${ id } ` ,
276+ ) ;
297277 }
298278
299279 logger . debug ( `Returning transformed code for ${ id } ` ) ;
0 commit comments