Skip to content

chore: split build files into smaller chunks [LW-12374] #1778

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

Merged
merged 12 commits into from
Apr 10, 2025

Conversation

pczeglik-iohk
Copy link
Contributor

@pczeglik-iohk pczeglik-iohk commented Mar 14, 2025

Checklist


Proposed solution

In order to submit Lace extension to Mozilla's Web Store we need to meet requirement of source files not exceeding 4MB each. In this PR I'm updating webpack configs to split code into chunks smaller then 4MB and move nami icons to source code as react-icons library does not support tree-shaking, what creates a file bigger then 6 MB.

Since this code is merged we will observe a new WARNING message in terminal output:

WARNING in ./src/shims/inquire.js 24:18-37
Critical dependency: the request of a dependency is an expression
 @ ../../node_modules/@trezor/transport/node_modules/protobufjs/src/util/minimal.js 17:15-45
 @ ../../node_modules/@trezor/transport/node_modules/protobufjs/src/index-minimal.js 19:24-49
 @ ../../node_modules/@trezor/transport/node_modules/protobufjs/src/index-light.js 2:15-58
 @ ../../node_modules/@trezor/transport/node_modules/protobufjs/light.js 4:0-45
 @ ../../node_modules/@trezor/transport/lib/index.js 30:30-57
 @ ../../packages/cardano/dist/index.esm.js 37:0-59 1349:26-55
 @ ./src/lib/scripts/background/onStorageChange.ts 3:0-39 15:29-65
 @ ./src/lib/scripts/background/index.ts 9:0-27
 @ ./src/lib/scripts/background/index-sw.ts 1:0-17

This is described in this file: apps/browser-extension-wallet/src/shims/inquire.js as

The latest published version of protobufjs/inquire uses eval, which is not allowed in the browser extension
https://github.com/protobufjs/protobuf.js/blob/2b12fb7db9d4eaa3b76b7198539946e97db684c4/lib/inquire/index.js
This issue has been already fixed in protobujs/inquire
https://github.com/protobufjs/protobuf.js/blob/master/lib/inquire/index.js
but not published yet
protobufjs/protobuf.js#1941
This shim can be removed once protobujs/inquire is published with the fix

Additionally, in this PR I changed a bit the structure of the dist folder. Currently it looks like this:

dist
├── app
│   ├── inject.js
│   ├── load-app.js
│   ├── load-dapp-connector.js
│   ├── ...
│   └── trezor-usb-permissions.js
├── assets
│   ├── cardano-blue-bg.png
│   ├── educational-illustration.png
│   ├── Exclamation.png
│   ├── ...
│   └──lace.mp4
├── sw
│   ├── 113.chunk.js
│   ├── 171.chunk.js
│   ├── ...
│   └── background.js
├── app.html
├── dappConnector.html
├── icon128.png
├── icon16.png
├── icon32.png
├── icon48.png
├── manifest.json
├── popup.html
└── trezor-usb-permissions.html

@pczeglik-iohk pczeglik-iohk requested a review from a team as a code owner March 14, 2025 10:36
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from 59d1986 to 78b8f4c Compare March 14, 2025 10:39
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from 78b8f4c to fb46688 Compare March 14, 2025 10:44
@lace-bot
Copy link
Collaborator

lace-bot commented Mar 14, 2025

Allure Report

allure-report-publisher generated test report!

processReports: ✅ test report for 2d041c8b

passed failed skipped flaky total result
Total 33 0 4 0 37

@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch 4 times, most recently from 73dd30b to 34db06e Compare March 20, 2025 08:08
@pczeglik-iohk pczeglik-iohk changed the title chore: split build files into smaller chunks chore: split build files into smaller chunks [LW-12374] Mar 20, 2025
@mkazlauskas mkazlauskas force-pushed the chore/firefox-webpack-chunks branch from d3fd91f to 156cd64 Compare March 31, 2025 12:00
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch 2 times, most recently from b5f462e to b8f0de1 Compare April 7, 2025 09:26
Copy link
Contributor

@przemyslaw-wlodek przemyslaw-wlodek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a few comments with improvements. Let's discuss them and I can approve :)

@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch 6 times, most recently from 588e17a to 7d68125 Compare April 8, 2025 11:09
Copy link
Contributor

@przemyslaw-wlodek przemyslaw-wlodek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @pczeglik-iohk ! 😄 🍻

@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch 2 times, most recently from 89cd932 to 950ae43 Compare April 9, 2025 10:21
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from edae8f0 to 79e706d Compare April 9, 2025 11:29
@pczeglik-iohk pczeglik-iohk requested a review from a team as a code owner April 9, 2025 11:29
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from 79e706d to 0851473 Compare April 10, 2025 07:10
pczeglik-iohk and others added 9 commits April 10, 2025 09:36
Because of the dynamic nature of code chunks in Webpack and the way Firefox handles background
scripts, we need to add a new custom plugin to the Webpack configuration. This plugin will
transform manifest file and ensure that the background scripts are properly loaded in Firefox.
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from 0851473 to bdda05d Compare April 10, 2025 07:37
@pczeglik-iohk pczeglik-iohk force-pushed the chore/firefox-webpack-chunks branch from 68613d5 to 2d041c8 Compare April 10, 2025 08:35
Copy link

sonarqubecloud bot commented Apr 10, 2025

@pczeglik-iohk pczeglik-iohk merged commit f9bf975 into main Apr 10, 2025
31 of 32 checks passed
@pczeglik-iohk pczeglik-iohk deleted the chore/firefox-webpack-chunks branch April 10, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants