From a4d5cefc408ac530552b44350b7b97a8b115e8f1 Mon Sep 17 00:00:00 2001 From: Heath Snee Date: Fri, 19 Jul 2024 18:07:01 +0200 Subject: [PATCH 1/4] preserveSymlinks --- apps/extension/tsconfig.json | 3 +-- apps/extension/tsconfig.radix.json | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/extension/tsconfig.json b/apps/extension/tsconfig.json index 1ce41267c..04b3b1de8 100644 --- a/apps/extension/tsconfig.json +++ b/apps/extension/tsconfig.json @@ -4,8 +4,7 @@ "paths": { "@src/*": ["./apps/extension/src/*"], }, - "tsBuildInfoFile": ".build-cache/tsconfig.tsbuildinfo", - "preserveSymlinks": true + "tsBuildInfoFile": ".build-cache/tsconfig.tsbuildinfo" }, "include": ["src/**/*.json", "src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "tests/**/*.ts"], "references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.radix.json" }] diff --git a/apps/extension/tsconfig.radix.json b/apps/extension/tsconfig.radix.json index 8ba241007..30a227156 100644 --- a/apps/extension/tsconfig.radix.json +++ b/apps/extension/tsconfig.radix.json @@ -15,6 +15,7 @@ "isolatedModules": false, "noEmit": false, "jsx": "react-jsx", + "preserveSymlinks": true, "rootDir":"../../node_modules/@radixdlt/connector-extension", "baseUrl": "../../node_modules/@radixdlt/connector-extension/src", From c01815ad2eccb8f4aea8c6ba763fa2ce5b9be69e Mon Sep 17 00:00:00 2001 From: Heath Snee Date: Fri, 19 Jul 2024 18:11:45 +0200 Subject: [PATCH 2/4] preserveSymlinks --- apps/extension/tsconfig.radix.json | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/extension/tsconfig.radix.json b/apps/extension/tsconfig.radix.json index 30a227156..8ba241007 100644 --- a/apps/extension/tsconfig.radix.json +++ b/apps/extension/tsconfig.radix.json @@ -15,7 +15,6 @@ "isolatedModules": false, "noEmit": false, "jsx": "react-jsx", - "preserveSymlinks": true, "rootDir":"../../node_modules/@radixdlt/connector-extension", "baseUrl": "../../node_modules/@radixdlt/connector-extension/src", From f6d0267f61d95a030a1b77ff9853e64733897574 Mon Sep 17 00:00:00 2001 From: Heath Snee Date: Fri, 19 Jul 2024 20:00:58 +0200 Subject: [PATCH 3/4] Add return type --- apps/extension/src/pages/app/main.tsx | 2 +- apps/extension/tsconfig.node.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/extension/src/pages/app/main.tsx b/apps/extension/src/pages/app/main.tsx index d9efb2580..5507b42f7 100644 --- a/apps/extension/src/pages/app/main.tsx +++ b/apps/extension/src/pages/app/main.tsx @@ -59,7 +59,7 @@ if (APP_RADIX) { } } -export const router = createHashRouter([ +export const router: ReturnType = createHashRouter([ { path: '/', element: , diff --git a/apps/extension/tsconfig.node.json b/apps/extension/tsconfig.node.json index 9264aa17a..81e340263 100644 --- a/apps/extension/tsconfig.node.json +++ b/apps/extension/tsconfig.node.json @@ -2,9 +2,9 @@ "compilerOptions": { "composite": true, "module": "esnext", + "moduleResolution": "node", "resolveJsonModule": true, "allowSyntheticDefaultImports": true, - "moduleResolution": "node", "tsBuildInfoFile": ".build-cache/tsconfig.node.tsbuildinfo" }, From bf2e0441c3b498809af7ab01917664303ae1092c Mon Sep 17 00:00:00 2001 From: Heath Snee Date: Sat, 20 Jul 2024 17:23:20 +0200 Subject: [PATCH 4/4] Dix build --- apps/extension/package.json | 3 ++- apps/extension/src/helpers/radix/fix-types.js | 16 ++++++++++++++++ apps/extension/vite.config.ts | 16 +++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 apps/extension/src/helpers/radix/fix-types.js diff --git a/apps/extension/package.json b/apps/extension/package.json index d66453590..265228b33 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -9,10 +9,11 @@ "start": "vite --mode development", "build:dev": "DEV_TOOLS=true yarn build:radix", "build:radix": "RADIX=true yarn build", - "build": "npm_config_build_from_source=true tsc --build && vite build --mode production", + "build": "yarn radix:fix-types && npm_config_build_from_source=true tsc --build && vite build --mode production", "build:copy-as-firefox": "node src/helpers/firefox", "build:release": "yarn build:radix && yarn build:copy-as-firefox", "preview": "vite preview", + "radix:fix-types": "node src/helpers/radix/fix-types", "check-types": "tsc --noemit", "eslint": "eslint --fix --ignore-path .eslintignore --ext .js,.ts,.tsx .", "lint": "yarn eslint && yarn check-types", diff --git a/apps/extension/src/helpers/radix/fix-types.js b/apps/extension/src/helpers/radix/fix-types.js new file mode 100644 index 000000000..d8809b1d6 --- /dev/null +++ b/apps/extension/src/helpers/radix/fix-types.js @@ -0,0 +1,16 @@ +import fs from 'fs' + +const content = fs.readFileSync( + '../../node_modules/@radixdlt/connector-extension/src/chrome/background/create-gateway-module.ts', + 'utf8', +) + +const newContent = content.replace( + 'createGatewayModule = (networkId: number) =>', + 'createGatewayModule = (networkId: number): GatewayModule =>', +) + +fs.writeFileSync( + '../../node_modules/@radixdlt/connector-extension/src/chrome/background/create-gateway-module.ts', + newContent, +) diff --git a/apps/extension/vite.config.ts b/apps/extension/vite.config.ts index bcaa5f2eb..b6b77103b 100644 --- a/apps/extension/vite.config.ts +++ b/apps/extension/vite.config.ts @@ -19,13 +19,12 @@ const config = { }, resolve: { alias: { - stream: 'vite-compatible-readable-stream', config: resolve(__dirname, 'src/config'), version: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/version'), - 'message-router': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/message-router'), - chrome: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/chrome'), - components: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/components'), - connector: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/connector'), + options: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/options'), + utils: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/utils'), + chrome: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/chrome'), + // have to replace each crypto/[path] otherwise it will error out due to default crypto import 'crypto/blake2b': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/crypto/blake2b'), 'crypto/curve25519': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/crypto/curve25519'), 'crypto/encryption': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/crypto/encryption'), @@ -33,16 +32,15 @@ const config = { 'crypto/secp256k1': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/crypto/secp256k1'), 'crypto/secure-random': resolve(__dirname,'../../node_modules/@radixdlt/connector-extension/src/crypto/secure-random'), 'crypto/get-linking-message': resolve(__dirname,'../../node_modules/@radixdlt/connector-extension/src/crypto/get-linking-message'), - 'io-types': resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/io-types'), - ledger: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/ledger'), pairing: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/pairing'), - options: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/options'), + components: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/components'), + ledger: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/ledger'), queues: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/queues'), - utils: resolve(__dirname, '../../node_modules/@radixdlt/connector-extension/src/utils'), 'chrome/helpers/add-origin-to-wallet-interaction': resolve(__dirname, 'src/radix/add-origin-to-wallet-interaction'), 'chrome/helpers/chrome-storage-sync': resolve(__dirname, 'src/radix/storage-sync'), 'chrome/helpers/chrome-local-store': resolve(__dirname, 'src/radix/storage-local'), 'chrome/background/create-gateway-module': resolve(__dirname, 'src/radix/create-gateway-module'), + './create-gateway-module': resolve(__dirname, 'src/radix/create-gateway-module'), }, }, define: {