
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@a-la/source-map-generator
Advanced tools
[fork] Generates Source Maps, Works With Google Closure Compiler.
@a-la/source-map-generator is a fork of Mozilla/SourceMap that Generates Source Maps and Works With Google Closure Compiler. It was rewritten in ES6 syntax and externs for GCC were provided for compilation.
yarn add @a-la/source-map-generator
The package is available by importing its default function:
import sourceMapGenerator from '@a-la/source-map-generator'
class SourceMapGeneratorAn instance of the SourceMapGenerator represents a source map which is being built incrementally.
Removed Methods For Now
static fromSourceMapapplySourceMapconstructor(conf: Config,): SourceMapGeneratorThe constructor method is called to create a new source map.
_sourceMapGenerator.Config: Options for the program.
| Name | Type | Description | Default |
|---|---|---|---|
| file | string | The filename of the generated source. | - |
| sourceRoot | string | A root for all relative URLs in this source map. | - |
| skipValidation | boolean | When true, disables validation of mappings as they are added. This can improve performance but should be used with discretion, as a last resort. Even then, one should avoid using this flag when running tests, if possible. | false |
import SourceMapGenerator from '@a-la/source-map-generator'
import { readFileSync } from 'fs'
const file = `${readFileSync(__filename)}`
const gen = new SourceMapGenerator({
file: 'example/index.js',
})
/**
* Generate the source map for the file, keeping all positions as they are.
*
* The first two rules will update inline and block comments to not have any tokens in them.
* The third rule will break each line into tokens and add mappings.
*/
const linesInSource = file
.replace(/\/\*(?:[\s\S]+?)\*\//g, (match, pos) => {
const next = file[pos + match.length]
if (next == '\n') return '\n'.repeat(match.split('\n').length - 1)
const lines = match.split('\n')
const lastLineI = lines.length - 1
const lastLine = lines[lastLineI]
const ss = ' '.repeat(lastLine.length)
const ws = '\n'.repeat(lastLineI)
return `${ws}${ss}`
})
.replace(/\/\/(.+)/gm, (match) => {
return ' '.repeat(match.length)
})
.split('\n')
linesInSource.forEach((l, i) => {
const line = i + 1
l
.replace(/(?:(?:\s+)|(?:[$_\w\d]+)|.)/g, (match, column) => {
if (column == 0 && /^\s+$/.test(match)) return
const generated = {
line,
column,
}
const m = {
generated,
source: __filename,
original: generated,
}
gen.addMapping(m)
})
})
gen.setSourceContent(__filename, file)
const sourceMap = gen.toJSON()
console.log(sourceMap)
{ version: 3,
sources: [ '/Users/zavr/a-la/source-map-generator/example/index.js' ],
names: [],
mappings: 'AAAA,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;AACtC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;;AAEhC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;;AAEzC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC;EACjC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1B,CAAC;;;;;;;AAOD,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;EACpB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;IACpC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;IAEjE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,KAAK,CAAC,SAAS,CAAC,CAAC,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,CAAC,CAAC,CAAC;MACxC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAChB,IAAI;QACJ,MAAM;MACR;MACA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACR,SAAS;QACT,MAAM,CAAC,CAAC,UAAU;QAClB,QAAQ,CAAC,CAAC,SAAS;MACrB;MACA,GAAG,CAAC,UAAU,CAAC,CAAC;IAClB,CAAC;AACL,CAAC;AACD,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,IAAI;AACrC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;AAC7B,OAAO,CAAC,GAAG,CAAC,SAAS',
file: 'example/index.js',
sourcesContent:
[ 'import SourceMapGenerator from \'../src\'\nimport { readFileSync } from \'fs\'\n\nconst file = `${readFileSync(__filename)}`\n\nconst gen = new SourceMapGenerator({\n file: \'example/index.js\',\n})\n/**\n * Generate the source map for the file, keeping all positions as they are.\n *\n * The first two rules will update inline and block comments to not have any tokens in them.\n * The third rule will break each line into tokens and add mappings.\n */\nconst linesInSource = file\n .replace(/\\/\\*(?:[\\s\\S]+?)\\*\\//g, (match, pos) => {\n const next = file[pos + match.length]\n if (next == \'\\n\') return \'\\n\'.repeat(match.split(\'\\n\').length - 1)\n\n const lines = match.split(\'\\n\')\n const lastLineI = lines.length - 1\n const lastLine = lines[lastLineI]\n const ss = \' \'.repeat(lastLine.length)\n const ws = \'\\n\'.repeat(lastLineI)\n return `${ws}${ss}`\n })\n .replace(/\\/\\/(.+)/gm, (match) => {\n return \' \'.repeat(match.length)\n })\n .split(\'\\n\')\nlinesInSource.forEach((l, i) => {\n const line = i + 1\n l\n .replace(/(?:(?:\\s+)|(?:[$_\\w\\d]+)|.)/g, (match, column) => {\n if (column == 0 && /^\\s+$/.test(match)) return\n const generated = {\n line,\n column,\n }\n const m = {\n generated,\n source: __filename,\n original: generated,\n }\n gen.addMapping(m)\n })\n})\ngen.setSourceContent(__filename, file)\nconst sourceMap = gen.toJSON()\nconsole.log(sourceMap)' ] }
Original Authors: Mozilla
| © Art Deco for À La Mode 2019 |
| Tech Nation Visa Sucks |
|---|
FAQs
[fork] Generates Source Maps, Works With Google Closure Compiler.
The npm package @a-la/source-map-generator receives a total of 6 weekly downloads. As such, @a-la/source-map-generator popularity was classified as not popular.
We found that @a-la/source-map-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.