How to use the source-map-url.removeFrom 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
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 {
  splitContents = map.sources.map(function(name){
    return fs.readFileSync(path.join(path.dirname(process.argv[2]), name), 'utf-8').split(newline);
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: '' }
    }
  }
}
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);
    }

    let valid = true;
github szrenwei / inline-manifest-webpack-plugin / index.js View on Github external
.tapAsync('InlineManifestWebpackPlugin', function (htmlPluginData, cb) {
                    var runtime = []
                    var assets = htmlPluginData.assets
                    var manifestAssetName = getAssetName(compilation.chunks, name)

                    if (manifestAssetName && htmlPluginData.plugin.options.inject === false) {
                        runtime.push('')

                        var runtimeIndex = assets.js.indexOf(assets.publicPath + manifestAssetName)
                        if (runtimeIndex >= 0) {
                            assets.js.splice(runtimeIndex, 1)
                            delete assets.chunks[name]
                        }
                    }

                    assets.runtime = runtime.join('')
                    cb(null, htmlPluginData)
                })
        })
github mapbox / underreact / lib / webpack-config / generate-html-template.js View on Github external
function getInlinedRuntime({ webpackCompilation }) {
  const runtimeFilename = getAssetFilename(
    webpackCompilation.chunks,
    'runtime'
  );
  return ``;
}
github rbuckton / iterable-query / scripts / build.js View on Github external
transform(file, _, cb) {
            if (typeof file === "string" || Buffer.isBuffer(file)) return cb(new Error("Only Vinyl files are supported."));
            if (file.extname === ".map") return cb();
            if (file.extname === ".js" || file.extname === ".ts") {
                if (file.isBuffer()) {
                    const contents = file.contents.toString("utf8");
                    const modified = sourcemapUrl.removeFrom(contents);
                    if (modified !== contents) {
                        file.contents = Buffer.from(modified, "utf8");
                    }
                }
            }
            return cb(null, file);
        }
    });
github szrenwei / inline-manifest-webpack-plugin / index.js View on Github external
return scripts.map(function (script) {
        var isManifestScript = script.tagName === 'script' &&
              (script.attributes.src.indexOf(manifestAssetName) >= 0)

        if (isManifestScript) {
            return {
                tagName: 'script',
                closeTag: true,
                attributes: {
                    type: 'text/javascript'
                },
                innerHTML: sourceMappingURL.removeFrom(compilation.assets[manifestAssetName].source())
            }
        }

        return script
    })
}

source-map-url

Tools for working with sourceMappingURL comments.

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis