Skip to content

Commit a0d3f0f

Browse files
committed
fix: firefox addon limitations
1 parent e798d89 commit a0d3f0f

8 files changed

Lines changed: 49 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "yarn build:all"
4646
docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:chrome && yarn zip"
4747
mv packages/extension/dist/release.zip release/enkrypt-chrome-edge-opera-${{ steps.get_release_tag.outputs.VERSION }}.zip
48+
docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:opera && yarn zip"
49+
mv packages/extension/dist/release.zip release/enkrypt-opera-${{ steps.get_release_tag.outputs.VERSION }}.zip
4850
docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:firefox && yarn zip"
4951
mv packages/extension/dist/release.zip release/enkrypt-firefox-${{ steps.get_release_tag.outputs.VERSION }}.xpi
5052

packages/extension/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ coverage
2828
*.sw?
2929

3030
*.tsbuildinfo
31+
stats.html
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Plugin } from 'vite'
2-
import { dirname, relative } from 'node:path'
1+
import { Plugin } from 'vite';
2+
import { dirname, relative } from 'node:path';
33

44
const assetsRewritePlugin: Plugin = {
55
name: 'assets-rewrite',
66
enforce: 'post',
77
apply: 'build',
88
transformIndexHtml(html, { path }) {
9-
const assetsPath = relative(dirname(path), '/assets').replace(/\\/g, '/')
10-
return html.replace(/"\/assets\//g, `"${assetsPath}/`)
9+
const assetsPath = relative(dirname(path), '/assets').replace(/\\/g, '/');
10+
return html.replace(/"\/assets\//g, `"${assetsPath}/`);
1111
},
12-
}
12+
};
1313

14-
export default assetsRewritePlugin
14+
export default assetsRewritePlugin;

packages/extension/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@enkryptcom/extension",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -126,6 +126,7 @@
126126
"prettier": "^3.3.3",
127127
"rimraf": "^6.0.1",
128128
"rollup": "^4.25.0",
129+
"rollup-plugin-visualizer": "^5.12.0",
129130
"semver": "^7.6.3",
130131
"systeminformation": "^5.23.5",
131132
"tsup": "^8.3.5",

packages/extension/src/manifest/manifest.firefox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const firefoxManifest = {
2121
web_accessible_resources: [],
2222
browser_specific_settings: {
2323
gecko: {
24-
strict_min_version: '100.0',
24+
id: '{21a9e8ea-7aa4-4aae-923c-ec8211f2779c}',
25+
strict_min_version: '112.0',
2526
},
2627
},
2728
content_security_policy: {

packages/extension/src/ui/provider-pages/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Vue3Lottie from 'vue3-lottie';
88
global.WeakMap = WeakMap;
99

1010
if (import.meta.env.DEV) {
11-
globalThis.__ENKRYPT_DEBUG_LOG_CONF__ = import.meta.env.VITE_DEBUG_LOG
11+
globalThis.__ENKRYPT_DEBUG_LOG_CONF__ = import.meta.env.VITE_DEBUG_LOG;
1212
}
1313

1414
const router = createRouter({

packages/extension/vite.config.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fileURLToPath, URL } from 'node:url';
22
import { nodePolyfills } from 'vite-plugin-node-polyfills';
3-
import { defineConfig } from 'vite';
3+
import { visualizer } from 'rollup-plugin-visualizer';
4+
import { defineConfig, type PluginOption } from 'vite';
45
import vue from '@vitejs/plugin-vue';
56
import { crx } from '@crxjs/vite-plugin';
67
import chromeManifest from './src/manifest/manifest.chrome';
@@ -12,7 +13,13 @@ import transformCSInject from './configs/vite/transform-cs-inject';
1213
import { version } from './package.json';
1314

1415
const BROWSER = process.env.BROWSER;
15-
16+
const firefoxChunking = (id: string) => {
17+
if (id.includes('node_modules')) {
18+
const chunkName = id.match(/node_modules\/(.+?)\//);
19+
if (chunkName && chunkName.length > 1) return chunkName[1].replace('@', '');
20+
return 'vendor';
21+
}
22+
};
1623
const getManifest = () => {
1724
switch (BROWSER) {
1825
case 'firefox':
@@ -49,6 +56,7 @@ export default defineConfig({
4956
: new Date().toLocaleString().replace(/\D/g, ''),
5057
},
5158
plugins: [
59+
visualizer() as PluginOption,
5260
nodePolyfills({
5361
include: [
5462
'crypto',
@@ -95,6 +103,9 @@ export default defineConfig({
95103
onboard: 'onboard.html',
96104
index: 'index.html',
97105
},
106+
output: {
107+
manualChunks: BROWSER === 'firefox' ? firefoxChunking : undefined,
108+
},
98109
},
99110
},
100111
optimizeDeps: {

yarn.lock

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,7 @@ __metadata:
16961696
qrcode.vue: "npm:^3.6.0"
16971697
rimraf: "npm:^6.0.1"
16981698
rollup: "npm:^4.25.0"
1699+
rollup-plugin-visualizer: "npm:^5.12.0"
16991700
semver: "npm:^7.6.3"
17001701
switch-ts: "npm:^1.1.1"
17011702
systeminformation: "npm:^5.23.5"
@@ -22677,7 +22678,7 @@ __metadata:
2267722678
languageName: node
2267822679
linkType: hard
2267922680

22680-
"open@npm:^8.0.2, open@npm:^8.0.9":
22681+
"open@npm:^8.0.2, open@npm:^8.0.9, open@npm:^8.4.0":
2268122682
version: 8.4.2
2268222683
resolution: "open@npm:8.4.2"
2268322684
dependencies:
@@ -25212,6 +25213,25 @@ __metadata:
2521225213
languageName: node
2521325214
linkType: hard
2521425215

25216+
"rollup-plugin-visualizer@npm:^5.12.0":
25217+
version: 5.12.0
25218+
resolution: "rollup-plugin-visualizer@npm:5.12.0"
25219+
dependencies:
25220+
open: "npm:^8.4.0"
25221+
picomatch: "npm:^2.3.1"
25222+
source-map: "npm:^0.7.4"
25223+
yargs: "npm:^17.5.1"
25224+
peerDependencies:
25225+
rollup: 2.x || 3.x || 4.x
25226+
peerDependenciesMeta:
25227+
rollup:
25228+
optional: true
25229+
bin:
25230+
rollup-plugin-visualizer: dist/bin/cli.js
25231+
checksum: 10/47358feb672291d6edcfd94197577c192a84c24cb644119425dae8241fb6f5a52556efd0c501f38b276c07534642a80c0885ef681babb474e83c7b5a3b475b84
25232+
languageName: node
25233+
linkType: hard
25234+
2521525235
"rollup@npm:2.79.2":
2521625236
version: 2.79.2
2521725237
resolution: "rollup@npm:2.79.2"
@@ -31015,7 +31035,7 @@ __metadata:
3101531035
languageName: node
3101631036
linkType: hard
3101731037

31018-
"yargs@npm:^17.0.0, yargs@npm:^17.7.2":
31038+
"yargs@npm:^17.0.0, yargs@npm:^17.5.1, yargs@npm:^17.7.2":
3101931039
version: 17.7.2
3102031040
resolution: "yargs@npm:17.7.2"
3102131041
dependencies:

0 commit comments

Comments
 (0)