React-Native module export problem?

in the source file / Libraries/react-native/react-native-implementation.js of react-native, all modules are exported as follows:

const ReactNative = {
    // Components
    get AccessibilityInfo() { return require("AccessibilityInfo"); },
    get ActivityIndicator() { return require("ActivityIndicator"); },
    ...
}

here we use getter to export, and perform require operation inside the method. Does anyone know the difference between the above export method and the following export method?

const AccessibilityInfo = require("AccessibilityInfo");
const ActivityIndicator = require("ActivityIndicator");

const ReactNative = {
    // Components
    AccessibilityInfo,
    ActivityIndicator
    ...
}

Thank you!


the previous one is require, when needed, and the next one is a stream of brain require coming in


to sum up, I didn't know much about the packaging build part at first, so that's why I have this question.

however, packaging builds are static parsing, so no matter which management method is used, it will not affect the size of the bundle, but because it loads on demand, it can improve the speed of page initialization.

Menu