@lingo.dev/_compiler 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{chunk-6W6K5RIW.cjs → chunk-3KRFP2F6.cjs} +6 -2
- package/build/{chunk-2HDSJRXT.mjs → chunk-QPJQYXXH.mjs} +6 -2
- package/build/index.cjs +93 -25
- package/build/index.d.cts +67 -0
- package/build/index.d.ts +67 -0
- package/build/index.mjs +72 -4
- package/build/lingo-turbopack-loader.cjs +3 -3
- package/build/lingo-turbopack-loader.mjs +1 -1
- package/package.json +6 -5
|
@@ -462,8 +462,12 @@ function findExistingImport(ast, exportedName, moduleName) {
|
|
|
462
462
|
if (!moduleName.includes(path7.node.source.value)) {
|
|
463
463
|
return;
|
|
464
464
|
}
|
|
465
|
+
if (path7.node.importKind === "type") {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
465
468
|
for (const specifier of path7.node.specifiers) {
|
|
466
|
-
if (t2.isImportSpecifier(specifier) &&
|
|
469
|
+
if (t2.isImportSpecifier(specifier) && // Skip type-only specifiers as they can't be used at runtime
|
|
470
|
+
specifier.importKind !== "type" && (t2.isIdentifier(specifier.imported) && specifier.imported.name === exportedName || specifier.importKind === "value" && t2.isIdentifier(specifier.local) && specifier.local.name === exportedName)) {
|
|
467
471
|
result = specifier.local.name;
|
|
468
472
|
path7.stop();
|
|
469
473
|
return;
|
|
@@ -499,7 +503,7 @@ function createImportDeclaration(ast, localName, exportedName, moduleName) {
|
|
|
499
503
|
t2.identifier(exportedName)
|
|
500
504
|
);
|
|
501
505
|
const existingImport = path7.get("body").find(
|
|
502
|
-
(nodePath) => t2.isImportDeclaration(nodePath.node) && moduleName.includes(nodePath.node.source.value)
|
|
506
|
+
(nodePath) => t2.isImportDeclaration(nodePath.node) && moduleName.includes(nodePath.node.source.value) && nodePath.node.importKind !== "type"
|
|
503
507
|
);
|
|
504
508
|
if (existingImport && t2.isImportDeclaration(existingImport.node)) {
|
|
505
509
|
existingImport.node.specifiers.push(importSpecifier2);
|
|
@@ -462,8 +462,12 @@ function findExistingImport(ast, exportedName, moduleName) {
|
|
|
462
462
|
if (!moduleName.includes(path7.node.source.value)) {
|
|
463
463
|
return;
|
|
464
464
|
}
|
|
465
|
+
if (path7.node.importKind === "type") {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
465
468
|
for (const specifier of path7.node.specifiers) {
|
|
466
|
-
if (t2.isImportSpecifier(specifier) &&
|
|
469
|
+
if (t2.isImportSpecifier(specifier) && // Skip type-only specifiers as they can't be used at runtime
|
|
470
|
+
specifier.importKind !== "type" && (t2.isIdentifier(specifier.imported) && specifier.imported.name === exportedName || specifier.importKind === "value" && t2.isIdentifier(specifier.local) && specifier.local.name === exportedName)) {
|
|
467
471
|
result = specifier.local.name;
|
|
468
472
|
path7.stop();
|
|
469
473
|
return;
|
|
@@ -499,7 +503,7 @@ function createImportDeclaration(ast, localName, exportedName, moduleName) {
|
|
|
499
503
|
t2.identifier(exportedName)
|
|
500
504
|
);
|
|
501
505
|
const existingImport = path7.get("body").find(
|
|
502
|
-
(nodePath) => t2.isImportDeclaration(nodePath.node) && moduleName.includes(nodePath.node.source.value)
|
|
506
|
+
(nodePath) => t2.isImportDeclaration(nodePath.node) && moduleName.includes(nodePath.node.source.value) && nodePath.node.importKind !== "type"
|
|
503
507
|
);
|
|
504
508
|
if (existingImport && t2.isImportDeclaration(existingImport.node)) {
|
|
505
509
|
existingImport.node.specifiers.push(importSpecifier2);
|
package/build/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunk3KRFP2F6cjs = require('./chunk-3KRFP2F6.cjs');
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
var _unplugin = require('unplugin');
|
|
@@ -25,7 +25,7 @@ var _unplugin = require('unplugin');
|
|
|
25
25
|
// package.json
|
|
26
26
|
var package_default = {
|
|
27
27
|
name: "@lingo.dev/_compiler",
|
|
28
|
-
version: "0.7.
|
|
28
|
+
version: "0.7.2",
|
|
29
29
|
description: "Lingo.dev Compiler",
|
|
30
30
|
private: false,
|
|
31
31
|
publishConfig: {
|
|
@@ -41,7 +41,8 @@ var package_default = {
|
|
|
41
41
|
],
|
|
42
42
|
scripts: {
|
|
43
43
|
dev: "tsup --watch",
|
|
44
|
-
build: "
|
|
44
|
+
build: "pnpm typecheck && tsup",
|
|
45
|
+
typecheck: "tsc --noEmit",
|
|
45
46
|
clean: "rm -rf build",
|
|
46
47
|
test: "vitest --run",
|
|
47
48
|
"test:watch": "vitest -w"
|
|
@@ -84,7 +85,7 @@ var package_default = {
|
|
|
84
85
|
unplugin: "^2.1.2",
|
|
85
86
|
vitest: "^2.1.4",
|
|
86
87
|
zod: "^3.25.76",
|
|
87
|
-
"posthog-node": "^
|
|
88
|
+
"posthog-node": "^5.5.1",
|
|
88
89
|
"node-machine-id": "^1.1.12"
|
|
89
90
|
},
|
|
90
91
|
packageManager: "pnpm@9.12.3"
|
|
@@ -131,7 +132,7 @@ async function trackEvent(event, properties) {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
async function getActualId() {
|
|
134
|
-
const rc =
|
|
135
|
+
const rc = _chunk3KRFP2F6cjs.getRc.call(void 0, );
|
|
135
136
|
const apiKey = process.env.LINGODOTDEV_API_KEY || _optionalChain([rc, 'optionalAccess', _3 => _3.auth, 'optionalAccess', _4 => _4.apiKey]);
|
|
136
137
|
const apiUrl = process.env.LINGODOTDEV_API_URL || _optionalChain([rc, 'optionalAccess', _5 => _5.auth, 'optionalAccess', _6 => _6.apiUrl]) || "https://engine.lingo.dev";
|
|
137
138
|
if (apiKey) {
|
|
@@ -159,20 +160,20 @@ async function getActualId() {
|
|
|
159
160
|
// src/index.ts
|
|
160
161
|
var keyCheckers = {
|
|
161
162
|
groq: {
|
|
162
|
-
checkEnv:
|
|
163
|
-
checkRc:
|
|
163
|
+
checkEnv: _chunk3KRFP2F6cjs.getGroqKeyFromEnv,
|
|
164
|
+
checkRc: _chunk3KRFP2F6cjs.getGroqKeyFromRc
|
|
164
165
|
},
|
|
165
166
|
google: {
|
|
166
|
-
checkEnv:
|
|
167
|
-
checkRc:
|
|
167
|
+
checkEnv: _chunk3KRFP2F6cjs.getGoogleKeyFromEnv,
|
|
168
|
+
checkRc: _chunk3KRFP2F6cjs.getGoogleKeyFromRc
|
|
168
169
|
},
|
|
169
170
|
mistral: {
|
|
170
|
-
checkEnv:
|
|
171
|
-
checkRc:
|
|
171
|
+
checkEnv: _chunk3KRFP2F6cjs.getMistralKeyFromEnv,
|
|
172
|
+
checkRc: _chunk3KRFP2F6cjs.getMistralKeyFromRc
|
|
172
173
|
},
|
|
173
174
|
"lingo.dev": {
|
|
174
|
-
checkEnv:
|
|
175
|
-
checkRc:
|
|
175
|
+
checkEnv: _chunk3KRFP2F6cjs.getLingoDotDevKeyFromEnv,
|
|
176
|
+
checkRc: _chunk3KRFP2F6cjs.getLingoDotDevKeyFromRc
|
|
176
177
|
}
|
|
177
178
|
};
|
|
178
179
|
var alreadySentBuildEvent = { value: false };
|
|
@@ -188,14 +189,14 @@ function sendBuildEvent(framework, config, isDev) {
|
|
|
188
189
|
var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
189
190
|
(_params, _meta) => {
|
|
190
191
|
console.log("\u2139\uFE0F Starting Lingo.dev compiler...");
|
|
191
|
-
const params = _lodash2.default.defaults(_params,
|
|
192
|
-
if (!
|
|
192
|
+
const params = _lodash2.default.defaults(_params, _chunk3KRFP2F6cjs.defaultParams);
|
|
193
|
+
if (!_chunk3KRFP2F6cjs.isRunningInCIOrDocker.call(void 0, )) {
|
|
193
194
|
if (params.models === "lingo.dev") {
|
|
194
195
|
validateLLMKeyDetails(["lingo.dev"]);
|
|
195
196
|
} else {
|
|
196
197
|
const configuredProviders = getConfiguredProviders(params.models);
|
|
197
198
|
validateLLMKeyDetails(configuredProviders);
|
|
198
|
-
const invalidLocales =
|
|
199
|
+
const invalidLocales = _chunk3KRFP2F6cjs.getInvalidLocales.call(void 0,
|
|
199
200
|
params.models,
|
|
200
201
|
params.sourceLocale,
|
|
201
202
|
params.targetLocales
|
|
@@ -218,7 +219,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
|
-
|
|
222
|
+
_chunk3KRFP2F6cjs.LCPCache.ensureDictionaryFile({
|
|
222
223
|
sourceRoot: params.sourceRoot,
|
|
223
224
|
lingoDir: params.lingoDir
|
|
224
225
|
});
|
|
@@ -226,9 +227,9 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
226
227
|
sendBuildEvent("unplugin", params, isDev);
|
|
227
228
|
return {
|
|
228
229
|
name: package_default.name,
|
|
229
|
-
loadInclude: (id) => !!id.match(
|
|
230
|
+
loadInclude: (id) => !!id.match(_chunk3KRFP2F6cjs.LCP_DICTIONARY_FILE_NAME),
|
|
230
231
|
async load(id) {
|
|
231
|
-
const dictionary = await
|
|
232
|
+
const dictionary = await _chunk3KRFP2F6cjs.loadDictionary.call(void 0, {
|
|
232
233
|
resourcePath: id,
|
|
233
234
|
resourceQuery: "",
|
|
234
235
|
params: {
|
|
@@ -252,7 +253,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
252
253
|
enforce: "pre",
|
|
253
254
|
transform(code, id) {
|
|
254
255
|
try {
|
|
255
|
-
const result =
|
|
256
|
+
const result = _chunk3KRFP2F6cjs.transformComponent.call(void 0, {
|
|
256
257
|
code,
|
|
257
258
|
params,
|
|
258
259
|
resourcePath: id,
|
|
@@ -269,10 +270,32 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
269
270
|
}
|
|
270
271
|
);
|
|
271
272
|
var src_default = {
|
|
273
|
+
/**
|
|
274
|
+
* Initializes Lingo.dev Compiler for Next.js (App Router).
|
|
275
|
+
*
|
|
276
|
+
* @param compilerParams - The compiler parameters.
|
|
277
|
+
*
|
|
278
|
+
* @returns The Next.js configuration.
|
|
279
|
+
*
|
|
280
|
+
* @example Configuration for Next.js's default template
|
|
281
|
+
* ```ts
|
|
282
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
283
|
+
* import type { NextConfig } from "next";
|
|
284
|
+
*
|
|
285
|
+
* const nextConfig: NextConfig = {
|
|
286
|
+
* /* config options here *\/
|
|
287
|
+
* };
|
|
288
|
+
*
|
|
289
|
+
* export default lingoCompiler.next({
|
|
290
|
+
* sourceRoot: "app",
|
|
291
|
+
* models: "lingo.dev",
|
|
292
|
+
* })(nextConfig);
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
272
295
|
next: (compilerParams) => (nextConfig = {}) => {
|
|
273
296
|
const mergedParams = _lodash2.default.merge(
|
|
274
297
|
{},
|
|
275
|
-
|
|
298
|
+
_chunk3KRFP2F6cjs.defaultParams,
|
|
276
299
|
{
|
|
277
300
|
rsc: true,
|
|
278
301
|
turbopack: {
|
|
@@ -323,7 +346,7 @@ var src_default = {
|
|
|
323
346
|
turbopackConfigPath.rules ??= {};
|
|
324
347
|
const rules = turbopackConfigPath.rules;
|
|
325
348
|
const lingoGlob = `**/*.{ts,tsx,js,jsx}`;
|
|
326
|
-
const lingoLoaderPath =
|
|
349
|
+
const lingoLoaderPath = _chunk3KRFP2F6cjs.__require.resolve("./lingo-turbopack-loader");
|
|
327
350
|
rules[lingoGlob] = {
|
|
328
351
|
loaders: [
|
|
329
352
|
{
|
|
@@ -335,10 +358,55 @@ var src_default = {
|
|
|
335
358
|
}
|
|
336
359
|
return nextConfig;
|
|
337
360
|
},
|
|
361
|
+
/**
|
|
362
|
+
* Initializes Lingo.dev Compiler for Vite.
|
|
363
|
+
*
|
|
364
|
+
* @param compilerParams - The compiler parameters.
|
|
365
|
+
*
|
|
366
|
+
* @returns The Vite configuration.
|
|
367
|
+
*
|
|
368
|
+
* @example Configuration for Vite's "react-ts" template
|
|
369
|
+
* ```ts
|
|
370
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
371
|
+
* import react from "@vitejs/plugin-react";
|
|
372
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
373
|
+
*
|
|
374
|
+
* // https://vite.dev/config/
|
|
375
|
+
* const viteConfig: UserConfig = {
|
|
376
|
+
* plugins: [react()],
|
|
377
|
+
* };
|
|
378
|
+
*
|
|
379
|
+
* export default defineConfig(() =>
|
|
380
|
+
* lingoCompiler.vite({
|
|
381
|
+
* models: "lingo.dev",
|
|
382
|
+
* })(viteConfig)
|
|
383
|
+
* );
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @example Configuration for React Router's default template
|
|
387
|
+
* ```ts
|
|
388
|
+
* import { reactRouter } from "@react-router/dev/vite";
|
|
389
|
+
* import tailwindcss from "@tailwindcss/vite";
|
|
390
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
391
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
392
|
+
* import tsconfigPaths from "vite-tsconfig-paths";
|
|
393
|
+
*
|
|
394
|
+
* const viteConfig: UserConfig = {
|
|
395
|
+
* plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
396
|
+
* };
|
|
397
|
+
*
|
|
398
|
+
* export default defineConfig(() =>
|
|
399
|
+
* lingoCompiler.vite({
|
|
400
|
+
* sourceRoot: "app",
|
|
401
|
+
* models: "lingo.dev",
|
|
402
|
+
* })(viteConfig)
|
|
403
|
+
* );
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
338
406
|
vite: (compilerParams) => (config) => {
|
|
339
407
|
const mergedParams = _lodash2.default.merge(
|
|
340
408
|
{},
|
|
341
|
-
|
|
409
|
+
_chunk3KRFP2F6cjs.defaultParams,
|
|
342
410
|
{ rsc: false },
|
|
343
411
|
compilerParams
|
|
344
412
|
);
|
|
@@ -352,7 +420,7 @@ var src_default = {
|
|
|
352
420
|
};
|
|
353
421
|
function getConfiguredProviders(models) {
|
|
354
422
|
return _lodash2.default.chain(Object.values(models)).map((modelString) => modelString.split(":")[0]).filter(Boolean).uniq().filter(
|
|
355
|
-
(providerId) =>
|
|
423
|
+
(providerId) => _chunk3KRFP2F6cjs.providerDetails.hasOwnProperty(providerId) && keyCheckers.hasOwnProperty(providerId)
|
|
356
424
|
).value();
|
|
357
425
|
}
|
|
358
426
|
function validateLLMKeyDetails(configuredProviders) {
|
|
@@ -363,7 +431,7 @@ function validateLLMKeyDetails(configuredProviders) {
|
|
|
363
431
|
const missingProviders = [];
|
|
364
432
|
const foundProviders = [];
|
|
365
433
|
for (const providerId of configuredProviders) {
|
|
366
|
-
const details =
|
|
434
|
+
const details = _chunk3KRFP2F6cjs.providerDetails[providerId];
|
|
367
435
|
const checkers = keyCheckers[providerId];
|
|
368
436
|
if (!details || !checkers) continue;
|
|
369
437
|
const foundInEnv = !!checkers.checkEnv();
|
package/build/index.d.cts
CHANGED
|
@@ -125,12 +125,79 @@ type ModelIdentifier = `${string}:${string}`;
|
|
|
125
125
|
declare const defaultParams: CompilerParams;
|
|
126
126
|
|
|
127
127
|
declare const _default: {
|
|
128
|
+
/**
|
|
129
|
+
* Initializes Lingo.dev Compiler for Next.js (App Router).
|
|
130
|
+
*
|
|
131
|
+
* @param compilerParams - The compiler parameters.
|
|
132
|
+
*
|
|
133
|
+
* @returns The Next.js configuration.
|
|
134
|
+
*
|
|
135
|
+
* @example Configuration for Next.js's default template
|
|
136
|
+
* ```ts
|
|
137
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
138
|
+
* import type { NextConfig } from "next";
|
|
139
|
+
*
|
|
140
|
+
* const nextConfig: NextConfig = {
|
|
141
|
+
* /* config options here *\/
|
|
142
|
+
* };
|
|
143
|
+
*
|
|
144
|
+
* export default lingoCompiler.next({
|
|
145
|
+
* sourceRoot: "app",
|
|
146
|
+
* models: "lingo.dev",
|
|
147
|
+
* })(nextConfig);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
128
150
|
next: (compilerParams?: Partial<typeof defaultParams> & {
|
|
129
151
|
turbopack?: {
|
|
130
152
|
enabled?: boolean | "auto";
|
|
131
153
|
useLegacyTurbo?: boolean;
|
|
132
154
|
};
|
|
133
155
|
}) => (nextConfig?: any) => NextConfig;
|
|
156
|
+
/**
|
|
157
|
+
* Initializes Lingo.dev Compiler for Vite.
|
|
158
|
+
*
|
|
159
|
+
* @param compilerParams - The compiler parameters.
|
|
160
|
+
*
|
|
161
|
+
* @returns The Vite configuration.
|
|
162
|
+
*
|
|
163
|
+
* @example Configuration for Vite's "react-ts" template
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
166
|
+
* import react from "@vitejs/plugin-react";
|
|
167
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
168
|
+
*
|
|
169
|
+
* // https://vite.dev/config/
|
|
170
|
+
* const viteConfig: UserConfig = {
|
|
171
|
+
* plugins: [react()],
|
|
172
|
+
* };
|
|
173
|
+
*
|
|
174
|
+
* export default defineConfig(() =>
|
|
175
|
+
* lingoCompiler.vite({
|
|
176
|
+
* models: "lingo.dev",
|
|
177
|
+
* })(viteConfig)
|
|
178
|
+
* );
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Configuration for React Router's default template
|
|
182
|
+
* ```ts
|
|
183
|
+
* import { reactRouter } from "@react-router/dev/vite";
|
|
184
|
+
* import tailwindcss from "@tailwindcss/vite";
|
|
185
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
186
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
187
|
+
* import tsconfigPaths from "vite-tsconfig-paths";
|
|
188
|
+
*
|
|
189
|
+
* const viteConfig: UserConfig = {
|
|
190
|
+
* plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
191
|
+
* };
|
|
192
|
+
*
|
|
193
|
+
* export default defineConfig(() =>
|
|
194
|
+
* lingoCompiler.vite({
|
|
195
|
+
* sourceRoot: "app",
|
|
196
|
+
* models: "lingo.dev",
|
|
197
|
+
* })(viteConfig)
|
|
198
|
+
* );
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
134
201
|
vite: (compilerParams?: Partial<typeof defaultParams>) => (config: any) => any;
|
|
135
202
|
};
|
|
136
203
|
|
package/build/index.d.ts
CHANGED
|
@@ -125,12 +125,79 @@ type ModelIdentifier = `${string}:${string}`;
|
|
|
125
125
|
declare const defaultParams: CompilerParams;
|
|
126
126
|
|
|
127
127
|
declare const _default: {
|
|
128
|
+
/**
|
|
129
|
+
* Initializes Lingo.dev Compiler for Next.js (App Router).
|
|
130
|
+
*
|
|
131
|
+
* @param compilerParams - The compiler parameters.
|
|
132
|
+
*
|
|
133
|
+
* @returns The Next.js configuration.
|
|
134
|
+
*
|
|
135
|
+
* @example Configuration for Next.js's default template
|
|
136
|
+
* ```ts
|
|
137
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
138
|
+
* import type { NextConfig } from "next";
|
|
139
|
+
*
|
|
140
|
+
* const nextConfig: NextConfig = {
|
|
141
|
+
* /* config options here *\/
|
|
142
|
+
* };
|
|
143
|
+
*
|
|
144
|
+
* export default lingoCompiler.next({
|
|
145
|
+
* sourceRoot: "app",
|
|
146
|
+
* models: "lingo.dev",
|
|
147
|
+
* })(nextConfig);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
128
150
|
next: (compilerParams?: Partial<typeof defaultParams> & {
|
|
129
151
|
turbopack?: {
|
|
130
152
|
enabled?: boolean | "auto";
|
|
131
153
|
useLegacyTurbo?: boolean;
|
|
132
154
|
};
|
|
133
155
|
}) => (nextConfig?: any) => NextConfig;
|
|
156
|
+
/**
|
|
157
|
+
* Initializes Lingo.dev Compiler for Vite.
|
|
158
|
+
*
|
|
159
|
+
* @param compilerParams - The compiler parameters.
|
|
160
|
+
*
|
|
161
|
+
* @returns The Vite configuration.
|
|
162
|
+
*
|
|
163
|
+
* @example Configuration for Vite's "react-ts" template
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
166
|
+
* import react from "@vitejs/plugin-react";
|
|
167
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
168
|
+
*
|
|
169
|
+
* // https://vite.dev/config/
|
|
170
|
+
* const viteConfig: UserConfig = {
|
|
171
|
+
* plugins: [react()],
|
|
172
|
+
* };
|
|
173
|
+
*
|
|
174
|
+
* export default defineConfig(() =>
|
|
175
|
+
* lingoCompiler.vite({
|
|
176
|
+
* models: "lingo.dev",
|
|
177
|
+
* })(viteConfig)
|
|
178
|
+
* );
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* @example Configuration for React Router's default template
|
|
182
|
+
* ```ts
|
|
183
|
+
* import { reactRouter } from "@react-router/dev/vite";
|
|
184
|
+
* import tailwindcss from "@tailwindcss/vite";
|
|
185
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
186
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
187
|
+
* import tsconfigPaths from "vite-tsconfig-paths";
|
|
188
|
+
*
|
|
189
|
+
* const viteConfig: UserConfig = {
|
|
190
|
+
* plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
191
|
+
* };
|
|
192
|
+
*
|
|
193
|
+
* export default defineConfig(() =>
|
|
194
|
+
* lingoCompiler.vite({
|
|
195
|
+
* sourceRoot: "app",
|
|
196
|
+
* models: "lingo.dev",
|
|
197
|
+
* })(viteConfig)
|
|
198
|
+
* );
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
134
201
|
vite: (compilerParams?: Partial<typeof defaultParams>) => (config: any) => any;
|
|
135
202
|
};
|
|
136
203
|
|
package/build/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
loadDictionary,
|
|
18
18
|
providerDetails,
|
|
19
19
|
transformComponent
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-QPJQYXXH.mjs";
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
import { createUnplugin } from "unplugin";
|
|
@@ -25,7 +25,7 @@ import { createUnplugin } from "unplugin";
|
|
|
25
25
|
// package.json
|
|
26
26
|
var package_default = {
|
|
27
27
|
name: "@lingo.dev/_compiler",
|
|
28
|
-
version: "0.7.
|
|
28
|
+
version: "0.7.2",
|
|
29
29
|
description: "Lingo.dev Compiler",
|
|
30
30
|
private: false,
|
|
31
31
|
publishConfig: {
|
|
@@ -41,7 +41,8 @@ var package_default = {
|
|
|
41
41
|
],
|
|
42
42
|
scripts: {
|
|
43
43
|
dev: "tsup --watch",
|
|
44
|
-
build: "
|
|
44
|
+
build: "pnpm typecheck && tsup",
|
|
45
|
+
typecheck: "tsc --noEmit",
|
|
45
46
|
clean: "rm -rf build",
|
|
46
47
|
test: "vitest --run",
|
|
47
48
|
"test:watch": "vitest -w"
|
|
@@ -84,7 +85,7 @@ var package_default = {
|
|
|
84
85
|
unplugin: "^2.1.2",
|
|
85
86
|
vitest: "^2.1.4",
|
|
86
87
|
zod: "^3.25.76",
|
|
87
|
-
"posthog-node": "^
|
|
88
|
+
"posthog-node": "^5.5.1",
|
|
88
89
|
"node-machine-id": "^1.1.12"
|
|
89
90
|
},
|
|
90
91
|
packageManager: "pnpm@9.12.3"
|
|
@@ -269,6 +270,28 @@ var unplugin = createUnplugin(
|
|
|
269
270
|
}
|
|
270
271
|
);
|
|
271
272
|
var src_default = {
|
|
273
|
+
/**
|
|
274
|
+
* Initializes Lingo.dev Compiler for Next.js (App Router).
|
|
275
|
+
*
|
|
276
|
+
* @param compilerParams - The compiler parameters.
|
|
277
|
+
*
|
|
278
|
+
* @returns The Next.js configuration.
|
|
279
|
+
*
|
|
280
|
+
* @example Configuration for Next.js's default template
|
|
281
|
+
* ```ts
|
|
282
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
283
|
+
* import type { NextConfig } from "next";
|
|
284
|
+
*
|
|
285
|
+
* const nextConfig: NextConfig = {
|
|
286
|
+
* /* config options here *\/
|
|
287
|
+
* };
|
|
288
|
+
*
|
|
289
|
+
* export default lingoCompiler.next({
|
|
290
|
+
* sourceRoot: "app",
|
|
291
|
+
* models: "lingo.dev",
|
|
292
|
+
* })(nextConfig);
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
272
295
|
next: (compilerParams) => (nextConfig = {}) => {
|
|
273
296
|
const mergedParams = _.merge(
|
|
274
297
|
{},
|
|
@@ -335,6 +358,51 @@ var src_default = {
|
|
|
335
358
|
}
|
|
336
359
|
return nextConfig;
|
|
337
360
|
},
|
|
361
|
+
/**
|
|
362
|
+
* Initializes Lingo.dev Compiler for Vite.
|
|
363
|
+
*
|
|
364
|
+
* @param compilerParams - The compiler parameters.
|
|
365
|
+
*
|
|
366
|
+
* @returns The Vite configuration.
|
|
367
|
+
*
|
|
368
|
+
* @example Configuration for Vite's "react-ts" template
|
|
369
|
+
* ```ts
|
|
370
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
371
|
+
* import react from "@vitejs/plugin-react";
|
|
372
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
373
|
+
*
|
|
374
|
+
* // https://vite.dev/config/
|
|
375
|
+
* const viteConfig: UserConfig = {
|
|
376
|
+
* plugins: [react()],
|
|
377
|
+
* };
|
|
378
|
+
*
|
|
379
|
+
* export default defineConfig(() =>
|
|
380
|
+
* lingoCompiler.vite({
|
|
381
|
+
* models: "lingo.dev",
|
|
382
|
+
* })(viteConfig)
|
|
383
|
+
* );
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @example Configuration for React Router's default template
|
|
387
|
+
* ```ts
|
|
388
|
+
* import { reactRouter } from "@react-router/dev/vite";
|
|
389
|
+
* import tailwindcss from "@tailwindcss/vite";
|
|
390
|
+
* import lingoCompiler from "lingo.dev/compiler";
|
|
391
|
+
* import { defineConfig, type UserConfig } from "vite";
|
|
392
|
+
* import tsconfigPaths from "vite-tsconfig-paths";
|
|
393
|
+
*
|
|
394
|
+
* const viteConfig: UserConfig = {
|
|
395
|
+
* plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
396
|
+
* };
|
|
397
|
+
*
|
|
398
|
+
* export default defineConfig(() =>
|
|
399
|
+
* lingoCompiler.vite({
|
|
400
|
+
* sourceRoot: "app",
|
|
401
|
+
* models: "lingo.dev",
|
|
402
|
+
* })(viteConfig)
|
|
403
|
+
* );
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
338
406
|
vite: (compilerParams) => (config) => {
|
|
339
407
|
const mergedParams = _.merge(
|
|
340
408
|
{},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk3KRFP2F6cjs = require('./chunk-3KRFP2F6.cjs');
|
|
5
5
|
|
|
6
6
|
// src/lingo-turbopack-loader.ts
|
|
7
7
|
async function lingo_turbopack_loader_default(source) {
|
|
@@ -9,7 +9,7 @@ async function lingo_turbopack_loader_default(source) {
|
|
|
9
9
|
const params = this.getOptions();
|
|
10
10
|
const isDev = process.env.NODE_ENV !== "production";
|
|
11
11
|
try {
|
|
12
|
-
const dictionary = await
|
|
12
|
+
const dictionary = await _chunk3KRFP2F6cjs.loadDictionary.call(void 0, {
|
|
13
13
|
resourcePath: this.resourcePath,
|
|
14
14
|
resourceQuery: this.resourceQuery,
|
|
15
15
|
params,
|
|
@@ -21,7 +21,7 @@ async function lingo_turbopack_loader_default(source) {
|
|
|
21
21
|
const code = `export default ${JSON.stringify(dictionary, null, 2)};`;
|
|
22
22
|
return callback(null, code);
|
|
23
23
|
}
|
|
24
|
-
const result =
|
|
24
|
+
const result = _chunk3KRFP2F6cjs.transformComponent.call(void 0, {
|
|
25
25
|
code: source,
|
|
26
26
|
params,
|
|
27
27
|
resourcePath: this.resourcePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingo.dev/_compiler",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Lingo.dev Compiler",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -50,14 +50,15 @@
|
|
|
50
50
|
"unplugin": "^2.1.2",
|
|
51
51
|
"vitest": "^2.1.4",
|
|
52
52
|
"zod": "^3.25.76",
|
|
53
|
-
"posthog-node": "^
|
|
53
|
+
"posthog-node": "^5.5.1",
|
|
54
54
|
"node-machine-id": "^1.1.12",
|
|
55
|
-
"@lingo.dev/
|
|
56
|
-
"@lingo.dev/
|
|
55
|
+
"@lingo.dev/_spec": "0.39.3",
|
|
56
|
+
"@lingo.dev/_sdk": "0.11.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"dev": "tsup --watch",
|
|
60
|
-
"build": "
|
|
60
|
+
"build": "pnpm typecheck && tsup",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
61
62
|
"clean": "rm -rf build",
|
|
62
63
|
"test": "vitest --run",
|
|
63
64
|
"test:watch": "vitest -w"
|