How to use the metro-source-map.BundleBuilder function in metro-source-map

To help you get started, we’ve selected a few metro-source-map examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / metro / packages / metro / src / ModuleGraph / output / plain-bundle.js View on Github external
function asPlainBundle({
  filename,
  idsForPath,
  modules,
  requireCalls,
  sourceMapPath,
  enableIDInlining,
}): {|
  code: string | Buffer,
  extraFiles?: Iterable<[string, string | Buffer]>,
  map: MixedSourceMap,
|} {
  const builder = new BundleBuilder(filename);
  const modIdForPath = (x: {path: string, ...}) => idsForPath(x).moduleId;

  for (const module of concat(modules, requireCalls)) {
    const {moduleCode, moduleMap} = getModuleCodeAndMap(module, modIdForPath, {
      enableIDInlining,
    });

    builder.append(moduleCode + '\n', moduleMap);
  }

  if (sourceMapPath) {
    builder.append(`//# sourceMappingURL=${sourceMapPath}`);
  }

  const code = builder.getCode();
  const map = builder.getMap();