@rsdoctor/graph 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1277,7 +1277,7 @@ function chunkTransform(assetMap, bundleStats) {
1277
1277
  });
1278
1278
  }) : bundleStats.assets?.forEach((_asset)=>{
1279
1279
  if (_asset.type === FILTER_ASSETS_TYPE) return;
1280
- let chunks = _asset.chunks?.map((ck)=>chunkGraph.getChunkById(String(ck))).filter((chunk)=>!!chunk) || [], { content = '' } = assetMap.get(_asset.name) || {}, asset = new Asset(_asset.name, _asset.size, chunks, content);
1280
+ let chunks = _asset.chunks?.map((ck)=>chunkGraph.getChunkById(String(ck))).filter((chunk)=>!!chunk) || [], { content = '' } = assetMap.get(_asset.name) || {}, contentLength = Buffer.byteLength(content, 'utf8'), size = _asset.size ?? contentLength, asset = new Asset(_asset.name, size, chunks, content);
1281
1281
  chunks.forEach((chunk)=>chunk?.addAsset(asset)), chunkGraph.addAsset(asset);
1282
1282
  }), bundleStats.entrypoints) for (let [key, _entrypoint] of Object.entries(bundleStats.entrypoints)){
1283
1283
  let entrypoint = new EntryPoint(_entrypoint.name || key);
@@ -1295,7 +1295,7 @@ const COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifes
1295
1295
  function assetsContents(assetMap, chunkGraph, supports) {
1296
1296
  chunkGraph.getAssets().forEach((asset)=>{
1297
1297
  let { content = '' } = assetMap.get(asset.path) || {};
1298
- asset.content = content, COMPRESSIBLE_REGEX.test(asset.path) && supports?.gzip && asset.setGzipSize(content);
1298
+ asset.content = content, content.length > 0 && 0 === asset.size && (asset.size = Buffer.byteLength(content, 'utf8')), COMPRESSIBLE_REGEX.test(asset.path) && supports?.gzip && asset.setGzipSize(content);
1299
1299
  });
1300
1300
  }
1301
1301
  const external_path_browserify_namespaceObject = require("path-browserify");
package/dist/index.js CHANGED
@@ -1242,7 +1242,7 @@ function chunkTransform(assetMap, bundleStats) {
1242
1242
  });
1243
1243
  }) : bundleStats.assets?.forEach((_asset)=>{
1244
1244
  if (_asset.type === FILTER_ASSETS_TYPE) return;
1245
- let chunks = _asset.chunks?.map((ck)=>chunkGraph.getChunkById(String(ck))).filter((chunk)=>!!chunk) || [], { content = '' } = assetMap.get(_asset.name) || {}, asset = new Asset(_asset.name, _asset.size, chunks, content);
1245
+ let chunks = _asset.chunks?.map((ck)=>chunkGraph.getChunkById(String(ck))).filter((chunk)=>!!chunk) || [], { content = '' } = assetMap.get(_asset.name) || {}, contentLength = Buffer.byteLength(content, 'utf8'), size = _asset.size ?? contentLength, asset = new Asset(_asset.name, size, chunks, content);
1246
1246
  chunks.forEach((chunk)=>chunk?.addAsset(asset)), chunkGraph.addAsset(asset);
1247
1247
  }), bundleStats.entrypoints) for (let [key, _entrypoint] of Object.entries(bundleStats.entrypoints)){
1248
1248
  let entrypoint = new EntryPoint(_entrypoint.name || key);
@@ -1260,7 +1260,7 @@ let COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)
1260
1260
  function assetsContents(assetMap, chunkGraph, supports) {
1261
1261
  chunkGraph.getAssets().forEach((asset)=>{
1262
1262
  let { content = '' } = assetMap.get(asset.path) || {};
1263
- asset.content = content, COMPRESSIBLE_REGEX.test(asset.path) && supports?.gzip && asset.setGzipSize(content);
1263
+ asset.content = content, content.length > 0 && 0 === asset.size && (asset.size = Buffer.byteLength(content, 'utf8')), COMPRESSIBLE_REGEX.test(asset.path) && supports?.gzip && asset.setGzipSize(content);
1264
1264
  });
1265
1265
  }
1266
1266
  function isImportDependency({ type }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/graph",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "es-toolkit": "^1.41.0",
25
+ "es-toolkit": "^1.43.0",
26
26
  "path-browserify": "1.0.1",
27
27
  "source-map": "^0.7.6",
28
- "@rsdoctor/types": "1.4.0",
29
- "@rsdoctor/utils": "1.4.0"
28
+ "@rsdoctor/types": "1.5.0",
29
+ "@rsdoctor/utils": "1.5.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/body-parser": "1.19.6",