Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return throughObj((file, encoding, callback) => {
gutil.log(`Generating treemap for ${gutil.colors.magenta(file.relative)}`);
if (typeof loadSourceMap !== 'undefined') {
const data = loadSourceMap(file.path, `${file.path}.map`);
const sizes = computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const asizes = adjustSourcePaths(sizes, true, '', '');
const tsv = 'Source\tSize\n' + Object.keys(asizes).map(k => `${k}\t${asizes[k]}`).join('\n');
file.contents = new Buffer(tsv);
file.path = gutil.replaceExtension(file.path, '.tsv');
return callback(null, file);
}
gutil.log('Running source-map-explorer in shell');
execa.stdout('source-map-explorer', ['--tsv', file.path, `${file.path}.map`])
.then(result => {
file.contents = new Buffer(result);
file.path = gutil.replaceExtension(file.path, '.tsv');
callback(null, file);
})
.catch(err => {
console.error(err); // eslint-disable-line no-console
async (bundle: string): Promise => {
try {
// SME will complain if sourcemaps contain just one file, but we don't control that
// in bundles generated by 3rd parties like webpack runtime or Ionic
const explored = await explore(bundle);
return {
bundle,
...explored,
};
} catch {
return false;
}
},
),
var getUsed = function(input) {
//browserify + derequire
var cmd = browserify + ' ' + input + ' --debug -t [ babelify ]'
cmd += ' >> ' + output
exec(cmd)
srcMapExplorer(output, {
json: true,
}).then(files => {
console.log(files)
files = Object.keys(files)
files = files.map(function(str) {
str = path.resolve(str)
return str
})
//clean it up a bit
files = files.filter(function(str) {
if (!str) {
return false
}
if (/_prelude.js$/.test(str)) {
return false
files.forEach((f) => {
console.error('> processing', f);
const data = sourcemapExplorer.loadSourceMap(f, `${f}.map`);
const sizes = sourcemapExplorer.computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const files = sourcemapExplorer.adjustSourcePaths(sizes.files, false);
updateThirdPartyModules(modules, files);
});
files.forEach((f) => {
console.error('> processing', f);
const data = sourcemapExplorer.loadSourceMap(f, `${f}.map`);
const sizes = sourcemapExplorer.computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const files = sourcemapExplorer.adjustSourcePaths(sizes.files, false);
updateThirdPartyModules(modules, files);
});
files.forEach((f) => {
console.error('> processing', f);
const data = sourcemapExplorer.loadSourceMap(f, `${f}.map`);
const sizes = sourcemapExplorer.computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const files = sourcemapExplorer.adjustSourcePaths(sizes.files, false);
updateThirdPartyModules(modules, files);
});
return throughObj((file, encoding, callback) => {
gutil.log(`Generating treemap for ${gutil.colors.magenta(file.relative)}`);
if (typeof loadSourceMap !== 'undefined') {
const data = loadSourceMap(file.path, `${file.path}.map`);
const sizes = computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const asizes = adjustSourcePaths(sizes, true, '', '');
const tsv = 'Source\tSize\n' + Object.keys(asizes).map(k => `${k}\t${asizes[k]}`).join('\n');
file.contents = new Buffer(tsv);
file.path = gutil.replaceExtension(file.path, '.tsv');
return callback(null, file);
}
gutil.log('Running source-map-explorer in shell');
execa.stdout('source-map-explorer', ['--tsv', file.path, `${file.path}.map`])
.then(result => {
file.contents = new Buffer(result);
file.path = gutil.replaceExtension(file.path, '.tsv');
callback(null, file);
})
.catch(err => {
return throughObj((file, encoding, callback) => {
gutil.log(`Generating treemap for ${gutil.colors.magenta(file.relative)}`);
if (typeof loadSourceMap !== 'undefined') {
const data = loadSourceMap(file.path, `${file.path}.map`);
const sizes = computeGeneratedFileSizes(data.mapConsumer, data.jsData);
const asizes = adjustSourcePaths(sizes, true, '', '');
const tsv = 'Source\tSize\n' + Object.keys(asizes).map(k => `${k}\t${asizes[k]}`).join('\n');
file.contents = new Buffer(tsv);
file.path = gutil.replaceExtension(file.path, '.tsv');
return callback(null, file);
}
gutil.log('Running source-map-explorer in shell');
execa.stdout('source-map-explorer', ['--tsv', file.path, `${file.path}.map`])
.then(result => {
file.contents = new Buffer(result);
file.path = gutil.replaceExtension(file.path, '.tsv');
callback(null, file);
})