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();
}
values.splice(3, 0,
'arguments[3]','arguments[4]',
'arguments[5]','arguments[6]'
);
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();
}
values.splice(3, 0,
'arguments[3]','arguments[4]',
'arguments[5]','arguments[6]'
);
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();
}
values.splice(3, 0,
'arguments[3]','arguments[4]',
'arguments[5]','arguments[6]'
);
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();
}
].join('\n');
hasComment = true; // now we have base64 comment
} catch (err) {
// Don't attempt to handle source maps for this file,
// it is most likely a comment about source maps and not
// a *real* source map comment!
}
}
var wrapScript = moduleWrap(script);
// do not make any more alterations to the source maps
if (hasComment || hasMapFile) return wrapScript;
// Otherwise, if no source maps exist, we can generate a new one
var sourceMap = combineSourceMap.create(sourceFileName, basedir)
.addFile({ sourceFile: sourceFile, source: original });
return [
combineSourceMap.removeComments(wrapScript),
sourceMap.comment()
].join('\n');
};
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);
});
});
source: "function b()\n{\n\tconsole.log(\"b1\");\n\tconsole.log(\"b2\");\n\tconsole.log(\"b3\");\n}" + "\n" + bComment
, sourceFile: "b.js"
};
var cFile = {
source: "function c()\n{\n\tconsole.log(\"c1\");\n\tconsole.log(\"c2\");\n\tconsole.log(\"c3\");\n}" + "\n" + cComment
, sourceFile: "c.js"
};
var dFile = {
source: "function d()\n{\n\tconsole.log(\"d1\");\n\tconsole.log(\"d2\");\n\tconsole.log(\"d3\");\n}" + "\n" + dComment
, sourceFile: "d.js"
};
var offset = { line: 2 };
var base64 = combine
.create("bundle.js")
.addFile(aFile, offset)
.addFile(bFile, { line: offset.line + 8 })
//.addFile(cFile, { line: offset.line + 16 })
//.addFile(dFile, { line: offset.line + 24 })
.base64();
console.log(base64);
//var sm = convert.fromBase64(base64).toObject();
//console.log("Combined source maps:\n", sm);
//console.log("\nMappings:\n", sm.mappings);
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;
}