
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
source-map-concat
Advanced tools
Concatenate files with source maps.
var fs = require("fs")
var path = require("path")
var concat = require("source-map-concat")
var resolveSourceMapSync = require("source-map-resolve").resolveSourceMapSync
var createDummySourceMap = require("source-map-dummy")
var jsFiles = ["foo.js", "subdir/bar.js", "../baz.js"]
jsFiles = jsFiles.map(function(file) {
return {
source: file,
code: fs.readFileSync(file).toString()
}
})
jsFiles.forEach(function(file) {
var previousMap = resolveSourceMapSync(file.code, file.source, fs.readFileSync)
if (previousMap) {
file.map = previousMap.map
file.sourcesRelativeTo = previousMap.sourcesRelativeTo
} else {
file.map = createDummySourceMap(file.code, {source: file.source, type: "js"})
}
})
function wrap(node, file) {
node.prepend("void function(){\n// File: " + file.source + "\n")
node.add("}();")
}
var output = "subdir/bundle.js"
var concatenated = concat(jsFiles, {
delimiter: "\n",
process: wrap,
mapPath: output + ".map"
})
concatenated.prepend("/* Bruce Banner */\n")
concatenated.add("\n/* Footer */")
var result = concatenated.toStringWithSourceMap({
file: path.basename(output)
})
fs.writeFileSync(output, result.code)
fs.writeFileSync(output + ".map", result.map.toString())
npm install source-map-concat
var concat = require("source-map-concat")
concat(files, options)
files
is an array of objects with the following properties:
code
: The contents of the file, as a string.map
: The source map of the file, if any, as an object, a string or anything
with a .toJSON()
method (such as a SourceMapGenerator
). It could be
taken straight from a compiler, be resolved using source-map-resolve or
created using source-map-dummy.sourcesRelativeTo
: A path that file.map.sources
are relative to. Defaults
to .
.options
:
delimiter
: A string to insert between each file.process(node, file, index)
: A function to call on each file in files
.
node
is a SourceNode
. You could use this to wrap JavaScript files in
IIFEs, for example.mapPath
: The path to where you intend to write the source map of the
produced concatenated file. Defaults to .
.The files in files
will be concatenated into a SourceNode
which is
returned. You may then modify this source node if you wish (node.add(...)
for
example). When you’re done, call node.toStringWithSourceMap()
, which returns
an object with a code
property containing the concatenated code, and a map
property containing the source map.
Version 1.0.0 (2015-02-26) ###
FAQs
Concatenate files with source maps.
The npm package source-map-concat receives a total of 374 weekly downloads. As such, source-map-concat popularity was classified as not popular.
We found that source-map-concat 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.