mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-17 23:39:26 +02:00
feat: Add package visualization
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -35,4 +35,4 @@ tsconfig.tsbuildinfo
|
|||||||
|
|
||||||
knsv*.html
|
knsv*.html
|
||||||
local*.html
|
local*.html
|
||||||
stats.html
|
stats/
|
||||||
|
@@ -4,7 +4,9 @@ import { fileURLToPath } from 'url';
|
|||||||
import jisonPlugin from './jisonPlugin.js';
|
import jisonPlugin from './jisonPlugin.js';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
|
import type { TemplateType } from 'rollup-plugin-visualizer/dist/plugin/template-types.js';
|
||||||
|
|
||||||
|
const visualize = process.argv.includes('--visualize');
|
||||||
const watch = process.argv.includes('--watch');
|
const watch = process.argv.includes('--watch');
|
||||||
const mermaidOnly = process.argv.includes('--mermaid');
|
const mermaidOnly = process.argv.includes('--mermaid');
|
||||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||||
@@ -14,6 +16,20 @@ type OutputOptions = Exclude<
|
|||||||
undefined
|
undefined
|
||||||
>['output'];
|
>['output'];
|
||||||
|
|
||||||
|
const visualizerOptions = (packageName: string): PluginOption[] => {
|
||||||
|
if (packageName !== 'mermaid' || !visualize) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return ['network', 'treemap', 'sunburst'].map((chartType) =>
|
||||||
|
visualizer({
|
||||||
|
filename: `./stats/${chartType}.html`,
|
||||||
|
template: chartType as TemplateType,
|
||||||
|
gzipSize: true,
|
||||||
|
brotliSize: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const packageOptions = {
|
const packageOptions = {
|
||||||
mermaid: {
|
mermaid: {
|
||||||
name: 'mermaid',
|
name: 'mermaid',
|
||||||
@@ -96,7 +112,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.jison', '.js', '.ts', '.json'],
|
extensions: ['.jison', '.js', '.ts', '.json'],
|
||||||
},
|
},
|
||||||
plugins: [jisonPlugin(), visualizer({ template: 'network' }) as PluginOption],
|
plugins: [jisonPlugin(), ...visualizerOptions(packageName)],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (watch && config.build) {
|
if (watch && config.build) {
|
||||||
@@ -122,7 +138,7 @@ const buildPackage = async (entryName: keyof typeof packageOptions) => {
|
|||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[];
|
const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[];
|
||||||
for (const pkg of packageNames) {
|
for (const pkg of packageNames.filter((pkg) => !mermaidOnly || pkg === 'mermaid')) {
|
||||||
await buildPackage(pkg);
|
await buildPackage(pkg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
"bilkent",
|
"bilkent",
|
||||||
"bisheng",
|
"bisheng",
|
||||||
"brolin",
|
"brolin",
|
||||||
|
"brotli",
|
||||||
"codedoc",
|
"codedoc",
|
||||||
"colour",
|
"colour",
|
||||||
"cpettitt",
|
"cpettitt",
|
||||||
@@ -70,6 +71,7 @@
|
|||||||
"substate",
|
"substate",
|
||||||
"sveidqvist",
|
"sveidqvist",
|
||||||
"techn",
|
"techn",
|
||||||
|
"treemap",
|
||||||
"ts-nocheck",
|
"ts-nocheck",
|
||||||
"tuleap",
|
"tuleap",
|
||||||
"verdana",
|
"verdana",
|
||||||
|
@@ -15,8 +15,9 @@
|
|||||||
"git graph"
|
"git graph"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:mermaid": "ts-node-esm --transpileOnly .vite/build.ts --mermaid",
|
|
||||||
"build:vite": "ts-node-esm --transpileOnly .vite/build.ts",
|
"build:vite": "ts-node-esm --transpileOnly .vite/build.ts",
|
||||||
|
"build:mermaid": "pnpm build:vite --mermaid",
|
||||||
|
"build:viz": "pnpm build:mermaid --visualize",
|
||||||
"build:types": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly",
|
"build:types": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly",
|
||||||
"build:watch": "pnpm build:vite --watch",
|
"build:watch": "pnpm build:vite --watch",
|
||||||
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
|
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
|
||||||
|
Reference in New Issue
Block a user