ghostery / adblocker

Efficient embeddable adblocker library

Home Page:https://www.ghostery.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Main process minimization with Webpack

glani opened this issue · comments

Minimization of the application in webpack causes the problem with

const PRELOAD_PATH = require.resolve('@cliqz/adblocker-electron-preload');

as result in the minified code:

(node:87637) UnhandledPromiseRejectionWarning: TypeError: Error processing argument at index 0, conversion failure from
at Ci.enable (/Applications/SMBActApp.app/Contents/Resources/app/app-native/main.js:3994:85)
at Di.enableBlockingInSession (/Applications/SMBActApp.app/Contents/Resources/app/app-native/main.js:4066:93)
at c. (/Applications/SMBActApp.app/Contents/Resources/app/app-native/main.js:16148:63)
at Generator.next ()
at n (/Applications/SMBActApp.app/Contents/Resources/app/app-native/main.js:16058:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

original call is before minimization:

this._win = new BrowserWindow({

  },
});
if (this._blockMetadata.blockAds) {
  blocker.enableBlockingInSession(this._win.webContents.session);
}

the problem is on these two lines:

this.session.setPreloads(this.session.getPreloads().concat([PRELOAD_PATH]));

const PRELOAD_PATH = require.resolve('@cliqz/adblocker-electron-preload');

looks like workaround to put: loadCosmeticFilters = false in configuration.