Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-groups-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lingo.dev/_compiler": patch
---

Fix Next.js 16 compatibility by handling string nextConfig parameters to prevent TypeError during webpack property assignment
16 changes: 16 additions & 0 deletions packages/compiler/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@ describe("compiler integration", () => {
expect(out.plugins[0]).toBeDefined();
});
});

it("next() handles string nextConfig (Next.js 16 compatibility)", () => {
// Test the problematic case from Next.js 16 where nextConfig is a string
const stringConfig = 'phase-production-build' as any;

const result = compiler.next({
sourceRoot: "src",
models: "lingo.dev",
turbopack: { enabled: false },
})(stringConfig);

// Should not throw an error and should return a valid NextConfig object
expect(typeof result).toBe("object");
expect(typeof result.webpack).toBe("function");
});

3 changes: 3 additions & 0 deletions packages/compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export default {
},
) =>
(nextConfig: any = {}): NextConfig => {
if (typeof nextConfig !== 'object' || nextConfig === null) {
nextConfig = {};
}
const mergedParams = _.merge(
{},
defaultParams,
Expand Down