@af-utils/rollup-plugin-export-bundle-size
Advanced tools
Comparing version 0.0.4 to 0.0.5
# @rollup/plugin-export-bundle-size | ||
## 0.0.5 | ||
### Patch Changes | ||
- upgraded deps, improved use-sync-external-shim import | ||
## 0.0.4 | ||
@@ -7,3 +13,3 @@ | ||
- mjs > ts conversion, pruned unused deps | ||
- mjs > ts conversion, pruned unused deps | ||
@@ -14,3 +20,3 @@ ## 0.0.3 | ||
- shrinked build size | ||
- shrinked build size | ||
@@ -21,2 +27,2 @@ ## 0.0.2 | ||
- upgraded deps, fixed headless updating range on itemCount change, improved syntax highlighting | ||
- upgraded deps, fixed headless updating range on itemCount change, improved syntax highlighting |
29
index.ts
import { writeFile } from "fs/promises"; | ||
import { gzip as gzipCallback, brotliCompress } from "zlib"; | ||
import { promisify } from "util"; | ||
import { minify } from "terser"; | ||
import { MinifyOptions, minify } from "terser"; | ||
import type { Plugin } from "rollup"; | ||
@@ -14,5 +14,6 @@ | ||
output: { | ||
comments: false | ||
comments: false, | ||
preserve_annotations: false | ||
} | ||
}; | ||
} satisfies MinifyOptions; | ||
@@ -62,3 +63,3 @@ const gzip = promisify(gzipCallback); | ||
function createPlugin({ dir }: { dir: string }) { | ||
function createPlugin({ dir, whitelist }: { dir: string; whitelist?: RegExp }) { | ||
return { | ||
@@ -68,11 +69,15 @@ name: "export-bundle-size", | ||
for (const file in output) { | ||
const newFileName = `${dir}/bundlesize.${file}`; | ||
const outputContent = output[file]; | ||
if (!whitelist || whitelist.test(file)) { | ||
const newFileName = `${dir}/bundlesize.${file}`; | ||
const outputContent = output[file]; | ||
if ("code" in outputContent) { | ||
const fileSizes = await getFileSizes(outputContent.code); | ||
await Promise.all([ | ||
write(newFileName, fileSizes, false), | ||
write(newFileName, fileSizes, true) | ||
]); | ||
if ("code" in outputContent) { | ||
const fileSizes = await getFileSizes( | ||
outputContent.code | ||
); | ||
await Promise.all([ | ||
write(newFileName, fileSizes, false), | ||
write(newFileName, fileSizes, true) | ||
]); | ||
} | ||
} | ||
@@ -79,0 +84,0 @@ } |
@@ -1,3 +0,4 @@ | ||
declare function createPlugin({ dir }: { | ||
declare function createPlugin({ dir, whitelist }: { | ||
dir: string; | ||
whitelist?: RegExp; | ||
}): { | ||
@@ -4,0 +5,0 @@ readonly name: "export-bundle-size"; |
@@ -12,3 +12,4 @@ import { writeFile } from "fs/promises"; | ||
output: { | ||
comments: false | ||
comments: false, | ||
preserve_annotations: false | ||
} | ||
@@ -45,3 +46,3 @@ }; | ||
} | ||
function createPlugin({ dir }) { | ||
function createPlugin({ dir, whitelist }) { | ||
return { | ||
@@ -51,10 +52,12 @@ name: "export-bundle-size", | ||
for (const file in output) { | ||
const newFileName = `${dir}/bundlesize.${file}`; | ||
const outputContent = output[file]; | ||
if ("code" in outputContent) { | ||
const fileSizes = await getFileSizes(outputContent.code); | ||
await Promise.all([ | ||
write(newFileName, fileSizes, false), | ||
write(newFileName, fileSizes, true) | ||
]); | ||
if (!whitelist || whitelist.test(file)) { | ||
const newFileName = `${dir}/bundlesize.${file}`; | ||
const outputContent = output[file]; | ||
if ("code" in outputContent) { | ||
const fileSizes = await getFileSizes(outputContent.code); | ||
await Promise.all([ | ||
write(newFileName, fileSizes, false), | ||
write(newFileName, fileSizes, true) | ||
]); | ||
} | ||
} | ||
@@ -61,0 +64,0 @@ } |
{ | ||
"name": "@af-utils/rollup-plugin-export-bundle-size", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Alex Fomin <nowaalex@gmail.com> (https://github.com/nowaalex/)", | ||
@@ -13,6 +13,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"rollup": "^4.0.2", | ||
"terser": "^5.21.0", | ||
"typescript": "^5.2.2", | ||
"@types/node": "^20.8.5" | ||
"rollup": "^4.9.6", | ||
"terser": "^5.27.0" | ||
}, | ||
@@ -19,0 +17,0 @@ "publishConfig": { |
{ | ||
"include": ["index.ts"], | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"moduleResolution": "Node", | ||
"module": "ESNext", | ||
"outDir": "lib/", | ||
"target": "ESNext", | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"alwaysStrict": true, | ||
"declaration": true, | ||
"types": ["node"] | ||
"outDir": "lib" | ||
} | ||
} |
7009
2
156