How to use the source-map-url.existsIn function in source-map-url

To help you get started, we’ve selected a few source-map-url 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 ef4 / fast-sourcemap-concat / tools / dissect.js View on Github external
#!/usr/bin/env node

var srcURL = require('source-map-url');
var SourceMap = require('../lib/source-map');

if (process.argv.length < 3) {
  process.stderr.write("Usage: dissect.js  []\n");
  process.exit(-1);
}

var fs = require('fs');
var path = require('path');
var src = fs.readFileSync(process.argv[2], 'utf-8');
var map;

if (srcURL.existsIn(src) && process.argv.length < 4) {
  var url = srcURL.getFrom(src);
  src = srcURL.removeFrom(src);
  map = SourceMap.prototype._resolveSourcemap(process.argv[2], url);
} else {
  map = JSON.parse(fs.readFileSync(process.argv[3], 'utf-8'));
}
var Coder = require('../lib/coder');
var colWidth = 60;
var newline = /\n\r?/;

var lines = src.split(newline);
var mappings = map.mappings.split(';');
var splitContents;
if (map.sourcesContent) {
  splitContents = map.sourcesContent.map(function(src){return src ? src.split(newline) : [];});
} else {
github ember-cli / broccoli-uglify-sourcemap / lib / process-file.js View on Github external
let filename = path.basename(inFile);
    let url = _options.sourceMapDir ? `/${path.join(_options.sourceMapDir, mapName)}` : mapName;

    let publicUrl = _options.publicUrl;
    if (publicUrl) {
      url = `${publicUrl}/${url}`;
    }

    let hiddenSourceMap = _options.hiddenSourceMap;
    if (hiddenSourceMap) {
      url = '';
    }

    let sourceMap = { filename, url };

    if (srcURL.existsIn(src)) {
      let url = srcURL.getFrom(src);
      let sourceMapPath = path.join(path.dirname(inFile), url);
      if (fs.existsSync(sourceMapPath)) {
        sourceMap.content = JSON.parse(fs.readFileSync(sourceMapPath));
      } else if (!silent) {
        console.warn(`[WARN] (broccoli-uglify-sourcemap) "${url}" referenced in "${relativePath}" could not be found`);
      }
    }

    options = defaults(options, { sourceMap });
  }

  let start = new Date();
  debug('[starting]: %s %dKB', relativePath, (src.length / 1000));
  let result = terser.minify(src, options);
  let end = new Date();
github ef4 / fast-sourcemap-concat / lib / source-map.js View on Github external
addFileSource(filename, source, inputSrcMap) {
    let url;

    if (source.length === 0) {
      return;
    }

    if (srcURL.existsIn(source)) {
      url = srcURL.getFrom(source);
      source = srcURL.removeFrom(source);
    }

    if (this.content.mappings.length > 0 && this.nextFileSourceNeedsComma) {
      this.content.mappings += ',';
      this.nextFileSourceNeedsComma = false;
    }

    if (typeof inputSrcMap === 'string') {
      inputSrcMap = JSON.parse(inputSrcMap);
    }

    if (inputSrcMap === undefined && url) {
      inputSrcMap = this._resolveSourcemap(filename, url);
    }
github lautis / rollup-plugin-browserify-transform / src / index.js View on Github external
function extract(code) {
  if (sourceMapURL.existsIn(code)) {
    return {
      code: sourceMapURL.removeFrom(code),
      map: parseSourceMap(code)
    }
  } else {
    return {
      code: code,
      map: { mappings: '' }
    }
  }
}

source-map-url

Tools for working with sourceMappingURL comments.

MIT
Latest version published 4 years ago

Package Health Score

52 / 100
Full package analysis