Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 2d01df9

Browse files
committed
fix: bundle emitted on save without changes
When there are no changes (timestamps are not modified) the chunk is taken from the cache. The cached asset object has the property existsAt set and this will prevent the emit of that chunk - https://github.com/webpack/webpack/blob/4056506488c1e071dfc9a0127daa61bf531170bf/lib/Compiler.js#L326. However when we replace the whole asset, the flag is no longer set and the chunk is emmited every time.
1 parent 0c51911 commit 2d01df9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: plugins/GenerateNativeScriptEntryPointsPlugin.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { convertToUnixPath } = require("../lib/utils");
2-
const { RawSource } = require("webpack-sources");
2+
const { RawSource, ConcatSource } = require("webpack-sources");
33
const { getPackageJson } = require("../projectHelpers");
44
const { SNAPSHOT_ENTRY_NAME } = require("./NativeScriptSnapshotPlugin");
55
const path = require("path");
@@ -83,7 +83,12 @@ exports.GenerateNativeScriptEntryPointsPlugin = (function () {
8383
return `require("./${depRelativePathUnix}");`;
8484
}).join("");
8585
const currentEntryFileContent = compilation.assets[filePath].source();
86-
compilation.assets[filePath] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
86+
87+
if(compilation.assets[filePath] instanceof ConcatSource) {
88+
compilation.assets[filePath].children.unshift(`${requireDeps}`);
89+
} else {
90+
compilation.assets[filePath] = new RawSource(`${requireDeps}${currentEntryFileContent}`);
91+
}
8792
}
8893
});
8994
}

0 commit comments

Comments
 (0)