Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (grunt.util._.isObject(options.beautify)) {
// beautify options sent as an object are merged
// with outputOptions and passed to the OutputStream
grunt.util._.extend(outputOptions, options.beautify);
} else {
outputOptions.beautify = true;
}
}
if (options.sourceMap) {
var sourceMapIn;
if (options.sourceMapIn) {
sourceMapIn = grunt.file.readJSON(options.sourceMapIn);
}
outputOptions.source_map = UglifyJS.SourceMap({
file: dest,
root: options.sourceMapRoot,
orig: sourceMapIn
});
}
return outputOptions;
};
}
}
})
deheredoc(ast)
ast.figure_out_scope()
const compressed = ast.transform(compressor)
if (mangle) {
compressed.figure_out_scope()
compressed.compute_char_frequency()
compressed.mangle_names()
}
const outSourceMap = new UglifyJS.SourceMap({
file: `${id}.js`,
root: sourceRoot
})
const stream = new UglifyJS.OutputStream({
ascii_only: true,
screw_ie8: false,
source_map: outSourceMap
})
/* eslint-enable camelcase */
compressed.print(stream)
const js = stream.toString()
const map = JSON.parse(outSourceMap.toString())
const generator = new SourceMapGenerator.fromSourceMap(new SourceMapConsumer(map))
sourceMaps.forEach(function(sourceMap) {
ast.figure_out_scope(options.mangle || {});
ast.compute_char_frequency(options.mangle || {});
ast.mangle_names(options.mangle || {});
if(options.mangle && options.mangle.props) {
uglify.mangle_properties(ast, options.mangle.props);
}
}
let output = {};
output.comments = Object.prototype.hasOwnProperty.call(options, "comments") ? options.comments : /^\**!|@preserve|@license/;
output.beautify = options.beautify;
for(let k in options.output) {
output[k] = options.output[k];
}
let map;
if(options.sourceMap) {
map = uglify.SourceMap({ // eslint-disable-line new-cap
file: file,
root: ""
});
output.source_map = map; // eslint-disable-line camelcase
}
let stream = uglify.OutputStream(output); // eslint-disable-line new-cap
ast.print(stream);
if(map) map = map + "";
stream = stream + "";
asset.__UglifyJsPlugin = compilation.assets[file] = (map ?
new SourceMapSource(stream, file, JSON.parse(map), input, inputSourceMap) :
new RawSource(stream));
if(warnings.length > 0) {
compilation.warnings.push(new Error(file + " from UglifyJs\n" + warnings.join("\n")));
}
} catch(err) {
var compressed_ast = toplevel.transform( compressor );
// Mangling
compressed_ast.figure_out_scope();
compressed_ast.compute_char_frequency();
compressed_ast.mangle_names();
// Output
var source_map_options = {
file: 'bravey.min.js',
root: 'src'
};
var source_map = uglify.SourceMap( source_map_options )
var stream = uglify.OutputStream( {
source_map: source_map,
comments: new RegExp( LICENSE )
} );
compressed_ast.print( stream );
var code = stream.toString();
fs.writeFileSync( output, code + sourcemapping, 'utf8' );
if ( args.sourcemaps ) {
fs.writeFileSync( sourcemap, source_map.toString(), 'utf8' );
}
// Mangle
root.figure_out_scope({ screw_ie8: true });
root.compute_char_frequency();
root.mangle_names({ screw_ie8: true });
root = UglifyJS.mangle_properties(root, {
regex: /^_/
});
// Output
var firstLicenseHeaderFound = false; // To detect and preserve the first license header
var output = {
source_map: UglifyJS.SourceMap({
file: path.basename(sourceMapFile.path),
orig: sourceMapFile.contents.toString()
}),
ascii_only: true,
comments: function (node, comment) {
if (!firstLicenseHeaderFound && comment.value.indexOf("Copyright") !== -1) {
firstLicenseHeaderFound = true;
return true;
}
return false;
},
screw_ie8: true
};
return mapEachResource(function(resource) {
// TODO: filename, based on output spec? on input filename?
var minResource = resource.withTransformation('minimised', 'min');
var mapResource = minResource.withExtension('map');
var sourceMapData = UglifyJS.SourceMap();
var result = UglifyJS.minify(resource.path().absolute(), {
outSourceMap: mapResource.filename(),
source_map: sourceMapData
});
return [
minResource.withData(result.code),
mapResource.withData(sourceMapData.toString())
];
});
};
if(options.mangle !== false) {
ast.figure_out_scope(options.mangle || {});
ast.compute_char_frequency(options.mangle || {});
ast.mangle_names(options.mangle || {});
if(options.mangle && options.mangle.props) {
uglify.mangle_properties(ast, options.mangle.props);
}
}
var output = {};
output.comments = Object.prototype.hasOwnProperty.call(options, "comments") ? options.comments : /^\**!|@preserve|@license/;
output.beautify = options.beautify;
for(var k in options.output) {
output[k] = options.output[k];
}
if(options.sourceMap !== false) {
var map = uglify.SourceMap({ // eslint-disable-line new-cap
file: file,
root: ""
});
output.source_map = map; // eslint-disable-line camelcase
}
var stream = uglify.OutputStream(output); // eslint-disable-line new-cap
ast.print(stream);
if(map) map = map + "";
stream = stream + "";
asset.__UglifyJsPlugin = compilation.assets[file] = (map ?
new SourceMapSource(stream, file, JSON.parse(map), input, inputSourceMap) :
new RawSource(stream));
if(warnings.length > 0) {
compilation.warnings.push(new Error(file + " from UglifyJs\n" + warnings.join("\n")));
}
} catch(err) {
outputOptions.beautify = true;
}
}
if (options.screwIE8) {
outputOptions.screw_ie8 = true;
}
if (options.sourceMap) {
var destBasename = path.basename(dest);
var sourceMapIn;
if (options.sourceMapIn) {
sourceMapIn = grunt.file.readJSON(options.sourceMapIn);
}
outputOptions.source_map = UglifyJS.SourceMap({
file: destBasename,
root: options.sourceMapRoot,
orig: sourceMapIn
});
if (options.sourceMapIncludeSources && sourceMapIn && sourceMapIn.sourcesContent) {
sourceMapIn.sourcesContent.forEach(function(content, idx) {
outputOptions.source_map.get().setSourceContent(sourceMapIn.sources[idx], content);
});
}
if (options.sourceMapIn) {
outputOptions.source_map.get()._file = destBasename;
}
}
if (!_.isUndefined(options.indentLevel)) {
}).then(function (bundle) {
var transpiled = bundle.generate({
format: 'umd',
sourceMap: true,
sourceMapFile: pkg.name + '.js',
moduleName: 'L.esri.Geocoding',
globals: {
'esri-leaflet': 'L.esri'
}
});
var sourceMap = UglifyJS.SourceMap({
file: pkg.name + '.js',
root: process.cwd(),
orig: JSON.parse(transpiled.map)
});
var stream = UglifyJS.OutputStream({
preamble: copyright,
source_map: sourceMap
});
UglifyJS.parse(transpiled.code).print(stream);
var code = stream.toString();
var map = sourceMap.toString().replace(new RegExp(path.join(process.cwd(), 'src'), 'g'), '../src');
fs.writeFileSync(path.join('dist', pkg.name + '.js'), code + '\n//# sourceMappingURL=./' + pkg.name + '.js.map');