-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mermaid.tiny.min.js
. 69.7% size reduction.
#4734
base: develop
Are you sure you want to change the base?
Conversation
Excludes elk and mindmap at build time
* sidv/splitChunks: chore: Add analyzer comment chore: Split chunks into folders chore: Split chunks into folders chore: Add defaultOptions to server chore: Split chunks into folders
* sidv/splitChunks: chore: Fix outfile names
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4734 +/- ##
==========================================
- Coverage 5.72% 5.72% -0.01%
==========================================
Files 278 278
Lines 42013 42046 +33
Branches 490 490
==========================================
Hits 2407 2407
- Misses 39606 39639 +33
Flags with carried forward coverage won't be shown. Click here to find out more.
|
* sidv/splitChunks: Fix import
mermaid.tiny.min.js
mermaid.tiny.min.js
. 69.7% size reduction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! That's a massive size reduction!
I'm really against putting this in the mermaid
package, because it will make the package bigger for everybody, even if they don't use the mermaid.tiny.min.js
file, and it will add another file that we will never be able to get rid of without breaking backwards compatibility with CDNs.
I think this must go in a new package, maybe something like @mermaid-js/mermaid-tiny
?
Two other recommendations that would be nice to fix, but not required:
-
Instead of changing
src/diagrams/.../detector.ts
, can't we just prevent addingmindmap
andflowchart/elk
in the thediagram-orchestration.ts
file, e.g. modifying these lines of code:mermaid/packages/mermaid/src/diagram-api/diagram-orchestration.ts
Lines 74 to 77 in 5f95a26
flowchartElk, flowchartV2, flowchart, mindmap, If ESBuild is smart enough, it should do tree shaking automatically, and it will have the same effect.
-
I think the error diagram needs a more human readable message in case somebody does try to use
mindmap
orflowchart-elk
withmermaid-tiny
. We have to assume that users might not even know they're usingmermaid-tiny
, e.g. if they're using a third-party Mermaid plugin.
The current unpacked size is 21MB, adding an extra 1MB to it is worth the tradeoff for not having to maintain and release another package. Moreover, this will only affect people using package managers, not actual end users.
Now it's just a file, if we use a package, we'll have to maintain that in sync with mermaid, which is a bigger headache than having a file in the package with 0 active maintenance requirement. |
I tried that first, the file size didn't change. But I was using a different approach then (not define). Let me try now. -- It worked! ❤️ |
Co-authored-by: Alois Klink <[email protected]>
That would be out of scope for this PR. I did try a POC, but the changes will be extensive. Especially since we're not even registering the diagrams since 55266c4 |
I still don't agree with adding the Would uploading this as a GitHub Release asset be a better idea (e.g. using something like https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28)? This should be pretty easy to do (we just need to add another job in https://github.com/mermaid-js/mermaid/blob/develop/.github/workflows/release-publish.yml). Since GitHub Releases don't have an Regardless of what we pick, since adding another entry-point to mermaid is a pretty major change, we should get @knsv's approval first (maybe also other mermaid maintainers?). I think long-term, having it in a separate NPM package like
That's fair! It would be a nice feature to have, especially if custom Mermaid plugins become more popular (although since it's not a breaking change, that would be a feature that can go directly into the |
This could be a stop-gap measure till we have automated builds and separate packages. Also, I don't think the |
I have this idea for fully customizable mermaid that people can download, containing code for only the diagrams that they need, in a single bundle, without lazy loading. A browser based version could be done using esbuild-wasm, once the bundling in browser part is figured out. |
* next: chore: Move SVG import to comment. build docs Remove whitespace on empty line chore: Fix minify Documentation for #2509 Update all minor dependencies Update all patch dependencies make more `RectData` required and remove optional assignment use lineBreakRegex in `svgDrawCommon` fix svgDrawCommon import by adding `.js` add types to `svgDrawCommon.ts` convert `svgDrawCommon` to TS
Hey there @sidharthv96 and @aloisklink! Thank you so much working this min variant. We're looking to add Mermaid support to our markdown plugin within the Elastic Assistant (elastic/kibana#167723 -- our testing of llm generated mermaid charts has been awesome!) however due some licensing issues around It seems there's still some discussion going on WRT packaging, but is there anything we could contribute here to help get this effort in? Happy to help where we can. 🙂 Thanks again! |
Hi @spong, I'm not sure if this exact PR will get merged anytime soon, but we are planning on removing If it gets merged, it should be in the next major/v11 release, which should hopefully come out before the Christmas/New Year holiday period! It's not the same as this PR, as mindmaps will still be included, which has a dependency on the very large cytoscape package, but that package is MIT licensed, so there shouldn't be any licensing issues there. |
Oh awesome -- thank you so much for the details @aloisklink! From a packaging perspective we're definitely still interested in a min variant, but that's not a strict blocker for adoption, so we will look forward to integrating once v11 is released. Appreciate all your work here, we're big fans of mermaid and can't wait to introduce it to more folks 🙂 |
@spong can you verify if https://www.npmjs.com/package/mermaid/v/11.0.0-alpha.5 complies with the license requirements? We've removed elkjs. |
Thank you @sidharthv96 for taking care of that so quickly 🙇 |
mermaid-parser is MIT licenced. https://github.com/mermaid-js/mermaid/blob/next/packages/parser/LICENSE And DOMPurify is Apache/MPL. |
Thank you @sidharthv96, it seems on npm it links to the wrong repo and License then https://www.npmjs.com/package/mermaid-parser |
Ohh, that we'll fix before the major release.
…On Sun, 26 Nov, 2023, 12:31 pm Patryk Kopyciński, ***@***.***> wrote:
Thank you @sidharthv96 <https://github.com/sidharthv96>, it seems on npm
it links to the wrong repo and License then
https://www.npmjs.com/package/mermaid-parser
—
Reply to this email directly, view it on GitHub
<#4734 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACRVEVIPPSQGMPB5B2MVPQTYGLSM3AVCNFSM6AAAAAA3PDHI7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGY4DENRWHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Awesome, Thank you! 🙇 |
@patrykkopycinski https://www.npmjs.com/package/@mermaid-js/parser is out with MIT license, available in mermaid v11.0.0-alpha.6. |
Hey @sidharthv96, I just wanted to check if there is any news about the v11 release? |
* next: (562 commits) Lint Remove echo RefTest Echo event Update cypress Fix applitools Fix applitools docs: fix lint docs: move community to Discord Swap condition blocks to avoid using negation Reposition const declaration to ideal place Change repetitive values into consts docs: fix swimm link Fix Update Browserslist Use pnpm/action-setup@v2 Fix lint Cleanup e2e.yml Ignore push events on merge queue Remove :: Remove :: ...
With the removal of elk js and addition of the new parser, the size delta has decreased significantly. It's 2.2 vs 1.7 MB now. See eclipse-langium/langium#1168 for Langium's size reduction efforts. |
* next: (269 commits) Resolves E2E testing issues and issue #5343 Fix spelling Fix community integrations Fix docs docs: Fix config Update all minor dependencies Amend docs to document gitgraph parallel commits Fix lint Use Yarn Add COREPACK_ENABLE_STRICT Added link to Blazorade Mermaid to the community integrations page. Bump node version Add lcov to cspell Correcting path to docker-entrypoint.sh Update recommended Vitest extension Replace mermaid-js.github.io links Replace links to docs with links to webhelp Link to contributing page on webhelp Changes to timeline.md 1. Added colons to all 'NOTES' for consistency. Changes to timeline.md 1. Updates the Wikipedia citation to include a link. 2. Removed periods from documentation sections to be consistent (some had periods, some didn't) 3. Added a space to a coding example for spacing consistency. Replace version number placeholder ...
* develop: (31 commits) make LLM integrations a new headline build docs ci(e2e): avoid commenting on PRs in CI chore: Remove unused imports in block Fix spelling Update docs Lychee ignore chrome webstore Update link chore(deps): update all patch dependencies build(docs): vendor CSS dependencies chore(deps): update all minor dependencies fix linting issues Ran lint:fix Fix chrome webstore url causing 404 Add LLM integration section in productivity tools and add HueHive build(deps): update `langium` to `v3` and apply the required changes Remove dummy change from e2e.yml Remove dummy change Remove log Format message ...
* develop: (101 commits) Add extra test Add visual test Wait for image to be rendered Update docs Linting chore: temp fix for eslint OOM chore: Update error snapshots Fix ESLint chore: Prettier chore: YOLO `pnpm --recursive update` chore: Remove commitlint Fix flowchart-elk render test chore: Add example page link in index Fix flowchart-elk render test chore: Add example page link in index fix: Remove space which caused extra newline on diagrams fix: Remove repeated config calls fix: ELK diagram remove re-parsing chore: Minor fixes #4856 chore: Increase ESLint memory limit ...
@sidharthv96 is there any way we can use mermaid.tiny ? |
* develop: (52 commits) docs: Add quadrant point styling feat: Change precedence of styling chore(deps): update all minor dependencies chore(deps): update all patch dependencies fix: eslint ignore, type definition chore(deps): update all patch dependencies fix: Remove `ImperativeState` type restriction. 📝🐛 fix schema link update latest news section Changes to rendering/gitGraph.spec.js - Added additional rendering test functionality for recognizing 'switch' as an alias to 'checkout'. 1. Changes to gitGraph.jison - Updated the regex to allow either 'checkout' or 'switch' 2. Changes to gitGraphParser.spec.js - Additional test coverage added for the changes made to the parser. 3. Changes to gitGraphParserV2.spec.js - Additional test coverafe added for the changes made to the parser. 4. Changes to gitgraph.md - Updated documentation to let users know that checkout/switch can be used interchangeably. revert from and to type to object add eslint rule consistent-type-definations Update createText.ts chore(deps): update all patch dependencies revert lock file simplify message type from and to move types to separate file use interfaces instead of types feat: create utils func + test cases ...
@Dhoot you can use the artifact generated during build. |
Thanks @sidharthv96, but I am looking for some pattern to access using npm so that we can do quick updates in our project and stay on latest version always. |
If you're using npm, you can use normal mermaid itself. It'll tree shake and lazy load, without affecting size that much. |
how to use this? |
📑 Summary
Resolves #4616
📏 Design Decisions
Uses the define feature of esbuild to exclude mindmap and flowchart-elk during build time.
📋 Tasks
Make sure you