How to use the source-map.SourceMapConsumer.initialize 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 kaspernj / api_maker / npm-api-maker / src / source-maps-loader.js View on Github external
import * as stackTraceParser from "stacktrace-parser"
import {SourceMapConsumer} from "source-map"

// Sometimes this needs to be called and sometimes not
if (SourceMapConsumer.initialize) {
  SourceMapConsumer.initialize({
    "lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm"
  })
}

export default class SourceMapsLoader {
  constructor() {
    this.sourceMaps = []
    this.srcLoaded = {}
  }

  loadSourceMapsForScriptTags(callback) {
    this.loadSourceMapsForScriptTagsCallback = callback
  }

  sourceMapForSource(callback) {
    this.sourceMapForSourceCallback = callback
github source-academy / js-slang / src / index.ts View on Github external
scheduler: 'preemptive' | 'async'
  steps: number
  executionMethod: ExecutionMethod
  originalMaxExecTime: number
}

const DEFAULT_OPTIONS: IOptions = {
  scheduler: 'async',
  steps: 1000,
  executionMethod: 'auto',
  originalMaxExecTime: 1000
}

// needed to work on browsers
// @ts-ignore
SourceMapConsumer.initialize({
  'lib/mappings.wasm': 'https://unpkg.com/source-map@0.7.3/lib/mappings.wasm'
})

// deals with parsing error objects and converting them to strings (for repl at least)

let verboseErrors = false
const resolvedErrorPromise = Promise.resolve({ status: 'error' } as Result)

export function parseError(errors: SourceError[], verbose: boolean = verboseErrors): string {
  const errorMessagesArr = errors.map(error => {
    const line = error.location ? error.location.start.line : ''
    const column = error.location ? error.location.start.column : ''
    const explanation = error.explain()

    if (verbose) {
      // TODO currently elaboration is just tagged on to a new line after the error message itself. find a better
github dumberjs / dumber / lib / transform.js View on Github external
const {SourceMapGenerator, SourceMapConsumer} = require('source-map');
const {warn} = require('./log');

if (typeof process === 'undefined' || process.browser) {
  SourceMapConsumer.initialize({
    "lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm"
  });
}

module.exports = function(unit, ...transformers) {
  let p = Promise.resolve(unit);

  for (let i = 0, ii = transformers.length; i < ii; i++) {
    p = p.then(unit =>
      Promise.resolve(transformers[i](unit))
        .then(newUnit => mergeUnit(unit, newUnit))
    );
  }

  return p;
};
github cypress-io / cypress / packages / driver / src / cypress / source_map_utils.js View on Github external
const initialize = (file, sourceMapBase64) => {
  SourceMapConsumer.initialize({
    'lib/mappings.wasm': require('source-map/lib/mappings.wasm'),
  })

  const sourceMap = base64toJs(sourceMapBase64)

  return Promise.resolve(new SourceMapConsumer(sourceMap)).then((consumer) => {
    sourceMapConsumers[file.fullyQualifiedUrl] = consumer

    return consumer
  })
}