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/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.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.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" }, 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: {