forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement webpack analysing for each package (deriv-com#14800)
- Loading branch information
1 parent
d8337d7
commit 3bc6169
Showing
17 changed files
with
185 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Bundle Analyser</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" /> | ||
<style> | ||
html, | ||
body { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
#main-content { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
} | ||
#frame { | ||
flex-grow: 1; | ||
} | ||
|
||
.navbar { | ||
background-color: rgb(255, 235, 255); | ||
border-bottom: 1px solid purple; | ||
padding: 0 12px; | ||
} | ||
|
||
.navbar .nav-link { | ||
color: black; | ||
} | ||
.total-size { | ||
color: white; | ||
background-color: purple; | ||
padding: 5px 10px; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body onload="updateLabelOnStart()"> | ||
<div id="main-content"> | ||
<nav class="navbar navbar-expand-lg"> | ||
<a class="navbar-brand" href="#">Bundle Analyser</a> | ||
|
||
<div class="navbar-collapse" id="navbarNavDropdown"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item dropdown"> | ||
<button | ||
class="nav-link dropdown-toggle" | ||
href="#" | ||
id="navbarDropdownMenuLink" | ||
data-bs-toggle="dropdown" | ||
aria-expanded="false" | ||
onkeypress="event.preventDefault()" | ||
> | ||
Loading... | ||
</button> | ||
|
||
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('account-v2')"> | ||
account-v2 | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('account')"> | ||
account | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('appstore')"> | ||
appstore | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('bot-web-ui')"> | ||
bot-web-ui | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('cashier-v2')"> | ||
cashier-v2 | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('cashier')"> | ||
cashier | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('cfd')">cfd</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('core')">core</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('p2p-v2')">p2p-v2</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('p2p')">p2p</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('reports')"> | ||
reports | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('trader')">trader</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('tradershub')"> | ||
tradershub | ||
</button> | ||
<button class="dropdown-item" href="#" onclick="updateIframe('wallets')"> | ||
wallets | ||
</button> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<span class="total-size" id="bundleSize">Bundle Size: Loading...</span> | ||
</nav> | ||
<iframe | ||
id="frame" | ||
title="bundle-view" | ||
src="./packages/core/analyzed.html" | ||
style="width: 100%; border: none" | ||
></iframe> | ||
</div> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha256-CDOy6cOibCWEdsRiZuaHf8dSGGJRYuBGC+mjoJimHGw=" | ||
crossorigin="anonymous" | ||
></script> | ||
<script> | ||
async function updateIframe(packageName) { | ||
const iframeSrc = './packages/' + packageName + '/analyzed.html'; | ||
document.getElementById('frame').src = iframeSrc; | ||
document.getElementById('navbarDropdownMenuLink').textContent = | ||
packageName.charAt(0).toUpperCase() + packageName.slice(1); | ||
updateBundleSize(packageName); | ||
} | ||
|
||
async function updateBundleSize(packageName) { | ||
const response = await fetch(`./packages/${packageName}/report.json`); | ||
if (!response.ok) { | ||
document.getElementById('bundleSize').textContent = 'Bundle Size: Error loading data'; | ||
return; | ||
} | ||
const data = await response.json(); | ||
const totalStatSize = data.reduce((acc, item) => acc + item.statSize, 0); | ||
const totalParsedSize = data.reduce((acc, item) => acc + item.parsedSize, 0); | ||
const totalGzipSize = data.reduce((acc, item) => acc + item.gzipSize, 0); | ||
document.getElementById('bundleSize').innerHTML = | ||
'<strong>Stat Size:</strong> ' + | ||
formatBytes(totalStatSize) + | ||
', <strong>Parsed Size:</strong> ' + | ||
formatBytes(totalParsedSize) + | ||
', <strong>Gzip Size:</strong> ' + | ||
formatBytes(totalGzipSize); | ||
} | ||
|
||
function formatBytes(bytes, decimals = 2) { | ||
if (bytes === 0) return '0 Bytes'; | ||
const k = 1024; | ||
const dm = decimals < 0 ? 0 : decimals; | ||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | ||
const i = Math.floor(Math.log(bytes) / Math.log(k)); | ||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; | ||
} | ||
|
||
function updateLabelOnStart() { | ||
updateIframe('core'); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters