diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /config/helpers | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'config/helpers')
-rw-r--r-- | config/helpers/incremental_webpack_compiler/compiler.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/config/helpers/incremental_webpack_compiler/compiler.js b/config/helpers/incremental_webpack_compiler/compiler.js index 480d7fa3263..0ef090bce24 100644 --- a/config/helpers/incremental_webpack_compiler/compiler.js +++ b/config/helpers/incremental_webpack_compiler/compiler.js @@ -4,8 +4,8 @@ const path = require('path'); const { History, HistoryWithTTL } = require('./history'); const log = require('./log'); -const onRequestEntryPoint = (app, callback) => { - app.use((req, res, next) => { +const onRequestEntryPoint = (callback) => { + return (req, res, next) => { const fileName = path.basename(req.url); /** @@ -20,7 +20,7 @@ const onRequestEntryPoint = (app, callback) => { } next(); - }); + }; }; /** @@ -40,7 +40,9 @@ class NoopCompiler { logStatus() {} // eslint-disable-next-line class-methods-use-this - setupMiddleware() {} + createMiddleware() { + return null; + } } /** @@ -55,8 +57,8 @@ class HistoryOnlyCompiler extends NoopCompiler { this.history = new History(historyFilePath); } - setupMiddleware(app) { - onRequestEntryPoint(app, (entryPoint) => { + createMiddleware() { + return onRequestEntryPoint((entryPoint) => { this.history.onRequestEntryPoint(entryPoint); }); } @@ -92,16 +94,16 @@ class IncrementalWebpackCompiler { log(`Currently compiling route entrypoints: ${this.history.size} of ${totalCount}`); } - setupMiddleware(app, server) { - onRequestEntryPoint(app, (entryPoint) => { + createMiddleware(devServer) { + return onRequestEntryPoint((entryPoint) => { const wasVisitedRecently = this.history.onRequestEntryPoint(entryPoint); if (!wasVisitedRecently) { log(`Have not visited ${entryPoint} recently. Adding to compilation.`); setTimeout(() => { - server.middleware.invalidate(() => { - if (server.sockets) { - server.sockWrite(server.sockets, 'content-changed'); + devServer.invalidate(() => { + if (devServer.sockets) { + devServer.sendMessage(devServer.webSocketServer.clients, 'static-changed'); } }); }, TIMEOUT); |