How to use the convert-source-map.fromBase64 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 thlorenz / combine-source-map / test / combine-source-map.js View on Github external
file: 'a/b/two.js',
    sourcesContent: [ 'console.log(2);\n' ]
  };

  var base64 = combine.create()
    .addFile({
      source: 'console.log(1);\n' + convert.fromObject(gen1Map).toComment(),
      sourceFile: 'a/b/one.js'
    })
    .addFile({
      source: 'console.log(2);\n' + convert.fromObject(gen2Map).toComment(),
      sourceFile: 'a/b/two.js'
    }, {line: 1})
    .base64()

  var sm = convert.fromBase64(base64).toObject();

  t.deepEqual(sm.sources, ['a/b/one.js', 'a/b/two.js'],
    'include the correct source');

  t.deepEqual(
      mappingsFromMap(sm)
    , [ { original: { column: 0, line: 1 },
        generated: { column: 0, line: 1 },
        source: 'a/b/one.js',
        name: null },
      { original: { column: 0, line: 1 },
        generated: { column: 0, line: 2 },
        source: 'a/b/two.js',
        name: null } ], 'should properly map multiple files');
  t.end()
});
github jamesshore / lets_code_javascript / node_modules / combine-source-map / example / two-files.js View on Github external
source: '(function() {\n\n  console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
  , sourceFile: 'foo.js'
};
var barFile = {
    source: '(function() {\n\n  console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
  , sourceFile: 'bar.js'
};

var offset = { line: 2 };
var base64 = combine
  .create('bundle.js')
  .addFile(fooFile, offset)
  .addFile(barFile, { line: offset.line + 8 })
  .base64();

var sm = convert.fromBase64(base64).toObject();
console.log('Combined source maps:\n', sm);
console.log('\nMappings:\n', sm.mappings);
github jamesshore / lets_code_javascript / node_modules / combine-source-map / example / two-files-short.js View on Github external
source: '(function() {\n\n  console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
  , sourceFile: 'foo.js'
};
var barFile = {
    source: '(function() {\n\n  console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
  , sourceFile: 'bar.js'
};

var offset = { line: 2 };
var base64 = combine
  .create('bundle.js')
  .addFile(fooFile, offset)
  .addFile(barFile, { line: offset.line + 8 })
  .base64();

var sm = convert.fromBase64(base64).toObject();
console.log(sm);
github thlorenz / combine-source-map / example / two-files.js View on Github external
source: '(function() {\n\n  console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
  , sourceFile: 'foo.js'
};
var barFile = {
    source: '(function() {\n\n  console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
  , sourceFile: 'bar.js'
};

var offset = { line: 2 };
var base64 = combine
  .create('bundle.js')
  .addFile(fooFile, offset)
  .addFile(barFile, { line: offset.line + 8 })
  .base64();

var sm = convert.fromBase64(base64).toObject();
console.log('Combined source maps:\n', sm);
console.log('\nMappings:\n', sm.mappings);
github bokeh / bokeh / bokehjs / make / linker.ts View on Github external
const source = combine.removeComments(source_with_sourcemap)
        sources += source
        sourcemap.addFile({source: source_with_sourcemap, sourceFile: file}, {line})
        line += newlines(source)

        const end = `${last ? "" : ","}\n`
        sources += end
        line += newlines(end)
      }

      const aliases = JSON.stringify(to_obj(exported))
      const entry_id = module_map.get(entry)!
      const parent_require = this.builtins ? `typeof "require" !== "undefined" && require` : "null"
      sources += `${suffix}, ${aliases}, ${entry_id}, ${parent_require});\n})\n`

      const obj = convert.fromBase64(sourcemap.base64()).toObject()
      return new Bundle(sources, obj, exported, bundled)
    }
github enyojs / enyo-dev / lib / Packager / lib / pack-bundle-stream / lib / BundleSource.js View on Github external
proto.compileMap = function () {
	if (this.map) {
		if (this.log()) this.log('compiling the sourceMap data');
		this.sourceMap = convert.fromBase64(this.map.base64()).toJSON();
		this.sourceMapFile = this.bundle.name + '.js.map';
		this.sourceMapPragma = '\n//# sourceMappingURL=' + this.sourceMapFile;
	}
};
github enyojs / enyo-dev / lib / Packager / lib / pack-bundle-stream / index.js View on Github external
beautify: false,
						semicolons: false
					}
				}).code;
			
				log.info({bundle: bundle.name}, 'done uglifying');
			
			} catch (e) {
				utils.streamError(stream,
					'UglifyJS error while parsing "%s"\noriginal: %s', bundle.name, e.toString()
				);
			}
		}
		bundle.contents = bundleSrc;
		if (devMode && opts.sourceMaps) {
			bundle.sourceMap = convert.fromBase64(sourceMap.base64()).toJSON();
			bundle.sourceMapFile = bundle.name + '.js.map';
			bundle.contents += ('\n//# sourceMappingURL=' + bundle.sourceMapFile);
		}
	}
	return bundle;
};
github bokeh / bokeh / bokehjs / src / compiler / linker.ts View on Github external
const source_with_sourcemap = minified ? artifact.code.min_source : artifact.code.source
      const source = combine.removeComments(source_with_sourcemap).trimRight()
      sources += source
      sourcemap.addFile({source: source_with_sourcemap, sourceFile: module.file}, {line})
      line += newlines(source)

      const end = ",\n"
      sources += end
      line += newlines(end)
    }

    const aliases_json = JSON.stringify(to_obj(aliases))
    const externals_json = JSON.stringify(to_obj(externals))
    sources += `${suffix}, ${safe_id(entry)}, ${aliases_json}, ${externals_json});\n})\n`

    const source_map = convert.fromBase64(sourcemap.base64()).toObject()
    return new Artifact(sources, source_map, aliases)
  }
}