How to use the metro-source-map.generateFunctionMap 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-react-native-babel-transformer / src / index.js View on Github external
: process.env.BABEL_ENV || 'production';

  try {
    const babelConfig = {
      // ES modules require sourceType='module' but OSS may not always want that
      sourceType: 'unambiguous',
      ...buildBabelConfig(filename, options, plugins),
      caller: {name: 'metro', platform: options.platform},
      ast: true,
    };
    const sourceAst = parseSync(src, babelConfig);
    /* $FlowFixMe(>=0.111.0 site=react_native_fb) This comment suppresses an
     * error found when Flow v0.111 was deployed. To see the error, delete this
     * comment and run Flow. */
    const result = transformFromAstSync(sourceAst, src, babelConfig);
    const functionMap = generateFunctionMap(sourceAst, {filename});

    // The result from `transformFromAstSync` can be null (if the file is ignored)
    if (!result) {
      return {ast: null, functionMap};
    }

    return {ast: result.ast, functionMap};
  } finally {
    if (OLD_BABEL_ENV) {
      process.env.BABEL_ENV = OLD_BABEL_ENV;
    }
  }
}
github facebook / metro / packages / metro-babel-transformer / src / index.js View on Github external
: process.env.BABEL_ENV || 'production';

  try {
    const babelConfig = {
      caller: {name: 'metro', platform: options.platform},
      ast: true,
      babelrc: options.enableBabelRCLookup,
      code: false,
      highlightCode: true,
      filename,
      plugins,
      sourceType: 'module',
    };
    const sourceAst = parseSync(src, babelConfig);
    const {ast} = transformFromAstSync(sourceAst, src, babelConfig);
    const functionMap = generateFunctionMap(sourceAst, {filename});

    return {ast, functionMap};
  } finally {
    if (OLD_BABEL_ENV) {
      process.env.BABEL_ENV = OLD_BABEL_ENV;
    }
  }
}