Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
62 lines (58 loc) · 2.41 KB
/
Copy pathnext.config.ts
File metadata and controls
62 lines (58 loc) · 2.41 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
58
59
60
61
62
import type { NextConfig } from "next";
/**
* satellite.js v7 (used by lib/iss for SGP4 on the ISS tab) re-exports an
* emscripten WASM runtime whose Node execution path statically imports
* `node:module` / `node:worker_threads`. The browser only uses satellite.js's
* pure-JS SGP4 (propagate / gstime / transforms); those WASM runtimes are
* re-exported but reached only through a dynamic import that never runs in the
* browser. Bundlers still try to resolve them and fail on the `node:` scheme, so
* for the CLIENT bundle only we stub them out.
*
* Both bundlers need telling, because Next 16 uses Turbopack for `next dev` and
* webpack only when `next build --webpack` is passed (see package.json).
*/
const nextConfig: NextConfig = {
// No secrets, no rewrites, no experiments. The app is a static-ish shell +
// one cache/proxy route handler (/api/gibs/[layer]) — see
// .claude/skills/vercel-compute-architecture for the compute decision.
reactStrictMode: true,
// Turbopack (default for `next dev` on Next 16): alias the Node builtins to an
// empty module for the browser. This is Turbopack's equivalent of webpack's
// `resolve.fallback: false`.
turbopack: {
resolveAlias: {
"node:module": { browser: "./lib/empty-module.ts" },
"node:worker_threads": { browser: "./lib/empty-module.ts" },
module: { browser: "./lib/empty-module.ts" },
worker_threads: { browser: "./lib/empty-module.ts" },
},
},
// Webpack (used for production builds via `next build --webpack`). Keeping the
// original, proven workaround: rewrite the `node:` scheme away and stub the
// bare builtins, then silence the top-level-await warnings from those same
// never-executed emscripten runtimes.
webpack: (config, { isServer, webpack }) => {
if (!isServer) {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/^node:(module|worker_threads)$/,
(resource: { request: string }) => {
resource.request = resource.request.replace(/^node:/, "");
}
)
);
config.resolve = config.resolve ?? {};
config.resolve.fallback = {
...(config.resolve.fallback ?? {}),
module: false,
worker_threads: false,
};
}
config.ignoreWarnings = [
...(config.ignoreWarnings ?? []),
{ module: /satellite\.js[\\/]wasm-build/ },
];
return config;
},
};
export default nextConfig;