How to use source-map-resolve - 10 common examples

To help you get started, we’ve selected a few source-map-resolve 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 walmartlabs / circus / lib / publish.js View on Github external
function processJS(file, data, callback) {
    // Preemptively kill the sourcemap published entry
    circus.published[file + '.map'] = undefined;

    if (options.sourceMap !== false) {
      SourceMapResolve.resolveSourceMap(data + '', Path.resolve(buildDir, file), Fs.readFile, function(err, sourceMap) {
        if (err) {
          return callback(err);
        }

        // Transform embedded urls using resolve
        var ast = recast.parse(data, {sourceFileName: file});

        recast.visit(ast, {
          visitLiteral: function(path) {
            // Replace literal file references
            var value = path.value.value;
            if (typeof value === 'string' && circus.published.hasOwnProperty(value)) {
              path.value.value = circus.published[value];
            }
            return path.value;
          }
github manse / stylus-css-modules / lib / index.js View on Github external
style.on('end', function(err, css) {
            var sourceMap = sourceMapResolve.resolveSourceMapSync(css, null, fs.readFile);
            var mangled = mangle(css, sourceMap.map, {
                camelCase: pluginOptions.camelCase,
                projection: pluginOptions.projection
            });
            if (typeof pluginOptions.target === 'function') {
                pluginOptions.target(style.options.filename, mangled.map);
            } else {
                for (var i in mangled.map) {
                    var relativePath = path.relative(srcDir, path.resolve(destDir, i));
                    if (~relativePath.indexOf('..')) {
                        console.log(color.yellow('Traversal path "' + relativePath + '" is not output.'));
                        continue;
                    }
                    var styl = path.parse(relativePath);
                    var variableName = camelCase(styl.name);
                    var outputPath = path.resolve(scriptDir, relativePath.replace(new RegExp(styl.ext + '$'), '.' + target));
github wheeyls / critical-css-server / node_modules / css / lib / stringify / source-map-support.js View on Github external
Object.keys(this.files).forEach(function(file) {
    var content = this.files[file];
    this.map.setSourceContent(file, content);

    if (this.options.inputSourcemaps !== false) {
      var originalMap = sourceMapResolve.resolveSync(
        content, file, fs.readFileSync);
      if (originalMap) {
        var map = new SourceMapConsumer(originalMap.map);
        var relativeTo = originalMap.sourcesRelativeTo;
        this.map.applySourceMap(map, file, urix(path.dirname(relativeTo)));
      }
    }
  }, this);
};
github MortenHoustonLudvigsen / KarmaTestAdapter / JsTestAdapter / TestServer / SourceUtils.ts View on Github external
private getSourceMapConsumer(filePath: string): SourceMap.SourceMapConsumer {
        if (filePath in this.sourceMapConsumers) {
            return this.sourceMapConsumers[filePath];
        }
        try {
            var content = fs.readFileSync(filePath).toString();
            var sourceMap = SourceMapResolve.resolveSync(content, filePath, fs.readFileSync);
            var consumer = sourceMap ? new SourceMap.SourceMapConsumer(sourceMap.map) : null;
            if (consumer) {
                consumer['resolvePath'] = (filePath: string) => path.resolve(path.dirname(sourceMap.sourcesRelativeTo), filePath);
            }
            this.sourceMapConsumers[filePath] = consumer;
            return consumer;
        } catch (e) {
            this.sourceMapConsumers[filePath] = undefined;
        }
    }
github liquidg3 / altair / node_modules / css-parse / node_modules / css / lib / stringify / source-map-support.js View on Github external
Object.keys(this.files).forEach(function(file) {
    var content = this.files[file];
    this.map.setSourceContent(file, content);

    if (this.options.inputSourcemaps !== false) {
      var originalMap = sourceMapResolve.resolveSync(
        content, file, fs.readFileSync);
      if (originalMap) {
        var map = new SourceMapConsumer(originalMap.map);
        var relativeTo = originalMap.sourcesRelativeTo;
        this.map.applySourceMap(map, file, urix(path.dirname(relativeTo)));
      }
    }
  }, this);
};
github reworkcss / css-stringify / lib / source-map-support.js View on Github external
Object.keys(this.files).forEach(function(file) {
    var originalMap = sourceMapResolve.resolveSync(
      this.files[file], file, fs.readFileSync);
    if (originalMap) {
      originalMap = new SourceMapConsumer(originalMap.map);
      this.map.applySourceMap(originalMap, file);
    }
  }, this);
};
github rhiokim / haroopad / src / node_modules / css / lib / stringify / source-map-support.js View on Github external
Object.keys(this.files).forEach(function(file) {
    var content = this.files[file];
    this.map.setSourceContent(file, content);

    if (this.options.inputSourcemaps !== false) {
      var originalMap = sourceMapResolve.resolveSync(
        content, file, fs.readFileSync);
      if (originalMap) {
        var map = new SourceMapConsumer(originalMap.map);
        var relativeTo = originalMap.sourcesRelativeTo;
        this.map.applySourceMap(map, file, urix(path.dirname(relativeTo)));
      }
    }
  }, this);
};
github MortenHoustonLudvigsen / KarmaTestAdapter / KarmaTestAdapter / TestServer / SourceUtils.js View on Github external
SourceUtils.prototype.getSourceMapConsumer = function (filePath) {
        if (filePath in this.sourceMapConsumers) {
            return this.sourceMapConsumers[filePath];
        }
        try {
            var content = fs.readFileSync(filePath).toString();
            var sourceMap = SourceMapResolve.resolveSync(content, filePath, fs.readFileSync);
            var consumer = sourceMap ? new SourceMap.SourceMapConsumer(sourceMap.map) : null;
            if (consumer) {
                consumer['resolvePath'] = function (filePath) { return path.resolve(path.dirname(sourceMap.sourcesRelativeTo), filePath); };
            }
            this.sourceMapConsumers[filePath] = consumer;
            return consumer;
        }
        catch (e) {
            this.sourceMapConsumers[filePath] = undefined;
        }
    };
    SourceUtils.prototype.resolveSource = function (source) {
github here-be / snapdragon / lib / source-maps.js View on Github external
Object.keys(this.files).forEach(function(file) {
    var content = this.files[file];
    this.map.setSourceContent(file, content);

    if (this.options.inputSourcemaps === true) {
      var originalMap = sourceMapResolve.resolveSync(content, file, fs.readFileSync);
      if (originalMap) {
        var map = new SourceMap.SourceMapConsumer(originalMap.map);
        var relativeTo = originalMap.sourcesRelativeTo;
        this.map.applySourceMap(map, file, unixify(path.dirname(relativeTo)));
      }
    }
  }, this);
};
github MortenHoustonLudvigsen / KarmaTestAdapter / KarmaTestAdapterTests / TestServer / SourceUtils.js View on Github external
SourceUtils.prototype.getSourceMapConsumer = function (filePath) {
        if (filePath in this.sourceMapConsumers) {
            return this.sourceMapConsumers[filePath];
        }
        try {
            var content = fs.readFileSync(filePath).toString();
            var sourceMap = SourceMapResolve.resolveSync(content, filePath, fs.readFileSync);
            var consumer = sourceMap ? new SourceMap.SourceMapConsumer(sourceMap.map) : null;
            if (consumer) {
                consumer['resolvePath'] = function (filePath) { return path.resolve(path.dirname(sourceMap.sourcesRelativeTo), filePath); };
            }
            this.sourceMapConsumers[filePath] = consumer;
            return consumer;
        }
        catch (e) {
            this.sourceMapConsumers[filePath] = undefined;
        }
    };
    SourceUtils.prototype.resolveSource = function (source) {

source-map-resolve

Resolve the source map and/or sources for a generated file.

MIT
Latest version published 4 years ago

Package Health Score

55 / 100
Full package analysis