Skip to content

Commit

Permalink
fix(browser): correctly overwrite loupe require
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 10, 2024
1 parent 0d534fb commit 756ac2b
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ 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 @@ -228,11 +226,8 @@ 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)) {
if (id.includes(browserServer.vite.config.cacheDir) && id.includes('loupe.js')) {
// 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))
Expand Down

0 comments on commit 756ac2b

Please sign in to comment.