How to use the source-map.SourceMapConsumer.fromSourceMap function in source-map

To help you get started, we’ve selected a few 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 magento / baler / src / __tests__ / minifyWorker.unit.js View on Github external
names: [],
        mappings:
            ';;AAAA,IAAM,IAAI,SAAJ,CAAI,GAAM;AACZ,YAAQ,GAAR,CAAY,UAAK,GAAjB;AACH,CAFD;;;ACAA,IAAM,IAAI,SAAJ,CAAI,GAAM;AACZ,YAAQ,GAAR,CAAY,UAAK,GAAjB;AACH,CAFD',
        file: 'bundle.js',
        sourcesContent: [
            'const b = () => {\n    console.log(this.heh);\n};',
            'const a = () => {\n    console.log(this.lol);\n};',
        ],
    };
    const result = await minifyFromString(js, 'bundle.js', JSON.stringify(map));
    expect(result.code).toMatchInlineSnapshot(`
        "\\"use strict\\";var b=function(){console.log((void 0).heh)},a=function(){console.log((void 0).lol)};
        //# sourceMappingURL=bundle.js.map"
    `);

    const consumer = await SourceMapConsumer.fromSourceMap(result.map);
    // Verify the original code, from before babel, made it to the sourcemap
    expect(consumer.sourceContentFor('file.js')).toMatchInlineSnapshot(`
        "const b = () => {
            console.log(this.heh);
        };"
    `);
    consumer.destroy();
});
github joewalker / devtools.html / server / actors / script.js View on Github external
return sources.getSourceMap(source).then(prevMap => {
      if (prevMap) {
        // Compose the source maps
        this._oldSourceMapping = {
          url: source.sourceMapURL,
          map: prevMap
        };

        prevMap = SourceMapGenerator.fromSourceMap(prevMap);
        prevMap.applySourceMap(sm, this.url);
        sm = SourceMapConsumer.fromSourceMap(prevMap);
      }

      let sources = this.threadActor.sources;
      sources.clearSourceMapCache(source.sourceMapURL);
      sources.setSourceMapHard(source, null, sm);
    });
  },
github joewalker / devtools.html / server / actors / script.js View on Github external
}).then(() => {
      generator.setSourceContent(this.url, code);
      let consumer = SourceMapConsumer.fromSourceMap(generator);

      return {
        code: code,
        map: consumer
      };
    });
  },