Skip to content

Commit 549be0e

Browse files
author
徐远翔
committed
fix: react-native#issue-26958
1 parent 5141281 commit 549be0e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

packages/preset/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@
4444
},
4545
"dependencies": {
4646
"@haul-bundler/babel-preset-react-native": "0.16.0",
47-
"@haul-bundler/cli": "0.19.0",
47+
"@haul-bundler/cli": "0.21.0",
4848
"@haul-bundler/preset-0.59": "0.18.0",
4949
"@haul-bundler/preset-0.60": "0.18.0",
5050
"@umijs/bundler-utils": "^3.0.0",
51-
"metro": "^0.51.1",
5251
"umi-react-native-runtime": "^0.0.4-alpha.0",
5352
"webpack-chain": "6.4.0"
5453
},

packages/preset/src/plugins/generateFiles/react-native/polyfill.ts

+20-5
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,32 @@ if (global.window === undefined) {
99
global.window = global;
1010
}
1111
12+
// disable hot module replacement
13+
// @ts-ignore
14+
if (module.hot) {
15+
// @ts-ignore
16+
module.hot.accept = function() {
17+
18+
};
19+
}
20+
1221
`;
1322

1423
export default (api: IApi) => {
1524
const {
1625
utils: { Mustache, semver },
1726
} = api;
18-
api.addPolyfillImports(() => [
19-
{
20-
source: './react-native/polyfill',
21-
},
22-
]);
27+
// api.addPolyfillImports(() => [
28+
// {
29+
// source: './react-native/polyfill',
30+
// },
31+
// ]);
32+
33+
// RN 不需要 @babel/polyfill,这里通过 alias 替换 @umijs/preset-built-in 中的 polyfill
34+
api.chainWebpack((memo) => {
35+
memo.resolve.alias.set('./core/polyfill', './react-native/polyfill');
36+
return memo;
37+
});
2338

2439
api.onGenerateFiles(() => {
2540
const polyfills: string[] = [];

0 commit comments

Comments
 (0)