Skip to content

Commit

Permalink
fix(browser): remove "util" warning (#5935)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jun 20, 2024
1 parent 45dfc95 commit 48f28f7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
const distRoot = resolve(pkgRoot, 'dist')
const project = browserServer.project

let loupePath: string

return [
{
enforce: 'pre',
Expand Down Expand Up @@ -205,6 +207,16 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
return resolve(distRoot, 'client', id.slice(1))
}
},
configResolved(config) {
loupePath = resolve(config.cacheDir, 'deps/loupe.js')
},
transform(code, id) {
if (id.startsWith(loupePath)) {
// loupe bundle has a nastry require('util') call that leaves a warning in the console
const utilRequire = 'nodeUtil = require_util();'
return code.replace(utilRequire, ' '.repeat(utilRequire.length))
}
},
},
BrowserContext(browserServer),
DynamicImport(),
Expand Down

0 comments on commit 48f28f7

Please sign in to comment.