Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
fix(index): reduce memory consumption (cacheKey.hash) (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Jan 29, 2018
1 parent 7d1b487 commit 2343274
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -3,6 +3,7 @@
Author Tobias Koppers @sokra
*/

import crypto from 'crypto';
import { SourceMapConsumer } from 'source-map';
import { SourceMapSource, RawSource, ConcatSource } from 'webpack-sources';
import RequestShortener from 'webpack/lib/RequestShortener';
Expand Down Expand Up @@ -160,7 +161,7 @@ class UglifyJsPlugin {
'uglifyjs-webpack-plugin': versions.plugin,
'uglifyjs-webpack-plugin-options': this.options,
path: compiler.outputPath ? `${compiler.outputPath}/${file}` : file,
input,
hash: crypto.createHash('md5').update(input).digest('hex'),
});
}

Expand Down
16 changes: 8 additions & 8 deletions test/__snapshots__/cache-options.test.js.snap
Expand Up @@ -23,56 +23,56 @@ exports[`cache \`true\`: asset manifest.6afe1bc6685e9ab36c1c.js 1`] = `"!functio
exports[`cache \`true\`: cached entry test.js 1`] = `
Array [
"test.js",
"function test(foo) { foo = 1; }",
"46adcef6cf434fbddbc275218b3e093a",
]
`;

exports[`cache \`true\`: cached entry test.js 2`] = `
Array [
"test.js",
"function test(foo) { foo = 1; }",
"46adcef6cf434fbddbc275218b3e093a",
]
`;

exports[`cache \`true\`: cached entry test1.js 1`] = `
Array [
"test1.js",
"function test1(foo) { foo = 1; }",
"6b6ccbbe331608e36cded49fd411c373",
]
`;

exports[`cache \`true\`: cached entry test1.js 2`] = `
Array [
"test1.js",
"function test1(foo) { foo = 1; }",
"6b6ccbbe331608e36cded49fd411c373",
]
`;

exports[`cache \`true\`: cached entry test2.js 1`] = `
Array [
"test2.js",
"function test2(foo) { foo = 1; }",
"975b72a762ef408dcf46a574fead7e60",
]
`;

exports[`cache \`true\`: cached entry test2.js 2`] = `
Array [
"test2.js",
"function test2(foo) { foo = 1; }",
"975b72a762ef408dcf46a574fead7e60",
]
`;

exports[`cache \`true\`: cached entry test3.js 1`] = `
Array [
"test3.js",
"function test3(foo) { foo = 1; }",
"fa894d635dc764c42fb6b1d4e3f6ed2b",
]
`;

exports[`cache \`true\`: cached entry test3.js 2`] = `
Array [
"test3.js",
"function test3(foo) { foo = 1; }",
"fa894d635dc764c42fb6b1d4e3f6ed2b",
]
`;

Expand Down
4 changes: 2 additions & 2 deletions test/cache-options.test.js
Expand Up @@ -243,7 +243,7 @@ describe('when options.cache', () => {
// eslint-disable-next-line no-new-func
const cacheEntryOptions = new Function(`'use strict'\nreturn ${cacheEntry}`)();

expect([cacheEntryOptions.path, cacheEntryOptions.input])
expect([cacheEntryOptions.path, cacheEntryOptions.hash])
.toMatchSnapshot(`cache \`true\`: cached entry ${cacheEntryOptions.path}`);
});

Expand Down Expand Up @@ -389,7 +389,7 @@ describe('when options.cache', () => {
// eslint-disable-next-line no-new-func
const cacheEntryOptions = new Function(`'use strict'\nreturn ${cacheEntry}`)();

expect([cacheEntryOptions.path, cacheEntryOptions.input])
expect([cacheEntryOptions.path, cacheEntryOptions.hash])
.toMatchSnapshot(`cache \`true\`: cached entry ${cacheEntryOptions.path}`);
});

Expand Down

0 comments on commit 2343274

Please sign in to comment.