MCPcopy Create free account
hub / github.com/QwikDev/qwik / createOutputAnalyzer

Function createOutputAnalyzer

packages/qwik/src/optimizer/src/plugins/plugin.ts:822–874  ·  view source on GitHub ↗
(rollupBundle: Rollup.OutputBundle)

Source from the content-addressed store, hash-verified

820 };
821
822 const createOutputAnalyzer = (rollupBundle: Rollup.OutputBundle) => {
823 const injections: GlobalInjections[] = [];
824
825 const outputAnalyzer: OutputAnalyzer = {
826 addInjection: (b: GlobalInjections) => injections.push(b),
827 } as Partial<OutputAnalyzer> as OutputAnalyzer;
828
829 outputAnalyzer.generateManifest = async (extra?: Partial<QwikManifest>) => {
830 const optimizer = getOptimizer();
831 const path = optimizer.sys.path;
832
833 const buildPath = path.resolve(opts.rootDir, opts.outDir, 'build');
834 const canonPath = (p: string) =>
835 path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
836 outputAnalyzer.canonPath = canonPath;
837
838 const segments = Array.from(clientResults.values())
839 .flatMap((r) => r.modules)
840 .map((mod) => mod.segment)
841 .filter((h) => !!h) as SegmentAnalysis[];
842
843 const manifest = generateManifestFromBundles(
844 path,
845 segments,
846 injections,
847 rollupBundle,
848 opts,
849 debug,
850 canonPath
851 );
852 if (extra) {
853 Object.assign(manifest, extra);
854 }
855
856 for (const symbol of Object.values(manifest.symbols)) {
857 if (symbol.origin) {
858 symbol.origin = normalizePath(symbol.origin);
859 }
860 }
861
862 for (const bundle of Object.values(manifest.bundles)) {
863 if (bundle.origins) {
864 bundle.origins = bundle.origins.sort();
865 }
866 }
867
868 manifest.manifestHash = hashCode(JSON.stringify(manifest));
869
870 return manifest;
871 };
872
873 return outputAnalyzer;
874 };
875
876 const getOptions = () => opts;
877

Callers 1

generateManifestFunction · 0.85

Calls 5

hashCodeFunction · 0.90
getOptimizerFunction · 0.85
normalizePathFunction · 0.70
resolveMethod · 0.65

Tested by

no test coverage detected