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

Commit de2b23a

Browse files
committed
fix: don't emit absolute webpack's runtime files
Previously we needed to emit files with full paths as {N} CLI relies on this and expected them in a such format. With the changes for "webpack-only" mode, {N} CLI expects only relative paths. So we need to fix this in order to ensure that runtime.js file will not be transferred on device on change in hmr mode.
1 parent 4f481b9 commit de2b23a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Diff for: plugins/WatchStateLoggerPlugin.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { join } from "path";
2-
31
export enum messages {
42
compilationComplete = "Webpack compilation complete.",
53
startWatching = "Webpack compilation complete. Watching for file changes.",
@@ -31,7 +29,7 @@ export class WatchStateLoggerPlugin {
3129
console.log(messages.compilationComplete);
3230
}
3331

34-
const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation, compiler.context);
32+
const runtimeOnlyFiles = getWebpackRuntimeOnlyFiles(compilation);
3533
let emittedFiles = Object
3634
.keys(compilation.assets)
3735
.filter(assetKey => compilation.assets[assetKey].emitted);
@@ -43,7 +41,7 @@ export class WatchStateLoggerPlugin {
4341
}
4442
}
4543

46-
function getWebpackRuntimeOnlyFiles(compilation, basePath) {
44+
function getWebpackRuntimeOnlyFiles(compilation) {
4745
let runtimeOnlyFiles = [];
4846
try {
4947
runtimeOnlyFiles = [].concat(...Array.from<any>(compilation.entrypoints.values())
@@ -52,9 +50,7 @@ function getWebpackRuntimeOnlyFiles(compilation, basePath) {
5250
.filter(runtimeChunk => !!runtimeChunk && runtimeChunk.preventIntegration)
5351
.map(runtimeChunk => runtimeChunk.files))
5452
// get only the unique files in case of "single" runtime (e.g. runtime.js)
55-
.filter((value, index, self) => self.indexOf(value) === index)
56-
// convert to absolute paths
57-
.map(fileName => join(basePath, fileName));
53+
.filter((value, index, self) => self.indexOf(value) === index);
5854
} catch (e) {
5955
// breaking change in the Webpack API
6056
console.log("Warning: Unable to find Webpack runtime files.");

0 commit comments

Comments
 (0)