How to use the convert-source-map.fromMapFileComment function in convert-source-map

To help you get started, we’ve selected a few convert-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 javascript-studio / studio-cli / lib / studio.js View on Github external
setSource(source) {
    if (!source) {
      this.fail('No sources received on stdin');
      return;
    }
    this.source = source;
    this.source_map = convert_source_map.fromSource(source);
    if (!this.source_map) {
      try {
        this.source_map = convert_source_map.fromMapFileComment(source,
          this.working_dir);
      } catch (ignore) {
        // It throws if there are no source maps
      }
    }
    if (this.source_map) {
      this.source_map = this.source_map.toObject();
      this.source = convert_source_map.removeComments(source);
    }
    gzip(source, (err, buffer) => {
      if (err) {
        this.fail('gzip failure', err);
      } else {
        this.setGzipBuffer(buffer);
      }
    });
github linkedin / css-blocks / packages / webpack-plugin / src / CssAssets.ts View on Github external
function assetAsSource(contents: string, filename: string): Source {
    let sourcemap: convertSourceMap.SourceMapConverter | undefined;
    if (/sourceMappingURL/.test(contents)) {
        sourcemap = convertSourceMap.fromSource(contents) ||
            convertSourceMap.fromMapFileComment(contents, path.dirname(filename));
    }
    if (sourcemap) {
        let sm: RawSourceMap = sourcemap.toObject();
        contents = convertSourceMap.removeComments(contents);
        contents = convertSourceMap.removeMapFileComments(contents);
        return new SourceMapSource(contents, filename, sm);
    } else {
        return new RawSource(contents);
    }
}
github plasma-umass / Stopify / stopify-third-party-compiler-container / server / ts / misc.ts View on Github external
export function inlineSourceMapFile(srcPath: string, mapPath: string): Promise {
  const mapConverter = smc.fromMapFileComment(`//# sourceMappingURL=${mapPath}`, path.dirname(mapPath))!;
  const inline = mapConverter.toComment();
  return fs.readFile(srcPath, 'utf-8')
    .then(src => fs.writeFile(srcPath, smc.removeMapFileComments(src), { encoding: 'utf-8' }))
    .then(() => fs.appendFile(srcPath, inline, { encoding: 'utf-8' }))
    .then(() => srcPath);
}
github plasma-umass / Stopify / stopify-ide / ts / compilers / utils.ts View on Github external
export function inlineSourceMapFile(srcPath: string, mapPath: string): Promise {
  const mapConverter = smc.fromMapFileComment(`//# sourceMappingURL=${mapPath}`, path.dirname(mapPath))!;
  const inline = mapConverter.toComment();
  return fsExtra.readFile(srcPath, 'utf-8')
    .then(src => fsExtra.writeFile(srcPath, smc.removeMapFileComments(src), { encoding: 'utf-8' }))
    .then(() => fs.appendFile(srcPath, inline, { encoding: 'utf-8' }))
    .then(() => srcPath);
}