From 8078e10fd62945b88d5071e50339cffc443e54c0 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Sun, 11 Aug 2024 06:27:59 +0800 Subject: [PATCH] Attempt to solve #10 by copying files in `node_modules` out --- .github/workflows/build.yml | 2 -- background_scripts/index.js | 4 ++-- manifest.json | 8 ++------ package.json | 1 + popup/index.js | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97e231e..f75f91c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,5 +40,3 @@ jobs: lib popup manifest.json - node_modules/webextension-polyfill/dist/browser-polyfill.min.js - node_modules/to-jyutping/dist/index.js diff --git a/background_scripts/index.js b/background_scripts/index.js index ca88246..8a0c4a2 100644 --- a/background_scripts/index.js +++ b/background_scripts/index.js @@ -1,5 +1,5 @@ -import '/node_modules/webextension-polyfill/dist/browser-polyfill.min.js'; -import '/node_modules/to-jyutping/dist/index.js'; +import '/lib/webextension-polyfill.js'; +import '/lib/to-jyutping.js'; import '/lib/MessageManager.js'; /* Communicate with content script */ diff --git a/manifest.json b/manifest.json index 4df8018..8237d93 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,7 @@ "content_scripts": [ { "matches": [""], - "js": ["node_modules/webextension-polyfill/dist/browser-polyfill.min.js", "lib/MessageManager.js", "content_scripts/index.js"], + "js": ["lib/webextension-polyfill.js", "lib/MessageManager.js", "content_scripts/index.js"], "css": ["content_scripts/index.css"], "all_frames": true, "run_at": "document_end" @@ -24,11 +24,7 @@ "web_accessible_resources": [ { "matches": [""], - "resources": [ - "node_modules/webextension-polyfill/dist/browser-polyfill.min.js", - "node_modules/to-jyutping/dist/index.js", - "lib/MessageManager.js" - ] + "resources": ["lib/webextension-polyfill.js", "lib/to-jyutping.js", "lib/MessageManager.js"] } ], "permissions": ["contextMenus", "storage"], diff --git a/package.json b/package.json index 42eaf00..1e03d8c 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.4.0", "description": "A browser extension that adds Cantonese pronunciation (Jyutping) on Chinese characters", "scripts": { + "postinstall": "cp ./node_modules/webextension-polyfill/dist/browser-polyfill.min.js ./lib/webextension-polyfill.js && cp ./node_modules/to-jyutping/dist/index.js ./lib/to-jyutping.js", "lint": "tsc -p jsconfig.json" }, "dependencies": { diff --git a/popup/index.js b/popup/index.js index f26afeb..78c0cac 100644 --- a/popup/index.js +++ b/popup/index.js @@ -1,4 +1,4 @@ -import '/node_modules/webextension-polyfill/dist/browser-polyfill.min.js'; +import './lib/webextension-polyfill.js'; const i = browser.i18n.getMessage;