Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
wrappedSource = '(function (' + names.join(',') + '){\n'
+ src + '\n}).call(this,' + values.join(',') + ')';
}
// Generate source maps if wanted. Including the right offset for
// the wrapped source.
if (!opts.debug) {
return wrappedSource;
}
var sourceFile = path.relative(opts.basedir, file)
.replace(/\\/g, '/');
var sourceMap = combineSourceMap.create().addFile(
{ sourceFile: sourceFile, source: src},
{ line: 1 });
return combineSourceMap.removeComments(wrappedSource) + "\n"
+ sourceMap.comment();
}
);
wrappedSource = '(function (' + names.join(',') + '){\n'
+ src + '\n}).call(this,' + values.join(',') + ')';
}
// Generate source maps if wanted. Including the right offset for
// the wrapped source.
if (!opts.debug) {
return wrappedSource;
}
var sourceFile = path.relative(opts.basedir, file)
.replace(/\\/g, '/');
var sourceMap = combineSourceMap.create().addFile(
{ sourceFile: sourceFile, source: src},
{ line: 1 });
return combineSourceMap.removeComments(wrappedSource) + "\n"
+ sourceMap.comment();
}
it("then the bundler generates the correct result", function() {
var expected = (
`require=_bb$iter=(${BUNDLE_MODULE_LOADER})({
${wrapModule(input, 1, {"./X": 2})},
${wrapModule(dep1, 2)}
},[1]);
`);
expect(combineSourceMap.removeComments(result)).to.equal(expected);
});
});
function wrapSimple(src) {
return 'function(require,module,exports){\n'
+ combineSourceMap.removeComments(src)
+ '\n}';
}
public removeSourceMapComment(queued: Queued): string {
return queued.emitOutput.sourceMapText ?
combineSourceMap.removeComments(queued.emitOutput.outputText) :
queued.emitOutput.outputText;
}
function wrapModule(row, deps) {
return new Buffer([
'\nloadjs.d("',
row.id,
'",function(require,module,exports){\n',
combineSourceMap.removeComments(row.source),
'\n},{',
deps,
'});\n'
].join(''));
}
map = convertSourceMap.fromJSON(mapJson);
}
else {
map = convertSourceMap.fromComment(commentMatch[0]);
}
if (!map.getProperty("sourcesContent")) {
var sourcesContent_1 = [];
map.getProperty("sources").forEach(function (source) {
var sourceFilename = path.join(dirname_1, source);
var sourceContent = fs.readFileSync(sourceFilename, "utf-8");
sourcesContent_1.push(sourceContent);
});
map.addProperty("sourcesContent", sourcesContent_1);
}
this.cleanupSources(map);
bundleItem.source = combineSourceMap.removeComments(bundleItem.source) + map.toComment();
}
};
SourceMap.prototype.cleanupSources = function (map) {
const mod = modules.get(file)!
mod.rewrite_deps(module_map)
mod.transform()
bundled.push(mod)
const id = module_map.get(file)!
if (!mod.is_external)
exported.set(mod.canonical, id)
const start = wrap(id, "")
sources += start
line += newlines(start)
const source_with_sourcemap = mod.source
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)