How to use the metro-source-map.fromRawMappings 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 / DeltaBundler / Serializers / Serializers.js View on Github external
const ramModules = modules.map(module => ({
    id: module.id,
    code: module.code,
    map: fromRawMappings([module]).toMap(module.path, {
      excludeSource: options.excludeSource,
    }),
    name: module.name,
    sourcePath: module.path,
    source: module.source,
    type: module.type,
  }));
github facebook / metro / packages / metro / src / DeltaBundler / Serializers / Serializers.js View on Github external
async function fullSourceMap(
  deltaBundler: DeltaBundler,
  options: BundleOptions,
): Promise {
  const {modules} = await _getAllModules(deltaBundler, options);

  return fromRawMappings(modules).toString(undefined, {
    excludeSource: options.excludeSource,
  });
}
github facebook / metro / packages / metro / src / JSTransformer / worker.js View on Github external
async _minifyCode(
    filename: string,
    code: string,
    source: string,
    map: Array,
    reserved?: $ReadOnlyArray = [],
  ): Promise<{
    code: string,
    map: Array,
    ...
  }> {
    const sourceMap = fromRawMappings([
      {code, source, map, functionMap: null, path: filename},
    ]).toMap(undefined, {});

    const minify = getMinifier(this._config.minifierPath);

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

      return {
        code: minified.code,
github facebook / metro / packages / metro / src / DeltaBundler / Serializers / Serializers.js View on Github external
async function fullSourceMapObject(
  deltaBundler: DeltaBundler,
  options: BundleOptions,
): Promise {
  const {modules} = await _getAllModules(deltaBundler, options);

  return fromRawMappings(modules).toMap(undefined, {
    excludeSource: options.excludeSource,
  });
}
github facebook / metro / packages / metro / src / DeltaBundler / Serializers / sourceMapGenerator.js View on Github external
): ReturnType {
  let sourceMapInfos;
  getSourceMapInfosImpl(
    true,
    infos => {
      sourceMapInfos = infos;
    },
    modules,
    options,
  );
  if (sourceMapInfos == null) {
    throw new Error(
      'Expected getSourceMapInfosImpl() to finish synchronously.',
    );
  }
  return fromRawMappings(sourceMapInfos);
}
github facebook / metro / packages / metro / src / Resolver / index.js View on Github external
async minifyModule(
    path: string,
    code: string,
    map: CompactRawMappings,
  ): Promise<{code: string, map: CompactRawMappings}> {
    const sourceMap = fromRawMappings([{code, source: code, map, path}]).toMap(
      undefined,
      {},
    );

    const minified = await this._minifyCode(path, code, sourceMap);
    const result = await this._postMinifyProcess({...minified});

    return {
      code: result.code,
      map: result.map ? toRawMappings(result.map).map(compactMapping) : [],
    };
  }