Skip to content

Commit

Permalink
Log error on duplicate webext-messenger execution (#6856)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Nov 16, 2023
1 parent 9e9a3af commit 6948811
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
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 @@ -165,7 +165,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

0 comments on commit 6948811

Please sign in to comment.