Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function combine(bundle) {
bundle.body = new MagicString.Bundle({
separator: '\n\n'
});
// give each module in the bundle a unique name
populateModuleNames(bundle);
// determine which specifiers are imported from
// external modules
populateExternalModuleImports(bundle);
// determine which identifiers need to be replaced
// inside this bundle
populateIdentifierReplacements(bundle);
bundle.exports = resolveExports(bundle);
function createBundle(
modules: { dep: string; file: MagicString; hasInvalidShim: boolean }[],
) {
const bundle = new Bundle();
const depsWithInvalidShims: string[] = [];
bundle.prepend(
`/* Generated by @magento/baler - ${new Date().toISOString()} */\n\n`,
);
for (const { dep, file, hasInvalidShim } of modules) {
bundle.addSource({
filename: `../${dep}.js`,
content: file,
});
if (hasInvalidShim) depsWithInvalidShims.push(dep);
}
return { bundle, depsWithInvalidShims };
}
render ( options = {} ) {
const format = options.format || 'es6';
// Determine export mode - 'default', 'named', 'none'
const exportMode = getExportMode( this, options.exports );
let magicString = new MagicString.Bundle({ separator: '\n\n' });
let usedModules = [];
this.orderedModules.forEach( module => {
const source = module.render( format === 'es6' );
if ( source.toString().length ) {
magicString.addSource( source );
usedModules.push( module );
}
});
const intro = [ options.intro ]
.concat(
this.plugins.map( plugin => plugin.intro && plugin.intro() )
)
.filter( Boolean )
.join( '\n\n' );
preRender(options: OutputOptions, inputBase: string) {
timeStart('render modules', 3);
const magicString = new MagicStringBundle({ separator: options.compact ? '' : '\n\n' });
this.usedModules = [];
this.indentString = options.compact ? '' : getIndentString(this.orderedModules, options);
const n = options.compact ? '' : '\n';
const _ = options.compact ? '' : ' ';
const renderOptions: RenderOptions = {
compact: options.compact as boolean,
dynamicImportFunction: options.dynamicImportFunction as string,
format: options.format as string,
freeze: options.freeze !== false,
indent: this.indentString,
namespaceToStringTag: options.namespaceToStringTag === true,
varOrConst: options.preferConst ? 'const' : 'var'
};
function bundleFiles(files, copyright) {
var bundle = new MagicString.Bundle();
for (var i = 0, len = files.length; i < len; i++) {
bundle.addSource({
filename: files[i],
content: new MagicString( fs.readFileSync(files[i], 'utf8') + '\n\n' )
});
}
bundle.prepend(
copyright + "(function (window, document, undefined) {"
).append("})(window, document);");
return bundle;
}
function bundleFiles(files, copyright) {
var bundle = new MagicString.Bundle(),
umdTemplate = require(__dirname + "/umd.template.js"),
i = 0;
for (; i < files.length; i += 1) {
bundle.addSource({
filename: files[i],
content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
});
}
bundle.prepend(
copyright + umdTemplate.before
).append(umdTemplate.after);
return bundle;
}
function bundleFiles(files, copyright) {
var bundle = new MagicString.Bundle(),
umdTemplate = require(__dirname + "/umd.template.js"),
i = 0;
for (; i < files.length; i += 1) {
bundle.addSource({
filename: files[i],
content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
});
}
bundle.prepend(
copyright + umdTemplate.before
).append(umdTemplate.after);
return bundle;
}
function bundleFiles(files, copyright) {
var bundle = new MagicString.Bundle(),
umdTemplate = require(__dirname + "/umd.template.js"),
i = 0;
for (; i < files.length; i += 1) {
bundle.addSource({
filename: files[i],
content: new MagicString( fs.readFileSync(files[i], "utf8") + "\n\n" )
});
}
bundle.prepend(
copyright + umdTemplate.before
).append(umdTemplate.after);
return bundle;
}
.then(function(results) {
var iterator = function() { };
if (vinyl.sourceMap) {
var bundle = new MagicString.Bundle();
iterator = function(file, result) {
bundle.addSource({
filename: result.importPath,
content: new MagicString(result.contents)
});
};
}
for (var i = 0; i < results.length; i++) {
var result = results[i];
var index = result.index;
var contents = result.contents;
file[index] = contents;
iterator(file, result);
}
vinyl.contents = new Buffer(file.join(""));
if (vinyl.sourceMap) {