sonda 0.6.1 → 0.7.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 +47 -0
- package/README.md +16 -9
- package/dist/entrypoints/astro.cjs +26 -0
- package/dist/entrypoints/astro.cjs.map +1 -0
- package/dist/entrypoints/astro.d.ts +3 -0
- package/dist/entrypoints/astro.mjs +25 -0
- package/dist/entrypoints/astro.mjs.map +1 -0
- package/dist/entrypoints/esbuild.cjs +39 -0
- package/dist/entrypoints/esbuild.cjs.map +1 -0
- package/dist/entrypoints/esbuild.d.ts +3 -0
- package/dist/entrypoints/esbuild.mjs +38 -0
- package/dist/entrypoints/esbuild.mjs.map +1 -0
- package/dist/entrypoints/next.cjs +26 -0
- package/dist/entrypoints/next.cjs.map +1 -0
- package/dist/entrypoints/next.d.ts +3 -0
- package/dist/entrypoints/next.mjs +25 -0
- package/dist/entrypoints/next.mjs.map +1 -0
- package/dist/entrypoints/nuxt.cjs +26 -0
- package/dist/entrypoints/nuxt.cjs.map +1 -0
- package/dist/entrypoints/nuxt.d.ts +3 -0
- package/dist/entrypoints/nuxt.mjs +25 -0
- package/dist/entrypoints/nuxt.mjs.map +1 -0
- package/dist/entrypoints/parcel.cjs +59 -0
- package/dist/entrypoints/parcel.cjs.map +1 -0
- package/dist/entrypoints/parcel.d.ts +6 -0
- package/dist/entrypoints/parcel.mjs +58 -0
- package/dist/entrypoints/parcel.mjs.map +1 -0
- package/dist/entrypoints/rollup.cjs +4 -0
- package/dist/entrypoints/rollup.d.ts +3 -0
- package/dist/entrypoints/rollup.mjs +4 -0
- package/dist/entrypoints/sveltekit.cjs +25 -0
- package/dist/entrypoints/sveltekit.cjs.map +1 -0
- package/dist/entrypoints/sveltekit.d.ts +3 -0
- package/dist/entrypoints/sveltekit.mjs +24 -0
- package/dist/entrypoints/sveltekit.mjs.map +1 -0
- package/dist/entrypoints/webpack.cjs +4 -0
- package/dist/entrypoints/webpack.d.ts +7 -0
- package/dist/entrypoints/webpack.mjs +4 -0
- package/dist/index.cjs +8 -490
- package/dist/index.d.ts +4 -5
- package/dist/index.html +4 -4
- package/dist/index.mjs +3 -0
- package/dist/report/formats.d.ts +3 -0
- package/dist/report/generate.d.ts +2 -3
- package/dist/rollup.cjs +40 -0
- package/dist/rollup.cjs.map +1 -0
- package/dist/rollup.mjs +34 -0
- package/dist/rollup.mjs.map +1 -0
- package/dist/sourcemap/bytes.d.ts +3 -4
- package/dist/sourcemap/map.d.ts +1 -2
- package/dist/src.cjs +398 -0
- package/dist/src.cjs.map +1 -0
- package/dist/src.mjs +333 -0
- package/dist/src.mjs.map +1 -0
- package/dist/types.d.ts +44 -29
- package/dist/utils.d.ts +2 -3
- package/dist/webpack.cjs +55 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.mjs +49 -0
- package/dist/webpack.mjs.map +1 -0
- package/package.json +58 -5
- package/dist/bundlers/esbuild.d.ts +0 -4
- package/dist/bundlers/esbuild.d.ts.map +0 -1
- package/dist/bundlers/rollup.d.ts +0 -4
- package/dist/bundlers/rollup.d.ts.map +0 -1
- package/dist/bundlers/webpack.d.ts +0 -8
- package/dist/bundlers/webpack.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -485
- package/dist/index.js.map +0 -1
- package/dist/report/generate.d.ts.map +0 -1
- package/dist/report.d.ts +0 -4
- package/dist/report.d.ts.map +0 -1
- package/dist/sourcemap/bytes.d.ts.map +0 -1
- package/dist/sourcemap/map.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Changes
|
|
6
|
+
|
|
7
|
+
#### New import paths
|
|
8
|
+
|
|
9
|
+
This release includes a breaking change. Now every bundler and framework has its own unique import path. For example, if you are using Vite, this is how the import has changed:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
- import { SondaRollupPlugin } from 'sonda';
|
|
13
|
+
+ import Sonda from 'sonda/vite';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Please refer to the [Getting started](https://sonda.dev/getting-started.html) page for more information.
|
|
17
|
+
|
|
18
|
+
#### New integrations
|
|
19
|
+
|
|
20
|
+
Sonda now has integrations for the following frameworks:
|
|
21
|
+
|
|
22
|
+
* [Next.js](https://sonda.dev/frameworks/nextjs.html)
|
|
23
|
+
* [Nuxt](https://sonda.dev/frameworks/nuxt.html)
|
|
24
|
+
* [Astro](https://sonda.dev/frameworks/astro.html)
|
|
25
|
+
* [SvelteKit](https://sonda.dev/frameworks/sveltekit.html)
|
|
26
|
+
|
|
27
|
+
#### New `enabled` option
|
|
28
|
+
|
|
29
|
+
You can now control whether the Sonda plugin is enabled or not using the `enabled` option.
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 215b289: Create an individual export path for each integration
|
|
34
|
+
- 215b289: Add Next.js integration
|
|
35
|
+
- 519ddea: Add Nuxt integration
|
|
36
|
+
- b450e5b: Add Astro integration
|
|
37
|
+
- dc237e5: Add SvelteKit integration
|
|
38
|
+
- 215b289: Add the `enabled` option to control whether to run the plugin
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- 215b289: Update dependencies
|
|
43
|
+
|
|
44
|
+
## 0.6.2
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- ff135df: Add `mjs` and `cjs` as accepted asset extensions
|
|
49
|
+
|
|
3
50
|
## 0.6.1
|
|
4
51
|
|
|
5
52
|
Sonda has a new home. You can now visit [https://sonda.dev](https://sonda.dev) for installation and usage instructions, or try it out at [https://sonda.dev/demo](https://sonda.dev/demo).
|
package/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
# Sonda
|
|
2
2
|
|
|
3
|
-
Sonda is a universal visualizer and analyzer for JavaScript and CSS bundles. It
|
|
4
|
-
|
|
5
|
-
Sonda
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
3
|
+
Sonda is a universal visualizer and analyzer for JavaScript and CSS bundles. 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
|
+
|
|
5
|
+
Sonda works with the following tools:
|
|
6
|
+
|
|
7
|
+
* **Bundlers**
|
|
8
|
+
* Vite
|
|
9
|
+
* Rollup
|
|
10
|
+
* Rolldown
|
|
11
|
+
* esbuild
|
|
12
|
+
* webpack
|
|
13
|
+
* Rspack
|
|
14
|
+
* **Frameworks**
|
|
15
|
+
* Next.js
|
|
16
|
+
* Nuxt
|
|
17
|
+
* Astro
|
|
18
|
+
* SvelteKit
|
|
12
19
|
|
|
13
20
|
## Installation
|
|
14
21
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../src.cjs');
|
|
3
|
+
const require_rollup = require('../rollup.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/astro.ts
|
|
6
|
+
function SondaAstroPlugin(options = {}) {
|
|
7
|
+
return {
|
|
8
|
+
name: "sonda/astro",
|
|
9
|
+
hooks: { "astro:build:setup"({ vite, target }) {
|
|
10
|
+
if (options.enabled === false) return;
|
|
11
|
+
options.format ??= "html";
|
|
12
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
13
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaAstroPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
14
|
+
const generateForServer = options.server ?? false;
|
|
15
|
+
if (target === "server" && !generateForServer) return;
|
|
16
|
+
const sondaOptions = Object.assign({}, options);
|
|
17
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", target);
|
|
18
|
+
vite.plugins ??= [];
|
|
19
|
+
vite.plugins.push(require_rollup.SondaRollupPlugin(sondaOptions));
|
|
20
|
+
} }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
module.exports = SondaAstroPlugin;
|
|
26
|
+
//# sourceMappingURL=astro.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.cjs","names":["options: Partial<FrameworkUserOptions>"],"sources":["../../src/entrypoints/astro.ts"],"sourcesContent":["import Sonda from './rollup';\nimport type { AstroIntegration } from 'astro';\nimport type { FrameworkUserOptions } from '../types';\n\nexport default function SondaAstroPlugin( options: Partial<FrameworkUserOptions> = {} ): AstroIntegration {\n return {\n name: 'sonda/astro',\n hooks: {\n 'astro:build:setup'( { vite, target } ) {\n if ( options.enabled === false ) {\n return;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Nuxt runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaAstroPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n const generateForServer = options.server ?? false;\n\n // Do not generate report for the server build unless explicitly enabled\n if ( target === 'server' && !generateForServer ) {\n return;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', target )\n\n vite.plugins ??= [];\n vite.plugins.push( Sonda( sondaOptions ) );\n }\n }\n };\n}\n"],"mappings":";;;;;AAIe,SAAS,iBAAkBA,UAAyC,CAAE,GAAqB;AACxG,QAAO;EACL,MAAM;EACN,OAAO,EACL,oBAAqB,EAAE,MAAM,QAAQ,EAAG;AACtC,OAAK,QAAQ,YAAY,MACvB;AAGF,WAAQ,WAAW;AACnB,WAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,QAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;GAGnB,MAAM,oBAAoB,QAAQ,UAAU;AAG5C,OAAK,WAAW,aAAa,kBAC3B;GAIF,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,OAAQ;AAEzE,QAAK,YAAY,CAAE;AACnB,QAAK,QAAQ,KAAM,iCAAO,aAAc,CAAE;EAC3C,EACF;CACF;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../src.mjs";
|
|
2
|
+
import { SondaRollupPlugin } from "../rollup.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/astro.ts
|
|
5
|
+
function SondaAstroPlugin(options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
name: "sonda/astro",
|
|
8
|
+
hooks: { "astro:build:setup"({ vite, target }) {
|
|
9
|
+
if (options.enabled === false) return;
|
|
10
|
+
options.format ??= "html";
|
|
11
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
12
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaAstroPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
13
|
+
const generateForServer = options.server ?? false;
|
|
14
|
+
if (target === "server" && !generateForServer) return;
|
|
15
|
+
const sondaOptions = Object.assign({}, options);
|
|
16
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", target);
|
|
17
|
+
vite.plugins ??= [];
|
|
18
|
+
vite.plugins.push(SondaRollupPlugin(sondaOptions));
|
|
19
|
+
} }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { SondaAstroPlugin as default };
|
|
25
|
+
//# sourceMappingURL=astro.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.mjs","names":["options: Partial<FrameworkUserOptions>"],"sources":["../../src/entrypoints/astro.ts"],"sourcesContent":["import Sonda from './rollup';\nimport type { AstroIntegration } from 'astro';\nimport type { FrameworkUserOptions } from '../types';\n\nexport default function SondaAstroPlugin( options: Partial<FrameworkUserOptions> = {} ): AstroIntegration {\n return {\n name: 'sonda/astro',\n hooks: {\n 'astro:build:setup'( { vite, target } ) {\n if ( options.enabled === false ) {\n return;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Nuxt runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaAstroPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n const generateForServer = options.server ?? false;\n\n // Do not generate report for the server build unless explicitly enabled\n if ( target === 'server' && !generateForServer ) {\n return;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', target )\n\n vite.plugins ??= [];\n vite.plugins.push( Sonda( sondaOptions ) );\n }\n }\n };\n}\n"],"mappings":";;;;AAIe,SAAS,iBAAkBA,UAAyC,CAAE,GAAqB;AACxG,QAAO;EACL,MAAM;EACN,OAAO,EACL,oBAAqB,EAAE,MAAM,QAAQ,EAAG;AACtC,OAAK,QAAQ,YAAY,MACvB;AAGF,WAAQ,WAAW;AACnB,WAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,QAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;GAGnB,MAAM,oBAAoB,QAAQ,UAAU;AAG5C,OAAK,WAAW,aAAa,kBAC3B;GAIF,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,OAAQ;AAEzE,QAAK,YAAY,CAAE;AACnB,QAAK,QAAQ,KAAM,kBAAO,aAAc,CAAE;EAC3C,EACF;CACF;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const require_src = require('../src.cjs');
|
|
3
|
+
const path = require_src.__toESM(require("path"));
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/esbuild.ts
|
|
6
|
+
function SondaEsbuildPlugin(options = {}) {
|
|
7
|
+
return {
|
|
8
|
+
name: "sonda",
|
|
9
|
+
setup(build) {
|
|
10
|
+
if (options.enabled === false) return;
|
|
11
|
+
build.initialOptions.metafile = true;
|
|
12
|
+
options.detailed = false;
|
|
13
|
+
build.onEnd((result) => {
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
const inputs = Object.entries(result.metafile.inputs).reduce((acc, [path$1, data]) => {
|
|
16
|
+
acc[path$1] = {
|
|
17
|
+
bytes: data.bytes,
|
|
18
|
+
format: data.format ?? "unknown",
|
|
19
|
+
imports: data.imports.map((data$1) => data$1.path),
|
|
20
|
+
belongsTo: null
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Because esbuild already reads the existing source maps, there may be
|
|
24
|
+
* cases where some report "outputs" include "inputs" that don't exist
|
|
25
|
+
* in the main "inputs" object. To avoid this, we parse each esbuild
|
|
26
|
+
* input and add its sources to the "inputs" object.
|
|
27
|
+
*/
|
|
28
|
+
require_src.addSourcesToInputs((0, path.resolve)(cwd, path$1), acc);
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
return require_src.generateReportFromAssets(Object.keys(result.metafile.outputs).map((path$1) => (0, path.resolve)(cwd, path$1)), inputs, options);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
module.exports = SondaEsbuildPlugin;
|
|
39
|
+
//# sourceMappingURL=esbuild.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.cjs","names":["options: Partial<UserOptions>","path","data"],"sources":["../../src/entrypoints/esbuild.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { generateReportFromAssets, addSourcesToInputs } from '../index.js';\nimport type { Plugin } from 'esbuild';\nimport type { JsonReport, UserOptions } from '../types.js';\n\nexport default function SondaEsbuildPlugin( options: Partial<UserOptions> = {} ): Plugin {\n\treturn {\n\t\tname: 'sonda',\n\t\tsetup( build ) {\n\t\t\tif ( options.enabled === false ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tbuild.initialOptions.metafile = true;\n\n\t\t\t// Esbuild already reads the existing source maps, so there's no need to do it again\n\t\t\toptions.detailed = false;\n\n\t\t\tbuild.onEnd( result => {\n\t\t\t\tconst cwd = process.cwd();\n\t\t\t\tconst inputs = Object\n\t\t\t\t\t.entries( result.metafile!.inputs )\n\t\t\t\t\t.reduce( ( acc, [ path, data ] ) => {\n\t\t\t\t\t\tacc[ path ] = {\n\t\t\t\t\t\t\tbytes: data.bytes,\n\t\t\t\t\t\t\tformat: data.format ?? 'unknown',\n\t\t\t\t\t\t\timports: data.imports.map( data => data.path ),\n\t\t\t\t\t\t\tbelongsTo: null,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Because esbuild already reads the existing source maps, there may be\n\t\t\t\t\t\t * cases where some report \"outputs\" include \"inputs\" that don't exist\n\t\t\t\t\t\t * in the main \"inputs\" object. To avoid this, we parse each esbuild\n\t\t\t\t\t\t * input and add its sources to the \"inputs\" object.\n\t\t\t\t\t\t */\n\t\t\t\t\t\taddSourcesToInputs(\n\t\t\t\t\t\t\tresolve( cwd, path ),\n\t\t\t\t\t\t\tacc\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}, {} as JsonReport[ 'inputs' ] );\n\n\t\t\t\treturn generateReportFromAssets(\n\t\t\t\t\tObject.keys( result.metafile!.outputs ).map( path => resolve( cwd, path ) ),\n\t\t\t\t\tinputs,\n\t\t\t\t\toptions\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\t};\n}\n"],"mappings":";;;;;AAKe,SAAS,mBAAoBA,UAAgC,CAAE,GAAW;AACxF,QAAO;EACN,MAAM;EACN,MAAO,OAAQ;AACd,OAAK,QAAQ,YAAY,MACxB;AAGD,SAAM,eAAe,WAAW;AAGhC,WAAQ,WAAW;AAEnB,SAAM,MAAO,YAAU;IACtB,MAAM,MAAM,QAAQ,KAAK;IACzB,MAAM,SAAS,OACb,QAAS,OAAO,SAAU,OAAQ,CAClC,OAAQ,CAAE,KAAK,CAAEC,QAAM,KAAM,KAAM;AACnC,SAAKA,UAAS;MACb,OAAO,KAAK;MACZ,QAAQ,KAAK,UAAU;MACvB,SAAS,KAAK,QAAQ,IAAK,YAAQC,OAAK,KAAM;MAC9C,WAAW;KACX;;;;;;;AAQD,oCACC,kBAAS,KAAKD,OAAM,EACpB,IACA;AAED,YAAO;IACP,GAAE,CAAE,EAA4B;AAElC,WAAO,qCACN,OAAO,KAAM,OAAO,SAAU,QAAS,CAAC,IAAK,YAAQ,kBAAS,KAAKA,OAAM,CAAE,EAC3E,QACA,QACA;GACD,EAAE;EACH;CACD;AACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { addSourcesToInputs, generateReportFromAssets } from "../src.mjs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/esbuild.ts
|
|
5
|
+
function SondaEsbuildPlugin(options = {}) {
|
|
6
|
+
return {
|
|
7
|
+
name: "sonda",
|
|
8
|
+
setup(build) {
|
|
9
|
+
if (options.enabled === false) return;
|
|
10
|
+
build.initialOptions.metafile = true;
|
|
11
|
+
options.detailed = false;
|
|
12
|
+
build.onEnd((result) => {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const inputs = Object.entries(result.metafile.inputs).reduce((acc, [path, data]) => {
|
|
15
|
+
acc[path] = {
|
|
16
|
+
bytes: data.bytes,
|
|
17
|
+
format: data.format ?? "unknown",
|
|
18
|
+
imports: data.imports.map((data$1) => data$1.path),
|
|
19
|
+
belongsTo: null
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Because esbuild already reads the existing source maps, there may be
|
|
23
|
+
* cases where some report "outputs" include "inputs" that don't exist
|
|
24
|
+
* in the main "inputs" object. To avoid this, we parse each esbuild
|
|
25
|
+
* input and add its sources to the "inputs" object.
|
|
26
|
+
*/
|
|
27
|
+
addSourcesToInputs(resolve(cwd, path), acc);
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
return generateReportFromAssets(Object.keys(result.metafile.outputs).map((path) => resolve(cwd, path)), inputs, options);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { SondaEsbuildPlugin as default };
|
|
38
|
+
//# sourceMappingURL=esbuild.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.mjs","names":["options: Partial<UserOptions>","data"],"sources":["../../src/entrypoints/esbuild.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { generateReportFromAssets, addSourcesToInputs } from '../index.js';\nimport type { Plugin } from 'esbuild';\nimport type { JsonReport, UserOptions } from '../types.js';\n\nexport default function SondaEsbuildPlugin( options: Partial<UserOptions> = {} ): Plugin {\n\treturn {\n\t\tname: 'sonda',\n\t\tsetup( build ) {\n\t\t\tif ( options.enabled === false ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tbuild.initialOptions.metafile = true;\n\n\t\t\t// Esbuild already reads the existing source maps, so there's no need to do it again\n\t\t\toptions.detailed = false;\n\n\t\t\tbuild.onEnd( result => {\n\t\t\t\tconst cwd = process.cwd();\n\t\t\t\tconst inputs = Object\n\t\t\t\t\t.entries( result.metafile!.inputs )\n\t\t\t\t\t.reduce( ( acc, [ path, data ] ) => {\n\t\t\t\t\t\tacc[ path ] = {\n\t\t\t\t\t\t\tbytes: data.bytes,\n\t\t\t\t\t\t\tformat: data.format ?? 'unknown',\n\t\t\t\t\t\t\timports: data.imports.map( data => data.path ),\n\t\t\t\t\t\t\tbelongsTo: null,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Because esbuild already reads the existing source maps, there may be\n\t\t\t\t\t\t * cases where some report \"outputs\" include \"inputs\" that don't exist\n\t\t\t\t\t\t * in the main \"inputs\" object. To avoid this, we parse each esbuild\n\t\t\t\t\t\t * input and add its sources to the \"inputs\" object.\n\t\t\t\t\t\t */\n\t\t\t\t\t\taddSourcesToInputs(\n\t\t\t\t\t\t\tresolve( cwd, path ),\n\t\t\t\t\t\t\tacc\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}, {} as JsonReport[ 'inputs' ] );\n\n\t\t\t\treturn generateReportFromAssets(\n\t\t\t\t\tObject.keys( result.metafile!.outputs ).map( path => resolve( cwd, path ) ),\n\t\t\t\t\tinputs,\n\t\t\t\t\toptions\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\t};\n}\n"],"mappings":";;;;AAKe,SAAS,mBAAoBA,UAAgC,CAAE,GAAW;AACxF,QAAO;EACN,MAAM;EACN,MAAO,OAAQ;AACd,OAAK,QAAQ,YAAY,MACxB;AAGD,SAAM,eAAe,WAAW;AAGhC,WAAQ,WAAW;AAEnB,SAAM,MAAO,YAAU;IACtB,MAAM,MAAM,QAAQ,KAAK;IACzB,MAAM,SAAS,OACb,QAAS,OAAO,SAAU,OAAQ,CAClC,OAAQ,CAAE,KAAK,CAAE,MAAM,KAAM,KAAM;AACnC,SAAK,QAAS;MACb,OAAO,KAAK;MACZ,QAAQ,KAAK,UAAU;MACvB,SAAS,KAAK,QAAQ,IAAK,YAAQC,OAAK,KAAM;MAC9C,WAAW;KACX;;;;;;;AAQD,wBACC,QAAS,KAAK,KAAM,EACpB,IACA;AAED,YAAO;IACP,GAAE,CAAE,EAA4B;AAElC,WAAO,yBACN,OAAO,KAAM,OAAO,SAAU,QAAS,CAAC,IAAK,UAAQ,QAAS,KAAK,KAAM,CAAE,EAC3E,QACA,QACA;GACD,EAAE;EACH;CACD;AACD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../src.cjs');
|
|
3
|
+
const require_webpack = require('../webpack.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/next.ts
|
|
6
|
+
function SondaNextPlugin(options = {}) {
|
|
7
|
+
return function Sonda(nextConfig = {}) {
|
|
8
|
+
if (options.enabled === false) return nextConfig;
|
|
9
|
+
options.format ??= "html";
|
|
10
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
11
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaNextPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
12
|
+
const generateForServer = options.server ?? false;
|
|
13
|
+
return Object.assign({}, nextConfig, { webpack(config, { nextRuntime, isServer }) {
|
|
14
|
+
const env = nextRuntime || "client";
|
|
15
|
+
if (env === "edge" || isServer && !generateForServer) return config;
|
|
16
|
+
const sondaOptions = Object.assign({}, options);
|
|
17
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", env);
|
|
18
|
+
config.plugins.push(new require_webpack.SondaWebpackPlugin(sondaOptions));
|
|
19
|
+
return config;
|
|
20
|
+
} });
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
module.exports = SondaNextPlugin;
|
|
26
|
+
//# sourceMappingURL=next.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.cjs","names":["options: Partial<FrameworkUserOptions>","nextConfig: NextConfig","SondaWebpack"],"sources":["../../src/entrypoints/next.ts"],"sourcesContent":["import SondaWebpack from './webpack';\nimport type { NextConfig } from 'next';\nimport type { FrameworkUserOptions } from '../types.js';\n\nexport default function SondaNextPlugin( options: Partial<FrameworkUserOptions> = {} ) {\n return function Sonda( nextConfig: NextConfig = {} ): NextConfig {\n if ( options.enabled === false ) {\n return nextConfig;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Next.js runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaNextPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n const generateForServer = options.server ?? false;\n\n return Object.assign( {}, nextConfig, {\n webpack( config, { nextRuntime, isServer } ) {\n const env = nextRuntime || 'client';\n\n // Do not generate report for...\n if (\n // ... the `edge` build because none of its files have source maps\n env === 'edge'\n\n // ... the server build unless explicitly enabled\n || ( isServer && !generateForServer )\n ) {\n return config;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', env );\n\n // Add the Sonda plugin to the Webpack configuration\n config.plugins.push(\n new SondaWebpack( sondaOptions )\n );\n\n return config;\n }\n } satisfies NextConfig );\n }\n}\n"],"mappings":";;;;;AAIe,SAAS,gBAAiBA,UAAyC,CAAE,GAAG;AACrF,QAAO,SAAS,MAAOC,aAAyB,CAAE,GAAe;AAC/D,MAAK,QAAQ,YAAY,MACvB,QAAO;AAGT,UAAQ,WAAW;AACnB,UAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,OAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;EAGnB,MAAM,oBAAoB,QAAQ,UAAU;AAE5C,SAAO,OAAO,OAAQ,CAAE,GAAE,YAAY,EACpC,QAAS,QAAQ,EAAE,aAAa,UAAU,EAAG;GAC3C,MAAM,MAAM,eAAe;AAG3B,OAEE,QAAQ,UAGH,aAAa,kBAElB,QAAO;GAIT,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,IAAK;AAGtE,UAAO,QAAQ,KACb,IAAIC,mCAAc,cACnB;AAED,UAAO;EACR,EACF,EAAuB;CACzB;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../src.mjs";
|
|
2
|
+
import { SondaWebpackPlugin } from "../webpack.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/next.ts
|
|
5
|
+
function SondaNextPlugin(options = {}) {
|
|
6
|
+
return function Sonda(nextConfig = {}) {
|
|
7
|
+
if (options.enabled === false) return nextConfig;
|
|
8
|
+
options.format ??= "html";
|
|
9
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
10
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaNextPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
11
|
+
const generateForServer = options.server ?? false;
|
|
12
|
+
return Object.assign({}, nextConfig, { webpack(config, { nextRuntime, isServer }) {
|
|
13
|
+
const env = nextRuntime || "client";
|
|
14
|
+
if (env === "edge" || isServer && !generateForServer) return config;
|
|
15
|
+
const sondaOptions = Object.assign({}, options);
|
|
16
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", env);
|
|
17
|
+
config.plugins.push(new SondaWebpackPlugin(sondaOptions));
|
|
18
|
+
return config;
|
|
19
|
+
} });
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { SondaNextPlugin as default };
|
|
25
|
+
//# sourceMappingURL=next.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.mjs","names":["options: Partial<FrameworkUserOptions>","nextConfig: NextConfig","SondaWebpack"],"sources":["../../src/entrypoints/next.ts"],"sourcesContent":["import SondaWebpack from './webpack';\nimport type { NextConfig } from 'next';\nimport type { FrameworkUserOptions } from '../types.js';\n\nexport default function SondaNextPlugin( options: Partial<FrameworkUserOptions> = {} ) {\n return function Sonda( nextConfig: NextConfig = {} ): NextConfig {\n if ( options.enabled === false ) {\n return nextConfig;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Next.js runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaNextPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n const generateForServer = options.server ?? false;\n\n return Object.assign( {}, nextConfig, {\n webpack( config, { nextRuntime, isServer } ) {\n const env = nextRuntime || 'client';\n\n // Do not generate report for...\n if (\n // ... the `edge` build because none of its files have source maps\n env === 'edge'\n\n // ... the server build unless explicitly enabled\n || ( isServer && !generateForServer )\n ) {\n return config;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', env );\n\n // Add the Sonda plugin to the Webpack configuration\n config.plugins.push(\n new SondaWebpack( sondaOptions )\n );\n\n return config;\n }\n } satisfies NextConfig );\n }\n}\n"],"mappings":";;;;AAIe,SAAS,gBAAiBA,UAAyC,CAAE,GAAG;AACrF,QAAO,SAAS,MAAOC,aAAyB,CAAE,GAAe;AAC/D,MAAK,QAAQ,YAAY,MACvB,QAAO;AAGT,UAAQ,WAAW;AACnB,UAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,OAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;EAGnB,MAAM,oBAAoB,QAAQ,UAAU;AAE5C,SAAO,OAAO,OAAQ,CAAE,GAAE,YAAY,EACpC,QAAS,QAAQ,EAAE,aAAa,UAAU,EAAG;GAC3C,MAAM,MAAM,eAAe;AAG3B,OAEE,QAAQ,UAGH,aAAa,kBAElB,QAAO;GAIT,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,IAAK;AAGtE,UAAO,QAAQ,KACb,IAAIC,mBAAc,cACnB;AAED,UAAO;EACR,EACF,EAAuB;CACzB;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../src.cjs');
|
|
3
|
+
const require_rollup = require('../rollup.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/nuxt.ts
|
|
6
|
+
function SondaNuxtPlugin(options = {}) {
|
|
7
|
+
return function SondaNuxtPlugin$1(_, nuxt) {
|
|
8
|
+
if (options.enabled === false) return;
|
|
9
|
+
options.format ??= "html";
|
|
10
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
11
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaNuxtPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
12
|
+
nuxt.hook("vite:extendConfig", (config, { isClient, isServer }) => {
|
|
13
|
+
const env = isClient ? "client" : "nitro";
|
|
14
|
+
const generateForServer = options.server ?? false;
|
|
15
|
+
if (isServer && !generateForServer) return;
|
|
16
|
+
const sondaOptions = Object.assign({}, options);
|
|
17
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", env);
|
|
18
|
+
config.plugins ??= [];
|
|
19
|
+
config.plugins.push(require_rollup.SondaRollupPlugin(sondaOptions));
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
module.exports = SondaNuxtPlugin;
|
|
26
|
+
//# sourceMappingURL=nuxt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.cjs","names":["options: Partial<FrameworkUserOptions>","SondaNuxtPlugin","nuxt: Nuxt"],"sources":["../../src/entrypoints/nuxt.ts"],"sourcesContent":["import Sonda from './rollup';\nimport type { NuxtModule, Nuxt } from '@nuxt/schema';\nimport type { FrameworkUserOptions } from '../types';\n\nexport default function SondaNuxtPlugin( options: Partial<FrameworkUserOptions> = {} ): NuxtModule {\n return function SondaNuxtPlugin( _, nuxt: Nuxt ): void {\n if ( options.enabled === false ) {\n return;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Nuxt runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaNuxtPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n nuxt.hook( 'vite:extendConfig', ( config, { isClient, isServer } ) => {\n const env = isClient ? 'client' : 'nitro';\n const generateForServer = options.server ?? false;\n\n // Do not generate report for the server build unless explicitly enabled\n if ( isServer && !generateForServer ) {\n return;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', env )\n\n // Add the Sonda plugin to the Vite configuration\n config.plugins ??= [];\n config.plugins.push( Sonda( sondaOptions ) );\n } )\n }\n}\n"],"mappings":";;;;;AAIe,SAAS,gBAAiBA,UAAyC,CAAE,GAAe;AACjG,QAAO,SAASC,kBAAiB,GAAGC,MAAmB;AACrD,MAAK,QAAQ,YAAY,MACvB;AAGF,UAAQ,WAAW;AACnB,UAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,OAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;AAGnB,OAAK,KAAM,qBAAqB,CAAE,QAAQ,EAAE,UAAU,UAAU,KAAM;GACpE,MAAM,MAAM,WAAW,WAAW;GAClC,MAAM,oBAAoB,QAAQ,UAAU;AAG5C,OAAK,aAAa,kBAChB;GAIF,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,IAAK;AAGtE,UAAO,YAAY,CAAE;AACrB,UAAO,QAAQ,KAAM,iCAAO,aAAc,CAAE;EAC7C,EAAE;CACJ;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../src.mjs";
|
|
2
|
+
import { SondaRollupPlugin } from "../rollup.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/nuxt.ts
|
|
5
|
+
function SondaNuxtPlugin(options = {}) {
|
|
6
|
+
return function SondaNuxtPlugin$1(_, nuxt) {
|
|
7
|
+
if (options.enabled === false) return;
|
|
8
|
+
options.format ??= "html";
|
|
9
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
10
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaNuxtPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
11
|
+
nuxt.hook("vite:extendConfig", (config, { isClient, isServer }) => {
|
|
12
|
+
const env = isClient ? "client" : "nitro";
|
|
13
|
+
const generateForServer = options.server ?? false;
|
|
14
|
+
if (isServer && !generateForServer) return;
|
|
15
|
+
const sondaOptions = Object.assign({}, options);
|
|
16
|
+
sondaOptions.filename = sondaOptions.filename.replace("[env]", env);
|
|
17
|
+
config.plugins ??= [];
|
|
18
|
+
config.plugins.push(SondaRollupPlugin(sondaOptions));
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { SondaNuxtPlugin as default };
|
|
25
|
+
//# sourceMappingURL=nuxt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.mjs","names":["options: Partial<FrameworkUserOptions>","SondaNuxtPlugin","nuxt: Nuxt"],"sources":["../../src/entrypoints/nuxt.ts"],"sourcesContent":["import Sonda from './rollup';\nimport type { NuxtModule, Nuxt } from '@nuxt/schema';\nimport type { FrameworkUserOptions } from '../types';\n\nexport default function SondaNuxtPlugin( options: Partial<FrameworkUserOptions> = {} ): NuxtModule {\n return function SondaNuxtPlugin( _, nuxt: Nuxt ): void {\n if ( options.enabled === false ) {\n return;\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // Nuxt runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaNuxtPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n nuxt.hook( 'vite:extendConfig', ( config, { isClient, isServer } ) => {\n const env = isClient ? 'client' : 'nitro';\n const generateForServer = options.server ?? false;\n\n // Do not generate report for the server build unless explicitly enabled\n if ( isServer && !generateForServer ) {\n return;\n }\n\n // Because this configuration is shared between multiple builds, we need to clone it\n const sondaOptions = Object.assign( {}, options );\n\n // Replace the \"[env]\" token with the current build type\n sondaOptions.filename = sondaOptions.filename!.replace( '[env]', env )\n\n // Add the Sonda plugin to the Vite configuration\n config.plugins ??= [];\n config.plugins.push( Sonda( sondaOptions ) );\n } )\n }\n}\n"],"mappings":";;;;AAIe,SAAS,gBAAiBA,UAAyC,CAAE,GAAe;AACjG,QAAO,SAASC,kBAAiB,GAAGC,MAAmB;AACrD,MAAK,QAAQ,YAAY,MACvB;AAGF,UAAQ,WAAW;AACnB,UAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,OAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;AAGnB,OAAK,KAAM,qBAAqB,CAAE,QAAQ,EAAE,UAAU,UAAU,KAAM;GACpE,MAAM,MAAM,WAAW,WAAW;GAClC,MAAM,oBAAoB,QAAQ,UAAU;AAG5C,OAAK,aAAa,kBAChB;GAIF,MAAM,eAAe,OAAO,OAAQ,CAAE,GAAE,QAAS;AAGjD,gBAAa,WAAW,aAAa,SAAU,QAAS,SAAS,IAAK;AAGtE,UAAO,YAAY,CAAE;AACrB,UAAO,QAAQ,KAAM,kBAAO,aAAc,CAAE;EAC7C,EAAE;CACJ;AACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const require_src = require('../src.cjs');
|
|
3
|
+
const path = require_src.__toESM(require("path"));
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/parcel.ts
|
|
6
|
+
var Reporter = class {
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this[Symbol.for("parcel-plugin-config")] = opts;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const SondaParcelPlugin = new Reporter({
|
|
12
|
+
async loadConfig({ config }) {
|
|
13
|
+
const conf = await config.getConfig([
|
|
14
|
+
(0, path.resolve)(".sondarc"),
|
|
15
|
+
(0, path.resolve)(".sondarc.js"),
|
|
16
|
+
(0, path.resolve)("sonda.config.js")
|
|
17
|
+
], {});
|
|
18
|
+
return conf.contents;
|
|
19
|
+
},
|
|
20
|
+
async report({ event, options }) {
|
|
21
|
+
if (event.type !== "buildSuccess") return;
|
|
22
|
+
let inputs = {};
|
|
23
|
+
const assets = [];
|
|
24
|
+
for (let bundle of event.bundleGraph.getBundles()) {
|
|
25
|
+
assets.push(bundle.filePath);
|
|
26
|
+
bundle.traverseAssets((asset) => {
|
|
27
|
+
const input = {
|
|
28
|
+
bytes: asset.stats.size,
|
|
29
|
+
format: asset.meta.hasCJSExports ? "cjs" : "esm",
|
|
30
|
+
imports: [],
|
|
31
|
+
belongsTo: null
|
|
32
|
+
};
|
|
33
|
+
for (let dep of event.bundleGraph.getDependencies(asset)) {
|
|
34
|
+
let resolved = event.bundleGraph.getResolvedAsset(dep, bundle);
|
|
35
|
+
if (resolved) input.imports.push(require_src.normalizePath((0, path.relative)(process.cwd(), resolved.filePath)));
|
|
36
|
+
}
|
|
37
|
+
inputs[require_src.normalizePath((0, path.relative)(process.cwd(), asset.filePath))] = input;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return require_src.generateReportFromAssets(
|
|
41
|
+
assets,
|
|
42
|
+
inputs,
|
|
43
|
+
// TODO: Use user provided options
|
|
44
|
+
{
|
|
45
|
+
format: "html",
|
|
46
|
+
detailed: true,
|
|
47
|
+
sources: true,
|
|
48
|
+
gzip: true,
|
|
49
|
+
brotli: true,
|
|
50
|
+
sourcesPathNormalizer: (path$1) => (0, path.join)(options.projectRoot, path$1)
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var parcel_default = SondaParcelPlugin;
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
module.exports = parcel_default;
|
|
59
|
+
//# sourceMappingURL=parcel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parcel.cjs","names":["opts: ReporterOpts","SondaParcelPlugin: Reporter","inputs: JsonReport[ 'inputs' ]","assets: Array<string>","input: ReportInput","path: string","path"],"sources":["../../src/entrypoints/parcel.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport type { Reporter as ReporterOpts } from '@parcel/types';\nimport {\n generateReportFromAssets,\n normalizePath,\n type JsonReport,\n type ReportInput,\n type UserOptions\n} from '../index.js';\n\nclass Reporter {\n constructor ( opts: ReporterOpts ) {\n // @ts-ignore\n this[ Symbol.for( 'parcel-plugin-config' ) ] = opts;\n }\n}\n\nconst SondaParcelPlugin: Reporter = new Reporter( {\n // @ts-ignore\n async loadConfig( { config } ): Promise<UserOptions> {\n // @ts-ignore\n const conf = await config.getConfig<UserOptions>( [\n resolve( '.sondarc' ),\n resolve( '.sondarc.js' ),\n resolve( 'sonda.config.js' ),\n ], {} );\n\n return conf!.contents;\n },\n async report( { event, options } ) {\n if ( event.type !== 'buildSuccess' ) {\n return;\n }\n\n let inputs: JsonReport[ 'inputs' ] = {};\n const assets: Array<string> = [];\n\n for ( let bundle of event.bundleGraph.getBundles() ) {\n assets.push( bundle.filePath );\n\n // @ts-ignore\n bundle.traverseAssets( asset => {\n const input: ReportInput = {\n bytes: asset.stats.size,\n\n // TODO: What abount 'unknown'?\n format: asset.meta.hasCJSExports ? 'cjs' : 'esm',\n imports: [],\n belongsTo: null,\n }\n\n for ( let dep of event.bundleGraph.getDependencies( asset ) ) {\n let resolved = event.bundleGraph.getResolvedAsset( dep, bundle )!;\n\n if ( resolved ) {\n input.imports.push( normalizePath( relative( process.cwd(), resolved.filePath ) ) );\n }\n }\n \n inputs[ normalizePath( relative( process.cwd(), asset.filePath ) ) ] = input;\n } );\n }\n\n return generateReportFromAssets(\n assets,\n inputs,\n // TODO: Use user provided options\n {\n format: 'html',\n detailed: true,\n sources: true,\n gzip: true,\n brotli: true,\n // TODO: `resolve` instead of `join`?\n sourcesPathNormalizer: ( path: string ) => join( options.projectRoot, path ),\n }\n );\n }\n} );\n\nexport default SondaParcelPlugin;\n"],"mappings":";;;;;IAUM,WAAN,MAAe;CACb,YAAcA,MAAqB;AAEjC,OAAM,OAAO,IAAK,uBAAwB,IAAK;CAChD;AACF;AAED,MAAMC,oBAA8B,IAAI,SAAU;CAEhD,MAAM,WAAY,EAAE,QAAQ,EAAyB;EAEnD,MAAM,OAAO,MAAM,OAAO,UAAwB;GAChD,kBAAS,WAAY;GACrB,kBAAS,cAAe;GACxB,kBAAS,kBAAmB;EAC7B,GAAE,CAAE,EAAE;AAEP,SAAO,KAAM;CACd;CACD,MAAM,OAAQ,EAAE,OAAO,SAAS,EAAG;AACjC,MAAK,MAAM,SAAS,eAClB;EAGF,IAAIC,SAAiC,CAAE;EACvC,MAAMC,SAAwB,CAAE;AAEhC,OAAM,IAAI,UAAU,MAAM,YAAY,YAAY,EAAG;AACnD,UAAO,KAAM,OAAO,SAAU;AAG9B,UAAO,eAAgB,WAAS;IAC9B,MAAMC,QAAqB;KACzB,OAAO,MAAM,MAAM;KAGnB,QAAQ,MAAM,KAAK,gBAAgB,QAAQ;KAC3C,SAAS,CAAE;KACX,WAAW;IACZ;AAED,SAAM,IAAI,OAAO,MAAM,YAAY,gBAAiB,MAAO,EAAG;KAC5D,IAAI,WAAW,MAAM,YAAY,iBAAkB,KAAK,OAAQ;AAEhE,SAAK,SACH,OAAM,QAAQ,KAAM,0BAAe,mBAAU,QAAQ,KAAK,EAAE,SAAS,SAAU,CAAE,CAAE;IAEtF;AAED,WAAQ,0BAAe,mBAAU,QAAQ,KAAK,EAAE,MAAM,SAAU,CAAE,IAAK;GACxE,EAAE;EACJ;AAED,SAAO;GACL;GACA;;GAEA;IACE,QAAQ;IACR,UAAU;IACV,SAAS;IACT,MAAM;IACN,QAAQ;IAER,uBAAuB,CAAEC,WAAkB,eAAM,QAAQ,aAAaC,OAAM;GAC7E;CACF;CACF;AACF;qBAEc"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { generateReportFromAssets, normalizePath } from "../src.mjs";
|
|
2
|
+
import { join, relative, resolve } from "path";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/parcel.ts
|
|
5
|
+
var Reporter = class {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
this[Symbol.for("parcel-plugin-config")] = opts;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const SondaParcelPlugin = new Reporter({
|
|
11
|
+
async loadConfig({ config }) {
|
|
12
|
+
const conf = await config.getConfig([
|
|
13
|
+
resolve(".sondarc"),
|
|
14
|
+
resolve(".sondarc.js"),
|
|
15
|
+
resolve("sonda.config.js")
|
|
16
|
+
], {});
|
|
17
|
+
return conf.contents;
|
|
18
|
+
},
|
|
19
|
+
async report({ event, options }) {
|
|
20
|
+
if (event.type !== "buildSuccess") return;
|
|
21
|
+
let inputs = {};
|
|
22
|
+
const assets = [];
|
|
23
|
+
for (let bundle of event.bundleGraph.getBundles()) {
|
|
24
|
+
assets.push(bundle.filePath);
|
|
25
|
+
bundle.traverseAssets((asset) => {
|
|
26
|
+
const input = {
|
|
27
|
+
bytes: asset.stats.size,
|
|
28
|
+
format: asset.meta.hasCJSExports ? "cjs" : "esm",
|
|
29
|
+
imports: [],
|
|
30
|
+
belongsTo: null
|
|
31
|
+
};
|
|
32
|
+
for (let dep of event.bundleGraph.getDependencies(asset)) {
|
|
33
|
+
let resolved = event.bundleGraph.getResolvedAsset(dep, bundle);
|
|
34
|
+
if (resolved) input.imports.push(normalizePath(relative(process.cwd(), resolved.filePath)));
|
|
35
|
+
}
|
|
36
|
+
inputs[normalizePath(relative(process.cwd(), asset.filePath))] = input;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return generateReportFromAssets(
|
|
40
|
+
assets,
|
|
41
|
+
inputs,
|
|
42
|
+
// TODO: Use user provided options
|
|
43
|
+
{
|
|
44
|
+
format: "html",
|
|
45
|
+
detailed: true,
|
|
46
|
+
sources: true,
|
|
47
|
+
gzip: true,
|
|
48
|
+
brotli: true,
|
|
49
|
+
sourcesPathNormalizer: (path) => join(options.projectRoot, path)
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var parcel_default = SondaParcelPlugin;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { parcel_default as default };
|
|
58
|
+
//# sourceMappingURL=parcel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parcel.mjs","names":["opts: ReporterOpts","SondaParcelPlugin: Reporter","inputs: JsonReport[ 'inputs' ]","assets: Array<string>","input: ReportInput","path: string"],"sources":["../../src/entrypoints/parcel.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport type { Reporter as ReporterOpts } from '@parcel/types';\nimport {\n generateReportFromAssets,\n normalizePath,\n type JsonReport,\n type ReportInput,\n type UserOptions\n} from '../index.js';\n\nclass Reporter {\n constructor ( opts: ReporterOpts ) {\n // @ts-ignore\n this[ Symbol.for( 'parcel-plugin-config' ) ] = opts;\n }\n}\n\nconst SondaParcelPlugin: Reporter = new Reporter( {\n // @ts-ignore\n async loadConfig( { config } ): Promise<UserOptions> {\n // @ts-ignore\n const conf = await config.getConfig<UserOptions>( [\n resolve( '.sondarc' ),\n resolve( '.sondarc.js' ),\n resolve( 'sonda.config.js' ),\n ], {} );\n\n return conf!.contents;\n },\n async report( { event, options } ) {\n if ( event.type !== 'buildSuccess' ) {\n return;\n }\n\n let inputs: JsonReport[ 'inputs' ] = {};\n const assets: Array<string> = [];\n\n for ( let bundle of event.bundleGraph.getBundles() ) {\n assets.push( bundle.filePath );\n\n // @ts-ignore\n bundle.traverseAssets( asset => {\n const input: ReportInput = {\n bytes: asset.stats.size,\n\n // TODO: What abount 'unknown'?\n format: asset.meta.hasCJSExports ? 'cjs' : 'esm',\n imports: [],\n belongsTo: null,\n }\n\n for ( let dep of event.bundleGraph.getDependencies( asset ) ) {\n let resolved = event.bundleGraph.getResolvedAsset( dep, bundle )!;\n\n if ( resolved ) {\n input.imports.push( normalizePath( relative( process.cwd(), resolved.filePath ) ) );\n }\n }\n \n inputs[ normalizePath( relative( process.cwd(), asset.filePath ) ) ] = input;\n } );\n }\n\n return generateReportFromAssets(\n assets,\n inputs,\n // TODO: Use user provided options\n {\n format: 'html',\n detailed: true,\n sources: true,\n gzip: true,\n brotli: true,\n // TODO: `resolve` instead of `join`?\n sourcesPathNormalizer: ( path: string ) => join( options.projectRoot, path ),\n }\n );\n }\n} );\n\nexport default SondaParcelPlugin;\n"],"mappings":";;;;IAUM,WAAN,MAAe;CACb,YAAcA,MAAqB;AAEjC,OAAM,OAAO,IAAK,uBAAwB,IAAK;CAChD;AACF;AAED,MAAMC,oBAA8B,IAAI,SAAU;CAEhD,MAAM,WAAY,EAAE,QAAQ,EAAyB;EAEnD,MAAM,OAAO,MAAM,OAAO,UAAwB;GAChD,QAAS,WAAY;GACrB,QAAS,cAAe;GACxB,QAAS,kBAAmB;EAC7B,GAAE,CAAE,EAAE;AAEP,SAAO,KAAM;CACd;CACD,MAAM,OAAQ,EAAE,OAAO,SAAS,EAAG;AACjC,MAAK,MAAM,SAAS,eAClB;EAGF,IAAIC,SAAiC,CAAE;EACvC,MAAMC,SAAwB,CAAE;AAEhC,OAAM,IAAI,UAAU,MAAM,YAAY,YAAY,EAAG;AACnD,UAAO,KAAM,OAAO,SAAU;AAG9B,UAAO,eAAgB,WAAS;IAC9B,MAAMC,QAAqB;KACzB,OAAO,MAAM,MAAM;KAGnB,QAAQ,MAAM,KAAK,gBAAgB,QAAQ;KAC3C,SAAS,CAAE;KACX,WAAW;IACZ;AAED,SAAM,IAAI,OAAO,MAAM,YAAY,gBAAiB,MAAO,EAAG;KAC5D,IAAI,WAAW,MAAM,YAAY,iBAAkB,KAAK,OAAQ;AAEhE,SAAK,SACH,OAAM,QAAQ,KAAM,cAAe,SAAU,QAAQ,KAAK,EAAE,SAAS,SAAU,CAAE,CAAE;IAEtF;AAED,WAAQ,cAAe,SAAU,QAAQ,KAAK,EAAE,MAAM,SAAU,CAAE,IAAK;GACxE,EAAE;EACJ;AAED,SAAO;GACL;GACA;;GAEA;IACE,QAAQ;IACR,UAAU;IACV,SAAS;IACT,MAAM;IACN,QAAQ;IAER,uBAAuB,CAAEC,SAAkB,KAAM,QAAQ,aAAa,KAAM;GAC7E;CACF;CACF;AACF;qBAEc"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../src.cjs');
|
|
3
|
+
const require_rollup = require('../rollup.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/entrypoints/sveltekit.ts
|
|
6
|
+
function SondaSvelteKitPlugin(options = {}) {
|
|
7
|
+
if (options.enabled === false) return { name: "sonda" };
|
|
8
|
+
options.format ??= "html";
|
|
9
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
10
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaSvelteKitPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
11
|
+
return {
|
|
12
|
+
apply: "build",
|
|
13
|
+
configResolved(config) {
|
|
14
|
+
const env = config.build.ssr ? "server" : "client";
|
|
15
|
+
const generateForServer = options.server ?? false;
|
|
16
|
+
if (env === "server" && !generateForServer) options.enabled = false;
|
|
17
|
+
options.filename = options.filename.replace("[env]", env);
|
|
18
|
+
},
|
|
19
|
+
...require_rollup.SondaRollupPlugin(options)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
module.exports = SondaSvelteKitPlugin;
|
|
25
|
+
//# sourceMappingURL=sveltekit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sveltekit.cjs","names":["options: Partial<FrameworkUserOptions>"],"sources":["../../src/entrypoints/sveltekit.ts"],"sourcesContent":["import Sonda from './rollup';\nimport type { PluginOption } from 'vite';\nimport type { FrameworkUserOptions } from '../types';\n\nexport default function SondaSvelteKitPlugin( options: Partial<FrameworkUserOptions> = {} ): PluginOption {\n if ( options.enabled === false ) {\n return { name: 'sonda' };\n }\n\n options.format ??= 'html';\n options.filename ??= `sonda-report-[env].${ options.format }`;\n\n // SvelteKit runs few builds and each must generate a separate report\n if ( !options.filename.includes( '[env]' ) ) {\n throw new Error( 'SondaSvelteKitPlugin: The \"filename\" option must include the \"[env]\" token.' );\n }\n\n return {\n apply: 'build',\n\n configResolved( config ) {\n const env = config.build.ssr ? 'server' : 'client';\n const generateForServer = options.server ?? false;\n\n if ( env === 'server' && !generateForServer ) {\n options.enabled = false;\n }\n\n options.filename = options.filename!.replace( '[env]', env );\n },\n\n ...Sonda( options )\n };\n}\n"],"mappings":";;;;;AAIe,SAAS,qBAAsBA,UAAyC,CAAE,GAAiB;AACxG,KAAK,QAAQ,YAAY,MACvB,QAAO,EAAE,MAAM,QAAS;AAG1B,SAAQ,WAAW;AACnB,SAAQ,cAAc,qBAAsB,QAAQ,OAAQ;AAG5D,MAAM,QAAQ,SAAS,SAAU,QAAS,CACxC,OAAM,IAAI,MAAO;AAGnB,QAAO;EACL,OAAO;EAEP,eAAgB,QAAS;GACvB,MAAM,MAAM,OAAO,MAAM,MAAM,WAAW;GAC1C,MAAM,oBAAoB,QAAQ,UAAU;AAE5C,OAAK,QAAQ,aAAa,kBACxB,SAAQ,UAAU;AAGpB,WAAQ,WAAW,QAAQ,SAAU,QAAS,SAAS,IAAK;EAC7D;EAED,GAAG,iCAAO,QAAS;CACpB;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "../src.mjs";
|
|
2
|
+
import { SondaRollupPlugin } from "../rollup.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/entrypoints/sveltekit.ts
|
|
5
|
+
function SondaSvelteKitPlugin(options = {}) {
|
|
6
|
+
if (options.enabled === false) return { name: "sonda" };
|
|
7
|
+
options.format ??= "html";
|
|
8
|
+
options.filename ??= `sonda-report-[env].${options.format}`;
|
|
9
|
+
if (!options.filename.includes("[env]")) throw new Error("SondaSvelteKitPlugin: The \"filename\" option must include the \"[env]\" token.");
|
|
10
|
+
return {
|
|
11
|
+
apply: "build",
|
|
12
|
+
configResolved(config) {
|
|
13
|
+
const env = config.build.ssr ? "server" : "client";
|
|
14
|
+
const generateForServer = options.server ?? false;
|
|
15
|
+
if (env === "server" && !generateForServer) options.enabled = false;
|
|
16
|
+
options.filename = options.filename.replace("[env]", env);
|
|
17
|
+
},
|
|
18
|
+
...SondaRollupPlugin(options)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SondaSvelteKitPlugin as default };
|
|
24
|
+
//# sourceMappingURL=sveltekit.mjs.map
|