-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
57 lines (48 loc) · 1.35 KB
/
next.config.ts
File metadata and controls
57 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
// Use Turbopack with experimental WASM support
turbopack: {},
// Enable WebAssembly support for tfhe.js FHE library (fallback for webpack)
webpack: (config, { isServer, webpack }) => {
// Enable async WebAssembly with proper layers
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
syncWebAssembly: true,
layers: true,
};
// Handle WASM files
config.module.rules.push({
test: /\.wasm$/,
type: "asset/resource",
});
// Ignore WASM module resolution errors
config.plugins.push(
new webpack.IgnorePlugin({
resourceRegExp: /^wbg$/,
})
);
// Exclude tfhe entirely from server-side bundling since WASM only works in browser
if (isServer) {
config.externals = [...(config.externals || []), "tfhe"];
} else {
// Client-side: resolve WASM imports properly
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
path: false,
crypto: false,
};
}
return config;
},
// Ensure tfhe is only loaded on the client side
serverExternalPackages: ["tfhe"],
// Enable experimental features for WASM
experimental: {
serverActions: {
bodySizeLimit: "10mb",
},
},
};
export default nextConfig;