GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — :construction: apply loader to silence HMR logs · nullstack/nullstack@20fda52

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • client
    • index.js
  • loaders
    • shut-up-loader.js
  • server
    • hmr.js
  • shared
    • silenceHmr.js
  • webpack.config.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎client/index.js‎

Copy file name to clipboardExpand all lines: client/index.js
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import element from '../shared/element'
22
import fragment from '../shared/fragment'
33
import generateTree from '../shared/generateTree'
44
import { loadPlugins, useClientPlugins } from '../shared/plugins'
5-
import dangerouslySilenceHmr from '../shared/silenceHmr'
65
import client from './client'
76
import context, { generateContext } from './context'
87
import environment from './environment'
@@ -107,8 +106,6 @@ export default class Nullstack {
107106
}
108107

109108
if (module.hot) {
110-
dangerouslySilenceHmr()
111-
112109
function pingAndReload() {
113110
const source = new window.EventSource('/nullstack/hmr')
114111
let shouldReconnect = false
Collapse file

‎loaders/shut-up-loader.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = function removeStaticFromClient(source) {
2+
const injection = `
3+
const console = {
4+
log: () => {},
5+
error: () => {},
6+
debug: () => {},
7+
info: () => {},
8+
warn: () => {}
9+
};
10+
`
11+
return injection + source
12+
}
Collapse file

‎server/hmr.js‎

Copy file name to clipboardExpand all lines: server/hmr.js
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
import { existsSync } from 'fs'
33
import path from 'path'
44

5-
import dangerouslySilenceHmr from '../shared/silenceHmr'
6-
75
export default function hmr(server) {
86
if (module.hot) {
9-
dangerouslySilenceHmr()
10-
117
const customConfig = path.resolve(process.cwd(), 'webpack.config.js')
128
const webpackConfigs = existsSync(customConfig)
139
? __non_webpack_require__(customConfig)
Collapse file

‎shared/silenceHmr.js‎

Copy file name to clipboardExpand all lines: shared/silenceHmr.js
-13Lines changed: 0 additions & 13 deletions
This file was deleted.
Collapse file

‎webpack.config.js‎

Copy file name to clipboardExpand all lines: webpack.config.js
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ function getLoader(loader) {
1616
return path.posix.join(loaders, loader)
1717
}
1818

19-
const originalLog = console.log
20-
global.console.log = function (...args) {
21-
if (args[0] && args[0].toString().startsWith('[nodemon-webpack-plugin]')) return
22-
originalLog(...args)
23-
}
24-
2519
function cacheFactory(args, folder, name) {
2620
if (args.cache || args.environment === 'development') {
2721
return {
@@ -374,6 +368,14 @@ function server(env, argv) {
374368
resourceQuery: /raw/,
375369
type: 'asset/source',
376370
},
371+
{
372+
test: /webpack[\\\/]hot/,
373+
loader: getLoader('shut-up-loader.js')
374+
},
375+
{
376+
test: /webpack-hot-middleware/,
377+
loader: getLoader('shut-up-loader.js')
378+
}
377379
],
378380
},
379381
target: 'node',
@@ -500,6 +502,14 @@ function client(env, argv) {
500502
test: /\.(njs|nts|jsx|tsx)$/,
501503
loader: getLoader('transform-node-ref.js'),
502504
},
505+
{
506+
test: /webpack[\\\/]hot/,
507+
loader: getLoader('shut-up-loader.js')
508+
},
509+
{
510+
test: /webpack-hot-middleware/,
511+
loader: getLoader('shut-up-loader.js')
512+
}
503513
],
504514
},
505515
target: 'web',

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.