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

Commit 2343274

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
fix(index): reduce memory consumption (cacheKey.hash) (#215)
1 parent 7d1b487 commit 2343274

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Diff for: src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Author Tobias Koppers @sokra
44
*/
55

6+
import crypto from 'crypto';
67
import { SourceMapConsumer } from 'source-map';
78
import { SourceMapSource, RawSource, ConcatSource } from 'webpack-sources';
89
import RequestShortener from 'webpack/lib/RequestShortener';
@@ -160,7 +161,7 @@ class UglifyJsPlugin {
160161
'uglifyjs-webpack-plugin': versions.plugin,
161162
'uglifyjs-webpack-plugin-options': this.options,
162163
path: compiler.outputPath ? `${compiler.outputPath}/${file}` : file,
163-
input,
164+
hash: crypto.createHash('md5').update(input).digest('hex'),
164165
});
165166
}
166167

Diff for: test/__snapshots__/cache-options.test.js.snap

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,56 @@ exports[`cache \`true\`: asset manifest.6afe1bc6685e9ab36c1c.js 1`] = `"!functio
2323
exports[`cache \`true\`: cached entry test.js 1`] = `
2424
Array [
2525
"test.js",
26-
"function test(foo) { foo = 1; }",
26+
"46adcef6cf434fbddbc275218b3e093a",
2727
]
2828
`;
2929

3030
exports[`cache \`true\`: cached entry test.js 2`] = `
3131
Array [
3232
"test.js",
33-
"function test(foo) { foo = 1; }",
33+
"46adcef6cf434fbddbc275218b3e093a",
3434
]
3535
`;
3636

3737
exports[`cache \`true\`: cached entry test1.js 1`] = `
3838
Array [
3939
"test1.js",
40-
"function test1(foo) { foo = 1; }",
40+
"6b6ccbbe331608e36cded49fd411c373",
4141
]
4242
`;
4343

4444
exports[`cache \`true\`: cached entry test1.js 2`] = `
4545
Array [
4646
"test1.js",
47-
"function test1(foo) { foo = 1; }",
47+
"6b6ccbbe331608e36cded49fd411c373",
4848
]
4949
`;
5050

5151
exports[`cache \`true\`: cached entry test2.js 1`] = `
5252
Array [
5353
"test2.js",
54-
"function test2(foo) { foo = 1; }",
54+
"975b72a762ef408dcf46a574fead7e60",
5555
]
5656
`;
5757

5858
exports[`cache \`true\`: cached entry test2.js 2`] = `
5959
Array [
6060
"test2.js",
61-
"function test2(foo) { foo = 1; }",
61+
"975b72a762ef408dcf46a574fead7e60",
6262
]
6363
`;
6464

6565
exports[`cache \`true\`: cached entry test3.js 1`] = `
6666
Array [
6767
"test3.js",
68-
"function test3(foo) { foo = 1; }",
68+
"fa894d635dc764c42fb6b1d4e3f6ed2b",
6969
]
7070
`;
7171

7272
exports[`cache \`true\`: cached entry test3.js 2`] = `
7373
Array [
7474
"test3.js",
75-
"function test3(foo) { foo = 1; }",
75+
"fa894d635dc764c42fb6b1d4e3f6ed2b",
7676
]
7777
`;
7878

Diff for: test/cache-options.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ describe('when options.cache', () => {
243243
// eslint-disable-next-line no-new-func
244244
const cacheEntryOptions = new Function(`'use strict'\nreturn ${cacheEntry}`)();
245245

246-
expect([cacheEntryOptions.path, cacheEntryOptions.input])
246+
expect([cacheEntryOptions.path, cacheEntryOptions.hash])
247247
.toMatchSnapshot(`cache \`true\`: cached entry ${cacheEntryOptions.path}`);
248248
});
249249

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

392-
expect([cacheEntryOptions.path, cacheEntryOptions.input])
392+
expect([cacheEntryOptions.path, cacheEntryOptions.hash])
393393
.toMatchSnapshot(`cache \`true\`: cached entry ${cacheEntryOptions.path}`);
394394
});
395395

0 commit comments

Comments
 (0)