mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-25 18:30:10 +02:00
Merge branch 'sidv/viz' into sidv/splitDiagrams
* sidv/viz: feat: Add package visualization Ignore stats.html feat: Add bundle 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\"",
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
"@types/mdast": "^3.0.10",
|
"@types/mdast": "^3.0.10",
|
||||||
"@types/node": "^18.11.9",
|
"@types/node": "^18.11.9",
|
||||||
"@types/prettier": "^2.7.1",
|
"@types/prettier": "^2.7.1",
|
||||||
|
"@types/rollup-plugin-visualizer": "^4.2.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
||||||
"@typescript-eslint/parser": "^5.42.1",
|
"@typescript-eslint/parser": "^5.42.1",
|
||||||
"@vitest/coverage-c8": "^0.25.1",
|
"@vitest/coverage-c8": "^0.25.1",
|
||||||
|
38
pnpm-lock.yaml
generated
38
pnpm-lock.yaml
generated
@@ -40,6 +40,9 @@ importers:
|
|||||||
'@types/prettier':
|
'@types/prettier':
|
||||||
specifier: ^2.7.1
|
specifier: ^2.7.1
|
||||||
version: 2.7.1
|
version: 2.7.1
|
||||||
|
'@types/rollup-plugin-visualizer':
|
||||||
|
specifier: ^4.2.1
|
||||||
|
version: 4.2.1
|
||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
specifier: ^5.42.1
|
specifier: ^5.42.1
|
||||||
version: 5.42.1_2udltptbznfmezdozpdoa2aemq
|
version: 5.42.1_2udltptbznfmezdozpdoa2aemq
|
||||||
@@ -2592,6 +2595,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==}
|
resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@types/rollup-plugin-visualizer/4.2.1:
|
||||||
|
resolution: {integrity: sha512-Fk4y0EgmsSbvbayYhtSI9+cGvgw1rcQ9RlbExkQt4ivXRdiEwFKuRpxNuJCr0JktXIvOPUuPR7GSmtyZu0dujQ==}
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 18.11.9
|
||||||
|
rollup: 2.79.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/semver/7.3.12:
|
/@types/semver/7.3.12:
|
||||||
resolution: {integrity: sha512-WwA1MW0++RfXmCr12xeYOOC5baSC9mSb0ZqCquFzKhcoF4TvHu5MKOuXsncgZcpVFhB1pXd5hZmM0ryAoCp12A==}
|
resolution: {integrity: sha512-WwA1MW0++RfXmCr12xeYOOC5baSC9mSb0ZqCquFzKhcoF4TvHu5MKOuXsncgZcpVFhB1pXd5hZmM0ryAoCp12A==}
|
||||||
dev: true
|
dev: true
|
||||||
@@ -6033,6 +6043,18 @@ packages:
|
|||||||
debug: 4.3.2
|
debug: 4.3.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/follow-redirects/1.15.2_debug@4.3.2:
|
||||||
|
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
|
||||||
|
engines: {node: '>=4.0'}
|
||||||
|
peerDependencies:
|
||||||
|
debug: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
debug:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
debug: 4.3.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/foreground-child/2.0.0:
|
/foreground-child/2.0.0:
|
||||||
resolution: {integrity: sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==}
|
resolution: {integrity: sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==}
|
||||||
engines: {node: '>=8.0.0'}
|
engines: {node: '>=8.0.0'}
|
||||||
@@ -9423,6 +9445,22 @@ packages:
|
|||||||
yargs: 17.5.1
|
yargs: 17.5.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/rollup-plugin-visualizer/5.8.3_rollup@2.79.1:
|
||||||
|
resolution: {integrity: sha512-QGJk4Bqe4AOat5AjipOh8esZH1nck5X2KFpf4VytUdSUuuuSwvIQZjMGgjcxe/zXexltqaXp5Vx1V3LmnQH15Q==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
rollup: 2.x || 3.x
|
||||||
|
peerDependenciesMeta:
|
||||||
|
rollup:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
open: 8.4.0
|
||||||
|
rollup: 2.79.1
|
||||||
|
source-map: 0.7.4
|
||||||
|
yargs: 17.5.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/rollup/2.79.1:
|
/rollup/2.79.1:
|
||||||
resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==}
|
resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==}
|
||||||
engines: {node: '>=10.0.0'}
|
engines: {node: '>=10.0.0'}
|
||||||
|
Reference in New Issue
Block a user