I'm trying to manipulate an HTML string in the background script, that in the chrome extension V3 is using a service worker.
In the migration documentation it is mentions to use jsdom in order to get access to the DOMParser: https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/#documents
The problem is that when I try to add jsdom, I receive the following error:
The manifest the background script is defined as:
"background": {
"service_worker": "background.js"
},
"manifest_version": 3,
....
The background script contains the following code:
const jsdom = require("jsdom");
const dom = new jsdom.JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
console.log("textContent", dom.window.document.querySelector("p").textContent); // 'Hello world'
My question is: How does one get access to DOMParser in the V3 chrome extension inside the service worker?