fix(ui): fix bundle diff

This commit is contained in:
Łukasz Mierzwa
2023-12-04 18:15:45 +00:00
committed by Łukasz Mierzwa
parent 140efe764c
commit 46974a4e15
5 changed files with 28 additions and 26 deletions

View File

@@ -15,7 +15,7 @@ test: lint
.PHONY: clean
clean:
rm -fr $(NAME) $(NAME)-* ui/dist ui/dist.pre ui/node_modules ui/coverage coverage.txt
rm -fr $(NAME) $(NAME)-* ui/dist ui/node_modules ui/coverage coverage.txt
.PHONY: show-version
show-version:

View File

@@ -40,8 +40,6 @@ def normalizePath(path):
def normalizeBundleName(path):
if path.startswith('dist/assets/index-'):
return path
return re.sub(r'\-.{8}\.([a-zA-Z-])', r'.\1', path)
@@ -56,6 +54,32 @@ def mergeFiles(allFiles):
return files
def mergeSize(a, b):
for k,v in b.items():
if k in a:
a[k] += v
else:
a[k] = v
return a
def mergeBundles(allBundles):
bundles = {}
for a in allBundles:
if a.bundleName not in bundles:
bundles[a.bundleName] = Bundle(
bundleName=a.bundleName,
totalBytes=0,
files={},
)
bundles[a.bundleName] = Bundle(
bundleName=a.bundleName,
totalBytes=bundles[a.bundleName].totalBytes + a.totalBytes,
files=mergeSize(bundles[a.bundleName].files, a.files),
)
return bundles.values()
def readBundle(path):
bundles = []
with open(path) as f:
@@ -66,7 +90,7 @@ def readBundle(path):
totalBytes=result['totalBytes'],
files=mergeFiles(result['files']))
bundles.append(bundle)
return bundles
return mergeBundles(bundles)
def printRow(diff, element):

View File

@@ -13,7 +13,6 @@ ignores:
- "@types/node"
- "eslint-plugin-jest"
- "node-fetch"
- "@babel/plugin-proposal-private-property-in-object"
- identity-obj-proxy
- jest
- jest-fetch-mock

20
ui/package-lock.json generated
View File

@@ -55,7 +55,6 @@
"vite-tsconfig-paths": "4.2.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
"@testing-library/jest-dom": "6.1.5",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
@@ -695,25 +694,6 @@
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/plugin-proposal-private-property-in-object": {
"version": "7.21.11",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz",
"integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==",
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.",
"dev": true,
"dependencies": {
"@babel/helper-annotate-as-pure": "^7.18.6",
"@babel/helper-create-class-features-plugin": "^7.21.0",
"@babel/helper-plugin-utils": "^7.20.2",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5"
},
"engines": {
"node": ">=6.9.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/plugin-syntax-async-generators": {
"version": "7.8.4",
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",

View File

@@ -50,7 +50,6 @@
"vite-tsconfig-paths": "4.2.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
"@testing-library/jest-dom": "6.1.5",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",