MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / addModule

Method addModule

packager/src/Bundler/Bundle.js:68–116  ·  view source on GitHub ↗
(
    /**
     * $FlowFixMe: this code is inherently incorrect, because it modifies the
     * signature of the base class function "addModule". That means callsites
     * using an instance typed as the base class would be broken. This must be
     * refactored.
     */
    resolver: {wrapModule: (options: any) => Promise<{code: any, map: any}>},
    resolutionResponse: mixed,
    module: mixed,
    /* $FlowFixMe: erroneous change of signature. */
    moduleTransport: ModuleTransport,
    /* $FlowFixMe: erroneous change of signature. */
  )

Source from the content-addressed store, hash-verified

66 }
67
68 addModule(
69 /**
70 * $FlowFixMe: this code is inherently incorrect, because it modifies the
71 * signature of the base class function "addModule". That means callsites
72 * using an instance typed as the base class would be broken. This must be
73 * refactored.
74 */
75 resolver: {wrapModule: (options: any) => Promise<{code: any, map: any}>},
76 resolutionResponse: mixed,
77 module: mixed,
78 /* $FlowFixMe: erroneous change of signature. */
79 moduleTransport: ModuleTransport,
80 /* $FlowFixMe: erroneous change of signature. */
81 ): Promise<void> {
82 const index = super.addModule(moduleTransport);
83 return resolver.wrapModule({
84 resolutionResponse,
85 module,
86 name: moduleTransport.name,
87 code: moduleTransport.code,
88 map: moduleTransport.map,
89 meta: moduleTransport.meta,
90 minify: this._minify,
91 dev: this._dev,
92 }).then(({code, map}) => {
93 // If we get a map from the transformer we'll switch to a mode
94 // were we're combining the source maps as opposed to
95 if (map) {
96 const usesRawMappings = isRawMappings(map);
97
98 if (this._sourceMapFormat === 'undetermined') {
99 this._sourceMapFormat = usesRawMappings ? 'flattened' : 'indexed';
100 } else if (usesRawMappings && this._sourceMapFormat === 'indexed') {
101 throw new Error(
102 `Got at least one module with a full source map, but ${
103 moduleTransport.sourcePath} has raw mappings`
104 );
105 } else if (!usesRawMappings && this._sourceMapFormat === 'flattened') {
106 throw new Error(
107 `Got at least one module with raw mappings, but ${
108 moduleTransport.sourcePath} has a full source map`
109 );
110 }
111 }
112
113 this.replaceModuleAt(
114 index, new ModuleTransport({...moduleTransport, code, map}));
115 });
116 }
117
118 finalize(options: FinalizeOptions) {
119 options = options || {};

Callers 4

finalizeBundleMethod · 0.45
_addRequireCallMethod · 0.45
Bundle-test.jsFile · 0.45
addModuleFunction · 0.45

Calls 3

wrapModuleMethod · 0.80
replaceModuleAtMethod · 0.80
thenMethod · 0.45

Tested by 1

addModuleFunction · 0.36