@size-limit/esbuild-why 9.0.0 → 10.0.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/index.js +22 -22
- package/package.json +4 -3
- package/report.js +6 -8
- package/valid-filename.js +7 -9
package/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { visualizer } from 'esbuild-visualizer'
|
|
2
|
+
import { writeFileSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import open from 'open'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { getReportName } from './report'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
async finally(config, check) {
|
|
11
|
+
let { esbuildVisualizerFile } = check
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (esbuildVisualizerFile) {
|
|
14
|
+
await open(esbuildVisualizerFile)
|
|
15
|
+
}
|
|
16
|
+
},
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
name: '@size-limit/esbuild-why',
|
|
19
|
+
async step81(config, check) {
|
|
20
|
+
if (config.why && check.esbuildMetafile) {
|
|
21
|
+
let result = await visualizer(check.esbuildMetafile)
|
|
22
|
+
let file = join(config.saveBundle ?? '', getReportName(config, check))
|
|
23
|
+
check.esbuildVisualizerFile = file
|
|
24
|
+
writeFileSync(file, result)
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
module.exports = [self]
|
|
28
|
+
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@size-limit/esbuild-why",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "esbuild plugin for Size Limit",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"size-limit",
|
|
7
8
|
"plugin",
|
|
@@ -17,10 +18,10 @@
|
|
|
17
18
|
"node": "^18.0.0 || >=20.0.0"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
|
-
"size-limit": "
|
|
21
|
+
"size-limit": "10.0.0"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"esbuild-visualizer": "^0.4.1",
|
|
24
|
-
"open": "^
|
|
25
|
+
"open": "^9.1.0"
|
|
25
26
|
}
|
|
26
27
|
}
|
package/report.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { isValidFilename } from './valid-filename'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return `esbuild-why-${index + 1}.html`
|
|
9
|
-
}
|
|
3
|
+
export function getReportName(config, check) {
|
|
4
|
+
if (config.checks.length === 1) return `esbuild-why.html`
|
|
5
|
+
if (isValidFilename(check.name)) return `esbuild-why-${check.name}.html`
|
|
6
|
+
let index = config.checks.findIndex(c => c.name === check.name)
|
|
7
|
+
return `esbuild-why-${index + 1}.html`
|
|
10
8
|
}
|
package/valid-filename.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return false
|
|
5
|
-
}
|
|
6
|
-
return (
|
|
7
|
-
!/[<>:"/\\|?*\u0000-\u001F]/g.test(string) &&
|
|
8
|
-
!/^(con|prn|aux|nul|com\d|lpt\d)$/i.test(string)
|
|
9
|
-
)
|
|
1
|
+
export function isValidFilename(string) {
|
|
2
|
+
if (!string || string.length > 255 || string === '.' || string === '..') {
|
|
3
|
+
return false
|
|
10
4
|
}
|
|
5
|
+
return (
|
|
6
|
+
!/[<>:"/\\|?*\u0000-\u001F]/g.test(string) &&
|
|
7
|
+
!/^(con|prn|aux|nul|com\d|lpt\d)$/i.test(string)
|
|
8
|
+
)
|
|
11
9
|
}
|