Weather Station / ECOWITT / DNT
1// Note: avoid strict typing here so we can use keys supported by the current Next version
2const nextConfig = {
3 // Turbopack configuration (Next.js 16+)
4 // Empty config to acknowledge Turbopack usage and silence migration warning
5 turbopack: {},
6
7 // Ensure native DuckDB modules are treated as externals in the server runtime
8 // Note: experimental.serverComponentsExternalPackages was moved in Next.js
9 // Use serverExternalPackages instead (see below).
10 // For runtimes that honor this key (Next 14/15), also externalize at the server layer
11 // If unsupported, Next will ignore it harmlessly
12 serverExternalPackages: [
13 "@duckdb/node-api",
14 "@duckdb/node-bindings",
15 ],
16 // Fallback for Webpack-based builds (non-Turbopack): mark these as commonjs externals
17 webpack: (config: any, { isServer }: { isServer: boolean }) => {
18 if (isServer) {
19 const externals = config.externals || [];
20 // Externalize Node.js built-ins for server-only modules
21 externals.push({
22 "fs": "commonjs fs",
23 "fs/promises": "commonjs fs/promises",
24 "path": "commonjs path",
25 "@duckdb/node-api": "commonjs @duckdb/node-api",
26 "@duckdb/node-bindings": "commonjs @duckdb/node-bindings",
27 });
28 // Externalize platform-specific native bindings e.g. @duckdb/node-bindings-linux-x64/duckdb.node
29 externals.push((
30 { request }: { request?: string },
31 callback: (err?: any, result?: string) => void
32 ) => {
33 if (request && /^@duckdb\/node-bindings-[^/]+\/duckdb\.node$/.test(request)) {
34 return callback(null, `commonjs ${request}`);
35 }
36 callback();
37 });
38 config.externals = externals;
39 }
40 return config;
41 },
42};
43
44export default nextConfig;