Skip to content

Commit 70b16a5

Browse files
authored
Merge pull request #5 from lingodotdev/fix/internalize-optimize-deps-hack
fix: add optimize deps hach in the plugin
2 parents 85fea6d + 30c1a5a commit 70b16a5

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

cmp/compiler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"tsdown": "^0.16.5",
144144
"tsx": "^4.19.2",
145145
"typescript": "^5.9.3",
146-
"unplugin": "^2.3.10",
146+
"unplugin": "^2.3.11",
147147
"vitest": "^4.0.13"
148148
},
149149
"dependencies": {

cmp/compiler/src/plugin/unplugin.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ export const lingoUnplugin = createUnplugin<
136136
enforce: "pre", // Run before other plugins (especially before React plugin)
137137

138138
vite: {
139+
// Vite handles deep merge
140+
config() {
141+
// Required for custom virtual like modules to be resolved; otherwise they are bundled with raw source code.
142+
return {
143+
optimizeDeps: {
144+
exclude: ["@lingo.dev/compiler"],
145+
},
146+
};
147+
},
139148
async buildStart() {
140149
const metadataFilePath = getMetadataPath();
141150

cmp/compiler/tests/e2e/shared/development.test.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test.describe.serial("Development Mode", () => {
2323
let fixture: TestFixture;
2424
let devServer: DevServer;
2525

26-
test.beforeAll(async ({}, testInfo) => {
26+
test.beforeAll(async () => {
2727
fixture = await setupFixture({ framework: "next" });
2828
devServer = await fixture.startDev();
2929
});
@@ -85,14 +85,7 @@ test.describe.serial("Development Mode", () => {
8585
console.log("German heading:", germanHeading);
8686
expect(germanHeading).toBeTruthy();
8787

88-
// Log if translation system changed the text
89-
if (germanHeading !== heading) {
90-
console.log("✅ Translation changed the heading");
91-
} else {
92-
console.log(
93-
"⚠️ Heading unchanged (pseudo-translation may not modify all text)",
94-
);
95-
}
88+
expect.soft(germanHeading).not.toEqual(heading);
9689

9790
// Verify translation request was made (optional check)
9891
console.log("Translation requests:", translationRequests);
@@ -127,7 +120,7 @@ test.describe.serial("Development Mode", () => {
127120
let fixture: TestFixture;
128121
let devServer: DevServer;
129122

130-
test.beforeAll(async ({}) => {
123+
test.beforeAll(async () => {
131124
fixture = await setupFixture({ framework: "vite" });
132125
devServer = await fixture.startDev();
133126
});
@@ -171,11 +164,7 @@ test.describe.serial("Development Mode", () => {
171164
await expect(spanishHeading).toBeVisible();
172165
const spanishHeadingText = await spanishHeading.textContent();
173166

174-
if (spanishHeadingText !== initialHeadingText) {
175-
console.log("✅ Translation system changed the text");
176-
} else {
177-
console.log("⚠️ Text unchanged");
178-
}
167+
expect(spanishHeadingText).not.toEqual(initialHeadingText);
179168
});
180169

181170
test("should navigate between pages and persist locale", async ({
@@ -197,7 +186,6 @@ test.describe.serial("Development Mode", () => {
197186
// Verify locale persisted
198187
const currentLocale = await getCurrentLocale(page);
199188
expect(currentLocale).toBe(newLocale);
200-
console.log(`✅ Locale persisted across navigation to ${newLocale}`);
201189
});
202190
});
203191
});

cmp/demo/vite-react-spa/vite.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export default defineConfig({
2929
viteReact(),
3030
tailwindcss(),
3131
],
32-
optimizeDeps: {
33-
exclude: ["@lingo.dev/compiler"],
34-
},
3532
resolve: {
3633
alias: {
3734
"@": fileURLToPath(new URL("./src", import.meta.url)),

cmp/pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)