How to use the metro-source-map.toBabelSegments 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 / JSTransformer / worker.js View on Github external
const minify = getMinifier(this._config.minifierPath);

    try {
      const minified = minify({
        code,
        map: sourceMap,
        filename,
        reserved,
        config: this._config.minifierConfig,
      });

      return {
        code: minified.code,
        map: minified.map
          ? toBabelSegments(minified.map).map(toSegmentTuple)
          : [],
      };
    } catch (error) {
      if (error.constructor.name === 'JS_Parse_Error') {
        throw new Error(
          `${error.message} in file ${filename} at ${error.line}:${error.col}`,
        );
      }

      throw error;
    }
  }