Add necessary npm dependencies for integrating SDK
Background / User story
Integrating the SDK in #972 (closed) requires some changes, for which we need to add the following npm dependencies:
- source-map-loader: Necessary to combine the source maps of the SDK bundles with the source maps of our own bundles.
- webextension-polyfill: Necessary to avoid conflicts caused by polyfill.js modifying the
chrome
global, which the SDK relies on for its own polyfill, which is also webextension-polyfill (see also https://gitlab.com/eyeo/webext/webext-sdk/-/issues/96).
What to change
- Design: N/A
- Research: N/A
- Spec: N/A
- Legal: TBD
-
Development:
- Add "source-map-loader" npm dependency.
- Integrate into extension build process via Webpack configuration.
- Replace source map type in adblockpluschrome/gulpfile.js from "inline-cheap-source-map" to "inline-source-map".
- Add "webextension-polyfill" npm dependency and update adblockpluschrome/polyfill.js:
- Convert into a bundle.
- Remove existing web extension API polyfill.
- Set
browser
global.
- Add "source-map-loader" npm dependency.
Hints for testers
- Interactions between the extension and the browser (i.e. web extension API) should remain unchanged, so that the extension still works as before. For example, changing preferences, blocking ads, hiding elements and the Block element feature should all work.
- Source maps should be used by browser, so that code is easily readable and navigable in the developer tools. This applies to code from adblockplusui, adblockpkluschrome, adblockpluscore as well as webext-sdk and npm dependencies (at least those that provide source maps).
- No errors should be shown in either:
- Extension background page
- Extension pages
- Web pages (only related to our content scripts)
- Ignore the warning that webextension-polyfill shows in the extension's background page console about
sendResponse
being deprecated (see comment).
Since the webext-sdk code is not being used in the extension code yet, you can add the following line to lib/init.js to include it in the extension's background page bundle when building the extension:
require("../vendor/webext-sdk/dist/ewe-api.js");
Hints for translators
N/A
Edited by Thomas Greiner