Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log error on duplicate webext-messenger execution #6856

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ jobs:
if-no-files-found: error

# The polyfill cannot be used outside the extension context
- run: "! grep 'loaded in a browser extension' dist/pageScript.js --quiet"
- run: "! grep 'loaded in a browser extension' dist/pageScript.js --files-with-matches"
name: Detect browser-polyfill in pageScript.js

# The messenger cannot be executed twice; only load it in contentScriptCore
# https://github.com/pixiebrix/webext-messenger/issues/88
- run: "! grep '__getTabData' dist/loadActivationEnhancements.js dist/contentScript.js --quiet"
name: Detect webext-messenger in loadActivationEnhancements.js and dist/contentScript.js
# - contentScript.js can't have it because the file could be injected multiple times, guarding contentScriptCore
# - loadActivationEnhancements.js can't have it because it's always loaded alongside contentScript.js
- run: "! grep '__getTabData' dist/loadActivationEnhancements.js dist/contentScript.js --files-with-matches"
name: Detect webext-messenger unwanted bundles

- uses: actions/upload-artifact@v3
name: Save report.html
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"webext-base-css": "^1.4.3",
"webext-content-scripts": "^2.5.5",
"webext-detect-page": "^4.1.1",
"webext-messenger": "^0.24.0",
"webext-messenger": "^0.25.0-0",
"webext-patterns": "^1.3.0",
"webext-polyfill-kinda": "^1.0.2",
"webext-storage": "^1.2.2",
Expand Down
2 changes: 2 additions & 0 deletions src/contentScript/loadActivationEnhancements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
// WARNING: this file MUST NOT directly or transitively import webext-messenger because it does not support being
// imported multiple times in the same contentScript. It's only safe to import webext-messenger in contentScriptCore.ts
// which is behind a guarded dynamic import.
// https://github.com/pixiebrix/webext-messenger/issues/88

import { initRuntimeLogging } from "@/development/runtimeLogging";
import { loadActivationEnhancements } from "@/contentScript/loadActivationEnhancementsCore";

// eslint-disable-next-line prefer-destructuring -- process.env substitution
const DEBUG = process.env.DEBUG;

Expand Down