sonda 0.8.2 → 0.9.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/index.d.ts +57 -23
- package/dist/index.js +14 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sonda
|
|
2
2
|
|
|
3
|
-
Sonda is a universal
|
|
3
|
+
Sonda is a universal bundle analyzer and visualizer. It generates an interactive HTML report that is more accurate and detailed than some alternatives. The accuracy is achieved by analyzing source maps and showing the size of each module after tree-shaking and minification.
|
|
4
4
|
|
|
5
5
|
Sonda works with the following tools:
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ declare class Config implements Required<IntegrationOptions> {
|
|
|
11
11
|
constructor(options: Partial<IntegrationOptions> | Config, defaults: IntegrationOptions);
|
|
12
12
|
clone(): Config;
|
|
13
13
|
get enabled(): boolean;
|
|
14
|
+
get include(): AssetFilter;
|
|
15
|
+
get exclude(): AssetFilter;
|
|
14
16
|
get format(): Format;
|
|
15
17
|
get filename(): string;
|
|
16
18
|
get outputDir(): string;
|
|
@@ -33,15 +35,40 @@ interface UserOptions {
|
|
|
33
35
|
*/
|
|
34
36
|
enabled?: boolean;
|
|
35
37
|
/**
|
|
36
|
-
* Specifies
|
|
38
|
+
* Specifies a list of RegExp patterns used to match output assets to include in the report.
|
|
39
|
+
* By default, all assets are included.
|
|
40
|
+
*
|
|
41
|
+
* Patterns are matched against the relative asset paths as displayed in the report. For example,
|
|
42
|
+
* to include only JavaScript files, use `[ /\.js$/ ]`.
|
|
43
|
+
*
|
|
44
|
+
* @default null
|
|
45
|
+
*/
|
|
46
|
+
include?: AssetFilter;
|
|
47
|
+
/**
|
|
48
|
+
* Specifies a list of RegExp patterns used to match output assets to exclude from the report.
|
|
49
|
+
* By default, no assets are excluded, except for those with `.map` and `.d.ts` extensions, which
|
|
50
|
+
* are always excluded regardless of this setting.
|
|
51
|
+
*
|
|
52
|
+
* This option takes precedence over `include`.
|
|
53
|
+
*
|
|
54
|
+
* Patterns are matched against the relative asset paths as shown in the report. For example, to exclude all CSS files, use `[ /\.css$/ ]`.
|
|
55
|
+
*
|
|
56
|
+
* @default null
|
|
57
|
+
*/
|
|
58
|
+
exclude?: AssetFilter;
|
|
59
|
+
/**
|
|
60
|
+
* Specifies the output format of the report. Supported formats include:
|
|
61
|
+
*
|
|
62
|
+
* - `'html'` - An HTML file with a treemap visualization.
|
|
63
|
+
* - `'json'` - A JSON file.
|
|
37
64
|
*
|
|
38
65
|
* @default 'html'
|
|
39
66
|
*/
|
|
40
67
|
format?: Format;
|
|
41
68
|
/**
|
|
42
69
|
* Specifies the filename of the generated report. If this value is an absolute path,
|
|
43
|
-
* it
|
|
44
|
-
*
|
|
70
|
+
* it overrides the `outputDir` option.
|
|
71
|
+
*
|
|
45
72
|
* The default value includes placeholders like `[index]` and `[env]`, which are replaced
|
|
46
73
|
* during report generation.
|
|
47
74
|
*
|
|
@@ -58,7 +85,10 @@ interface UserOptions {
|
|
|
58
85
|
*/
|
|
59
86
|
filename?: string;
|
|
60
87
|
/**
|
|
61
|
-
* Specifies the
|
|
88
|
+
* Specifies the directory where the report will be saved. This can be a relative or absolute path. By default,
|
|
89
|
+
* the report is saved in a `.sonda` directory relative to the current working directory.
|
|
90
|
+
*
|
|
91
|
+
* The directory is created if it does not exist.
|
|
62
92
|
*
|
|
63
93
|
* @default '.sonda'
|
|
64
94
|
*/
|
|
@@ -72,47 +102,47 @@ interface UserOptions {
|
|
|
72
102
|
*/
|
|
73
103
|
open?: boolean;
|
|
74
104
|
/**
|
|
75
|
-
* Specifies whether to read
|
|
105
|
+
* Specifies whether to read source maps of imported modules.
|
|
76
106
|
*
|
|
77
|
-
* By default, external dependencies bundled into a single file appear as a single
|
|
78
|
-
*
|
|
79
|
-
* files of imported modules, if source maps are available.
|
|
107
|
+
* By default, external dependencies bundled into a single file appear as a single asset. When this option
|
|
108
|
+
* is enabled, the report includes the source files of imported modules, if their source maps are available.
|
|
80
109
|
*
|
|
81
|
-
* Enabling this option may increase
|
|
82
|
-
*
|
|
110
|
+
* Enabling this option may increase report generation time and reduce the accuracy of estimated GZIP
|
|
111
|
+
* and Brotli sizes.
|
|
83
112
|
*
|
|
84
113
|
* @default false
|
|
85
114
|
*/
|
|
86
115
|
deep?: boolean;
|
|
87
116
|
/**
|
|
88
|
-
* Specifies whether to include source maps of
|
|
89
|
-
*
|
|
117
|
+
* Specifies whether to include source maps of generated assets in the report to visualize which parts of
|
|
118
|
+
* the code contribute to the final asset size.
|
|
90
119
|
*
|
|
91
|
-
* ⚠️
|
|
92
|
-
*
|
|
93
|
-
* you share the report responsibly.
|
|
120
|
+
* ⚠️
|
|
121
|
+
* This option significantly increases the report size and embeds the **source code** of the assets.
|
|
122
|
+
* If you are working with proprietary code, ensure you share the report responsibly.
|
|
123
|
+
* ⚠️
|
|
94
124
|
*
|
|
95
125
|
* @default false
|
|
96
126
|
*/
|
|
97
127
|
sources?: boolean;
|
|
98
128
|
/**
|
|
99
|
-
* Specifies whether to calculate
|
|
129
|
+
* Specifies whether to calculate asset sizes after compression with GZIP.
|
|
100
130
|
*
|
|
101
|
-
* The report includes estimated compressed sizes for each file within an asset.
|
|
102
|
-
*
|
|
131
|
+
* The report also includes estimated compressed sizes for each file within an asset. These estimates are
|
|
132
|
+
* approximate and intended for general reference.
|
|
103
133
|
*
|
|
104
|
-
* Enabling this option may increase
|
|
134
|
+
* Enabling this option may increase report generation time.
|
|
105
135
|
*
|
|
106
136
|
* @default false
|
|
107
137
|
*/
|
|
108
138
|
gzip?: boolean;
|
|
109
139
|
/**
|
|
110
|
-
* Specifies whether to calculate
|
|
140
|
+
* Specifies whether to calculate asset sizes after compression with Brotli.
|
|
111
141
|
*
|
|
112
|
-
* The report includes estimated compressed sizes for each file within an asset.
|
|
113
|
-
*
|
|
142
|
+
* The report also includes estimated compressed sizes for each file within an asset. These estimates are
|
|
143
|
+
* approximate and intended for general reference.
|
|
114
144
|
*
|
|
115
|
-
* Enabling this option may increase
|
|
145
|
+
* Enabling this option may increase report generation time.
|
|
116
146
|
*
|
|
117
147
|
* @default false
|
|
118
148
|
*/
|
|
@@ -138,6 +168,10 @@ interface IntegrationOptions extends UserOptions {
|
|
|
138
168
|
*/
|
|
139
169
|
sourcesPathNormalizer?: SourcesPathNormalizer;
|
|
140
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Filter for including or excluding assets based on their paths.
|
|
173
|
+
*/
|
|
174
|
+
type AssetFilter = Array<RegExp> | null;
|
|
141
175
|
type Format = "html" | "json";
|
|
142
176
|
type Integration = "angular" | "astro" | "esbuild" | "next" | "nuxt" | "rolldown" | "rollup" | "rspack" | "sveltekit" | "vite" | "webpack" | "unknown";
|
|
143
177
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@ var Config = class Config {
|
|
|
17
17
|
}
|
|
18
18
|
this.#options = Object.assign({
|
|
19
19
|
enabled: true,
|
|
20
|
+
include: null,
|
|
21
|
+
exclude: null,
|
|
20
22
|
format: "html",
|
|
21
23
|
filename: "sonda_[index]",
|
|
22
24
|
outputDir: ".sonda",
|
|
@@ -35,6 +37,12 @@ var Config = class Config {
|
|
|
35
37
|
get enabled() {
|
|
36
38
|
return this.#options.enabled;
|
|
37
39
|
}
|
|
40
|
+
get include() {
|
|
41
|
+
return this.#options.include;
|
|
42
|
+
}
|
|
43
|
+
get exclude() {
|
|
44
|
+
return this.#options.exclude;
|
|
45
|
+
}
|
|
38
46
|
get format() {
|
|
39
47
|
return this.#options.format;
|
|
40
48
|
}
|
|
@@ -164,7 +172,7 @@ function hasIgnoredExtension(name) {
|
|
|
164
172
|
|
|
165
173
|
//#endregion
|
|
166
174
|
//#region package.json
|
|
167
|
-
var version = "0.
|
|
175
|
+
var version = "0.9.0";
|
|
168
176
|
|
|
169
177
|
//#endregion
|
|
170
178
|
//#region src/report/formatters/Formatter.ts
|
|
@@ -203,7 +211,7 @@ var Formatter = class {
|
|
|
203
211
|
async replaceIndex(path) {
|
|
204
212
|
if (!path.includes("[index]")) return path;
|
|
205
213
|
const { dir, base } = parse(path);
|
|
206
|
-
const regex = new RegExp("^" + base.replace("[index]", "(\\d+)") + "$");
|
|
214
|
+
const regex = /* @__PURE__ */ new RegExp("^" + base.replace("[index]", "(\\d+)") + "$");
|
|
207
215
|
const versions = (await getAllFiles(dir)).map((path$1) => basename(path$1).match(regex)).filter((match) => match !== null).map((match) => parseInt(match[1], 10));
|
|
208
216
|
const maxVersion = Math.max(...versions, -1);
|
|
209
217
|
const version$1 = String(maxVersion + 1);
|
|
@@ -607,6 +615,9 @@ var Report = class {
|
|
|
607
615
|
}
|
|
608
616
|
addAsset(name, entrypoints) {
|
|
609
617
|
if (hasIgnoredExtension(name)) return;
|
|
618
|
+
const normalizedName = normalizePath(name);
|
|
619
|
+
if (this.config.exclude?.some((pattern) => pattern.test(normalizedName))) return;
|
|
620
|
+
if (this.config.include && !this.config.include.some((pattern) => pattern.test(normalizedName))) return;
|
|
610
621
|
this.assets[name] = entrypoints;
|
|
611
622
|
}
|
|
612
623
|
async generate() {
|
|
@@ -784,7 +795,7 @@ var SondaWebpackPlugin = class {
|
|
|
784
795
|
* - (?:${ namespace })? - Non-capturing group that matches the optional namespace
|
|
785
796
|
* - ([^?]*) - Matches the path, which is everything up to the first "?" (if present)
|
|
786
797
|
*/
|
|
787
|
-
const sourceMapFilenameRegex = new RegExp(`(?:webpack://)?(?:${namespace})?([^?]*)`);
|
|
798
|
+
const sourceMapFilenameRegex = /* @__PURE__ */ new RegExp(`(?:webpack://)?(?:${namespace})?([^?]*)`);
|
|
788
799
|
compiler.hooks.afterEmit.tapPromise("SondaWebpackPlugin", async (compilation) => {
|
|
789
800
|
for (const mod of compilation.modules) {
|
|
790
801
|
const name = mod.nameForCondition();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonda",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Universal
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Universal bundle analyzer and visualizer that works with most popular bundlers and frameworks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundle",
|
|
7
7
|
"visualizer",
|