Open PLtier opened 10 months ago
Hi @101arrowz - maybe you have an insight about that? Have seen you pushed to the web-extensions docs :)
Here is the workaround I have found so far:
import
or URL
atop of the service worker.chrome.storage
Maybe plasmohq has solved that issue if someone has time to check.
🐛 bug report
I use the same new URL, pointing to an extension page, in two different places: SW and Popup, but Parcel keeps on bundling two distinct files. Their dependencies are somehow mixed. Page to which Popup points cannot resolve it's dependencies. See the code:
File
paths.js
:Service Worker:
Popup:
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Both URLs should point to the same HTML page, all dependencies should be the same.
😯 Current Behavior
First URL, used in SW, points to one HTML file, the second one, used in Popup, to another HTML file. In addition, this latter "duplicate" throws error "Cannot find module + some ID". Strangely CSS file is shared between them, but no video nor script.
Developer console of the extension page opened via Popup.
Dist directory There should be a single set of these four files:
camera_permission.js
,camera_permission.css
,extension_tutoria.mp4
andcamera_permission.html
.💁 Possible Solution
I have no idea. But I checked that if you access new URL in a different context - i.e. an Offscreen document, then there is no issue. I assume it's limited to the Popups.
🔦 Context
Once the user opens the extension, SW opens an extension page on which user can grant permission for the camera, as it's used by the extension in the offscreen document. But user can access this extension page by clicking a button on popup (if they have closed this accidentally and didn't give permission). "The first" extension page works as indented, but this opened in Popup points to different extension page which malfunctions.
💻 Code Sample
extension_page_script.js
extension_page.html
popup_script.js
popup.html
service_worker.js
See the dist - there are two different extension pages generated. Click on the URL in the SW console - it's fine. Click on the URL in the Popup console - it's there is "Cannot find module" Error and the console.log in EP there is not executed.
🌍 Your Environment