Skip to content

Commit f99ba74

Browse files
fix blob import
1 parent 111a306 commit f99ba74

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

packages/react-native/rollup.config.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import inject from '@rollup/plugin-inject';
44
import json from '@rollup/plugin-json';
55
import nodeResolve from '@rollup/plugin-node-resolve';
66
import replace from '@rollup/plugin-replace';
7+
import terser from '@rollup/plugin-terser';
78
import path from 'path';
89
import { fileURLToPath } from 'url';
9-
import terser from '@rollup/plugin-terser';
1010

1111
const __filename = fileURLToPath(import.meta.url);
1212
const __dirname = path.dirname(__filename);
@@ -34,7 +34,7 @@ export default (commandLineArgs) => {
3434
}),
3535
json(),
3636
nodeResolve({
37-
preferBuiltins: false,
37+
preferBuiltins: false
3838
}),
3939
commonjs({}),
4040
inject({
@@ -48,6 +48,10 @@ export default (commandLineArgs) => {
4848
alias({
4949
entries: [
5050
{ find: 'bson', replacement: path.resolve(__dirname, '../../node_modules/bson/lib/bson.rn.cjs') },
51+
{
52+
find: 'react-native/Libraries/Blob/BlobManager',
53+
replacement: path.resolve(__dirname, './vendor/BlobManager.js')
54+
}
5155
]
5256
}),
5357
terser()
@@ -59,7 +63,6 @@ export default (commandLineArgs) => {
5963
'node-fetch',
6064
'js-logger',
6165
'react-native',
62-
'react-native/Libraries/Blob/BlobManager',
6366
'react'
6467
]
6568
};

packages/react-native/src/sync/stream/ReactNativeRemote.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ class ReactNativeFetchProvider extends FetchImplementationProvider {
3232
}
3333

3434
getFetch(): FetchImplementation {
35-
/**
36-
* From Expo 52, Expo provides a fetch implementation which supports HTTP streams.
37-
* https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api
38-
*/
39-
try {
40-
const f = require('expo/fetch').fetch;
41-
if (f) {
42-
this.logger.debug('Using Expo fetch implementation');
43-
return f;
44-
}
45-
} catch (e) {
46-
// If expo is not installed, fallback
47-
}
4835
return fetch.bind(globalThis);
4936
}
5037
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The current Rollup configuration targets a CommonJs output.
3+
* This translates import statements to require statements.
4+
* React native recently shifted to ESM exports.
5+
* https://github.com/facebook/react-native/pull/48761/files
6+
* This causes requiring this module to return an object
7+
* of the form
8+
* ```javascript
9+
* {
10+
* _esModule: true,
11+
* default: BlobManager
12+
* }
13+
* ```
14+
* This wrapper provides a small shim to conditionally return the default export of the module.
15+
*/
16+
const BlobManager = require('react-native/Libraries/Blob/BlobManager');
17+
const interop = (mod) => (mod && mod.__esModule ? mod.default : mod);
18+
19+
export default interop(BlobManager);

0 commit comments

Comments
 (0)