facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.24k stars 626 forks source link

RN The official scaffolding project introduced bundlejs and modified it again, but the hot update could not be triggered #1288

Open nianxiongdi opened 5 months ago

nianxiongdi commented 5 months ago
  1. install project
    
    npx react-native@latest init AwesomeProject
2. Description
Introduced in app.tsx. official scaffolding、official scaffolding、official scaffolding、official scaffolding

```js
const infos = require('./infos')

const App = () => {

  <View>

  <<infos />
</view>
}

export default App;
  1. Modify file A and cannot trigger hot.

  2. I would like to ask how to trigger my bundlejs file through metro and trigger hot update again.

  3. Thank you very much.

nianxiongdi commented 5 months ago
// source code of metro
const inject = ({ module: [id, code], sourceURL }) => {
  if (global.globalEvalWithSourceUrl) {
    global.globalEvalWithSourceUrl(code, sourceURL);
  } else {
    eval(code);
  } 
};

during the second update code, it was found that the code and sourceURL were the latest, but the original components were used when rendering. The component is not updated.

Blackgan3 commented 4 months ago

same problem