8000 fix discussions · webpack/webpack@aa76e82 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa76e82

Browse files
committed
fix discussions
1 parent 83fea25 commit aa76e82

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/dependencies/JsonExportsDependency.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ class JsonExportsDependency extends NullDependency {
4949
*/
5050
constructor(data) {
5151
super();
52-
this.data = data && data.get();
53-
this._hashUpdate = undefined;
52+
this.data = data;
5453
}
5554

5655
get type() {
@@ -64,7 +63,7 @@ class JsonExportsDependency extends NullDependency {
6463
*/
6564
getExports(moduleGraph) {
6665
return {
67-
exports: getExportsFromData(this.data),
66+
exports: getExportsFromData(this.data && this.data.get()),
6867
dependencies: undefined
6968
};
7069
}
@@ -76,10 +75,7 @@ class JsonExportsDependency extends NullDependency {
7675
* @returns {void}
7776
*/
7877
updateHash(hash, context) {
79-
if (this._hashUpdate === undefined) {
80-
this._hashUpdate = this.data ? JSON.stringify(this.data) : "undefined";
81-
}
82-
hash.update(this._hashUpdate);
78+
this.data.updateHash(hash);
8379
}
8480

8581
serialize(context) {

lib/json/JsonData.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ class JsonData {
2424
}
2525
return this._data;
2626
}
27+
28+
updateHash(hash) {
29+
if (this._buffer === undefined && this._data !== undefined) {
30+
this._buffer = Buffer.from(JSON.stringify(this._data));
31+
}
32+
33+
if (this._buffer) return hash.update(this._buffer);
34+
}
2735
}
2836

2937
register(JsonData, "webpack/lib/json/JsonData", null, {

0 commit comments

Comments
 (0)
0