Compare commits

...

6 Commits

Author SHA1 Message Date
Timo
feb0fd93e6 Update vite.config.js
Co-authored-by: Robin <robin@robin.town>
2025-04-04 23:19:35 +02:00
Timo
0073a3e079 add comment (review) 2025-04-04 23:06:14 +02:00
Timo
d71c81e82c also allow just linking matrix-sdk-crypto-wasm (without js-sdk linking) 2025-04-04 22:59:42 +02:00
Timo
af4a5e9a7a use realpathSync and make it work with linked and not-linked
We need to use sync because an async defineConfig fails for the embedded exports.
2025-04-04 22:45:45 +02:00
Timo
ae6052cbe4 review: use real path 2025-04-04 22:29:10 +02:00
Valere
feb81c6c03 Devex: Default vite config to support using local build of crypto wasm 2025-04-04 21:48:19 +02:00
2 changed files with 19 additions and 2 deletions

View File

@@ -337,7 +337,7 @@ export function getRelativeRoomUrl(
}
/**
* Perfom a network operation with retries on ConnectionError.
* Perform a network operation with retries on ConnectionError.
* If the error is not retryable, or the max number of retries is reached, the error is rethrown.
* Supports handling of matrix quotas.
*/

View File

@@ -5,13 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { defineConfig, loadEnv } from "vite";
import { defineConfig, loadEnv, searchForWorkspaceRoot } from "vite";
import svgrPlugin from "vite-plugin-svgr";
import { createHtmlPlugin } from "vite-plugin-html";
import { codecovVitePlugin } from "@codecov/vite-plugin";
import { sentryVitePlugin } from "@sentry/vite-plugin";
import react from "@vitejs/plugin-react";
import basicSsl from "@vitejs/plugin-basic-ssl";
import { realpathSync } from "fs";
// https://vitejs.dev/config/
export default defineConfig(({ mode, packageType }) => {
@@ -64,9 +65,25 @@ export default defineConfig(({ mode, packageType }) => {
);
}
// The crypto WASM module is imported dynamically. Since it's common
// for developers to use a linked copy of matrix-js-sdk or Rust
// crypto (which could reside anywhere on their file system), Vite
// needs to be told to recognize it as a legitimate file access.
const allow = [searchForWorkspaceRoot(process.cwd())];
for (const path of [
"node_modules/matrix-js-sdk/node_modules/@matrix-org/matrix-sdk-crypto-wasm",
"node_modules/@matrix-org/matrix-sdk-crypto-wasm",
]) {
try {
allow.push(realpathSync(path));
} catch {}
}
console.log("Allowed vite paths:", allow);
return {
server: {
port: 3000,
fs: { allow },
},
build: {
sourcemap: true,