async _explodedSourceMapForURL()

in packages/metro/src/Server.js [1109:1161]


  async _explodedSourceMapForURL(reqUrl: string): Promise<ExplodedSourceMap> {
    const options = parseOptionsFromUrl(
      reqUrl,
      new Set(this._config.resolver.platforms),
      BYTECODE_VERSION,
    );

    const {
      entryFile,
      transformOptions,
      serializerOptions,
      graphOptions,
      onProgress,
    } = splitBundleOptions(options);

    /**
     * `entryFile` is relative to projectRoot, we need to use resolution function
     * to find the appropriate file with supported extensions.
     */
    const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
      transformOptions,
      relativeTo: 'server',
    });

    const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
      shallow: graphOptions.shallow,
      experimentalImportBundleSupport:
        this._config.transformer.experimentalImportBundleSupport,
    });
    let revision;
    const revPromise = this._bundler.getRevisionByGraphId(graphId);
    if (revPromise == null) {
      ({revision} = await this._bundler.initializeGraph(
        resolvedEntryFilePath,
        transformOptions,
        {onProgress, shallow: graphOptions.shallow},
      ));
    } else {
      ({revision} = await this._bundler.updateGraph(await revPromise, false));
    }

    let {prepend, graph} = revision;
    if (serializerOptions.modulesOnly) {
      prepend = [];
    }

    return getExplodedSourceMap(
      [...prepend, ...this._getSortedModules(graph)],
      {
        processModuleFilter: this._config.serializer.processModuleFilter,
      },
    );
  }