Skip to content

Commit

Permalink
fix: cache for extracted comments (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Sep 15, 2020
1 parent bbfa283 commit 5340814
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/Webpack4Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export default class Webpack4Cache {
input,
inputSourceMap,
extractedComments,
banner,
shebang,
} = cachedResult;

if (map) {
Expand All @@ -70,6 +72,14 @@ export default class Webpack4Cache {
cachedResult.source = new RawSource(code);
}

if (banner) {
cachedResult.source = new ConcatSource(
shebang ? `${shebang}\n` : '',
`/*! ${banner} */\n`,
cachedResult.source
);
}

if (extractedComments) {
cachedResult.extractedCommentsSource = new RawSource(extractedComments);
}
Expand Down Expand Up @@ -105,6 +115,8 @@ export default class Webpack4Cache {
map: cacheData.map,
input: cacheData.input,
inputSourceMap: cacheData.inputSourceMap,
banner: cacheData.banner,
shebang: cacheData.shebang,
};

if (cacheData.extractedCommentsSource) {
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class TerserPlugin {

let output = await cache.get(cacheData, {
RawSource,
ConcatSource,
SourceMapSource,
});

Expand Down Expand Up @@ -433,6 +434,8 @@ class TerserPlugin {
`/*! ${banner} */\n`,
output.source
);
output.banner = banner;
output.shebang = shebang;
}
}

Expand Down
Loading

0 comments on commit 5340814

Please sign in to comment.