This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
size
property to output (#672)
* feat: add `size` property to output * chore: add `size` to README * refactor: replace lstat with stat * chore: add test * refactor: move formatZipResult to a separate file * refactor: move `addArchiveSize` to separate file
- Loading branch information
1 parent
89d11ca
commit c4b41ab
Showing
6 changed files
with
87 additions
and
36 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,19 @@ | ||
const { extname } = require('path') | ||
|
||
const { stat } = require('./fs') | ||
|
||
// Returns the input object with an additional `size` property containing the | ||
// size of the file at `path` when it is a ZIP archive. | ||
const addArchiveSize = async (result) => { | ||
const { path } = result | ||
|
||
if (extname(path) !== '.zip') { | ||
return result | ||
} | ||
|
||
const { size } = await stat(path) | ||
|
||
return { ...result, size } | ||
} | ||
|
||
module.exports = { addArchiveSize } |
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,36 @@ | ||
const { removeFalsy } = require('./remove_falsy') | ||
|
||
// Takes the result of zipping a function and formats it for output. | ||
const formatZipResult = (result) => { | ||
const { | ||
bundler, | ||
bundlerErrors, | ||
bundlerWarnings, | ||
config = {}, | ||
inputs, | ||
mainFile, | ||
name, | ||
nativeNodeModules, | ||
nodeModulesWithDynamicImports, | ||
path, | ||
runtime, | ||
size, | ||
} = result | ||
|
||
return removeFalsy({ | ||
bundler, | ||
bundlerErrors, | ||
bundlerWarnings, | ||
config, | ||
inputs, | ||
mainFile, | ||
name, | ||
nativeNodeModules, | ||
nodeModulesWithDynamicImports, | ||
path, | ||
runtime: runtime.name, | ||
size, | ||
}) | ||
} | ||
|
||
module.exports = { formatZipResult } |
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
c4b41ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏱ Benchmark results
largeDepsEsbuild: 11s
largeDepsNft: 43.8s
largeDepsZisi: 1m 3.3s