Skip to content
Open
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
12 changes: 11 additions & 1 deletion application/ui/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,24 @@ export default defineConfig({
...config,
resolve: { ...config.resolve, extensions },
watchOptions: { ...config.watchOptions, ignored: ['**/src-tauri/**'] },
// opencv.js (emscripten, under src/ so it's parsed) references
// `__dirname` for Node environment detection. Rspack's default
// `warn-mock` mocks it to '/' AND warns on every build. In the
// browser opencv takes the non-Node code path, so the mock value
// is never used — switch to 'mock' to keep the (identical) runtime
// behavior without the noisy build warning.
node: { ...config.node, __dirname: 'mock', __filename: 'mock' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we ignore the warnings from opencv? I think that might be safe because of:

// The vendored @geti/smart-tools OpenCV.js build (Emscripten-generated,
// cloned in by clone-geti-ui-packages and not ours to edit) contains
// __dirname/__filename in its Node-environment-detection boilerplate.
// It's dead code in a web build (guarded by an ENVIRONMENT_IS_NODE
// check) but Rspack still statically parses and warns on it. Scope
// the suppression to just this file so any future first-party/new
// dependency __dirname usage still surfaces a warning.
ignoreWarnings: [...(config.ignoreWarnings ?? []), { module: /smart-tools[\\/]src[\\/]opencv/ }]

};
},
},
server: {
headers: {
'Cross-Origin-Embedder-Policy': 'credentialless',
'Cross-Origin-Opener-Policy': 'same-origin',
'Cache-Control': 'public, max-age=31536000, immutable',
// Must NOT be 'immutable': dev async chunks are not content-hashed, so an
// immutable cache causes the browser to keep serving stale chunk/HMR runtime
// URLs after a rebuild (stale worker imports, mismatched hmr.js client).
'Cache-Control': 'no-cache',
'Content-Security-Policy':
"default-src 'self'; " +
"script-src 'self' 'unsafe-eval' blob:; " +
Expand Down
Loading