disable package exports

This commit is contained in:
Samuel Newman
2025-04-28 12:54:40 +03:00
parent 16325fd43e
commit 649c89bda1
4 changed files with 23 additions and 11 deletions
-4
View File
@@ -37,10 +37,6 @@ module.exports = function (api) {
alias: {
// This needs to be mirrored in tsconfig.json
'#': './src',
lib: './src/lib',
platform: './src/platform',
state: './src/state',
view: './src/view',
crypto: './src/platform/crypto.ts',
},
},
+18
View File
@@ -16,7 +16,25 @@ if (process.env.BSKY_PROFILE) {
cfg.resolver.assetExts = [...cfg.resolver.assetExts, 'woff2']
// Enabled by default in RN 0.79+, but this breaks Lingui + others
cfg.resolver.unstable_enablePackageExports = false
cfg.resolver.resolveRequest = (context, moduleName, platform) => {
// HACK: manually resolve a few packages that use `exports` in `package.json`.
// A proper solution is to enable `unstable_enablePackageExports` but this needs careful testing.
if (moduleName.startsWith('multiformats/hashes/hasher')) {
return context.resolveRequest(
context,
'multiformats/cjs/src/hashes/hasher',
platform,
)
}
if (moduleName.startsWith('multiformats/cid')) {
return context.resolveRequest(context, 'multiformats/cjs/src/cid', platform)
}
if (moduleName === '@ipld/dag-cbor') {
return context.resolveRequest(context, '@ipld/dag-cbor/src', platform)
}
if (process.env.BSKY_PROFILE) {
if (moduleName.endsWith('ReactNativeRenderer-prod')) {
return context.resolveRequest(
+3 -2
View File
@@ -19,7 +19,8 @@ import * as dcbor from '@ipld/dag-cbor'
import {t} from '@lingui/macro'
import {type QueryClient} from '@tanstack/react-query'
import {sha256} from 'js-sha256'
import {CID, hasher} from 'multiformats'
import {CID} from 'multiformats/cid'
import * as Hasher from 'multiformats/hashes/hasher'
import {isNetworkError} from '#/lib/strings/errors'
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
@@ -409,7 +410,7 @@ async function resolveRecord(
// The built-in hashing functions from multiformats (`multiformats/hashes/sha2`)
// are meant for Node.js, this is the cross-platform equivalent.
const mf_sha256 = hasher.from({
const mf_sha256 = Hasher.from({
name: 'sha2-256',
code: 0x12,
encode: input => {
+2 -5
View File
@@ -7,12 +7,9 @@
"baseUrl": ".",
"paths": {
"#/*": ["./src/*"],
"lib/*": ["./src/lib/*"],
"platform/*": ["./src/platform/*"],
"state/*": ["./src/state/*"],
"view/*": ["./src/view/*"],
"crypto": ["./src/platform/crypto.ts"],
"multiformats": ["node_modules/multiformats/types/src/index.d.ts"]
"multiformats/cid": ["node_modules/multiformats/types/src/cid.d.ts"],
"multiformats/hashes/hasher": ["node_modules/multiformats/types/src/hashes/hasher.d.ts"]
}
},
"exclude": ["bskyweb", "bskyembed", "web-build"]