Skip to content

Commit ce4e6f9

Browse files
committed
WIP: try enabling webpack with next
1 parent c0e959a commit ce4e6f9

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

cmp/compiler/src/plugin/next.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export async function withLingo(
282282
translationServerUrl,
283283
...lingoConfig.dev,
284284
},
285+
isEmbeddedIntoNext: true,
285286
}),
286287
);
287288

cmp/compiler/src/plugin/unplugin.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
*/
1212
import { createUnplugin } from "unplugin";
1313
import { transformComponent } from "./transform";
14-
import type { PartialLingoConfig } from "../types";
14+
import type {
15+
LingoConfig,
16+
LingoInternalFields,
17+
PartialLingoConfig,
18+
} from "../types";
1519
import {
1620
startTranslationServer,
1721
type TranslationServer,
@@ -44,7 +48,9 @@ const PLUGIN_NAME = "lingo-compiler";
4448
* Universal plugin for Lingo.dev compiler
4549
* Supports Vite, Webpack, Rollup, and esbuild
4650
*/
47-
export const lingoUnplugin = createUnplugin<LingoPluginOptions>((options) => {
51+
export const lingoUnplugin = createUnplugin<
52+
LingoPluginOptions & Pick<LingoConfig, LingoInternalFields>
53+
>((options) => {
4854
const config = createLingoConfig(options);
4955

5056
// Won't work for webpack most likely. Use mode there to set correct environment in configs.
@@ -112,9 +118,9 @@ export const lingoUnplugin = createUnplugin<LingoPluginOptions>((options) => {
112118
},
113119

114120
webpack(compiler) {
115-
// if (config.isEmbeddedIntoNext) {
116-
// return;
117-
// }
121+
if (config.isEmbeddedIntoNext) {
122+
return;
123+
}
118124

119125
webpackMode =
120126
compiler.options.mode === "development" ? "development" : "production";

cmp/compiler/src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type LocalePersistenceConfig = { type: "cookie"; cookieName?: string };
3232
*/
3333
export type LingoConfigRequiredFields = "sourceLocale" | "targetLocales";
3434

35-
export type LingoInternalFields = "environment";
35+
export type LingoInternalFields = "environment" | "isEmbeddedIntoNext";
3636

3737
/**
3838
* Configuration for the Lingo compiler
@@ -198,6 +198,8 @@ export type LingoConfig = {
198198
* @default "translate"
199199
*/
200200
buildMode: "translate" | "cache-only";
201+
202+
isEmbeddedIntoNext: boolean;
201203
};
202204

203205
/**

0 commit comments

Comments
 (0)