Skip to content
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

currentConfig is incorrectly bundled over multiple files #4345

Closed
luttje opened this issue Apr 25, 2023 · 0 comments · Fixed by #4889
Closed

currentConfig is incorrectly bundled over multiple files #4345

luttje opened this issue Apr 25, 2023 · 0 comments · Fixed by #4889
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@luttje
Copy link

luttje commented Apr 25, 2023

Description

I'm noticing that currentConfig (in config.ts) is incorrectly split by Vite/RollUp over multiple files. This causes some scripts to not get the same currentConfig as others.

Steps to reproduce

I am trying to add a curve configuration option to the ER diagram. That is where I ran into this issue. The only relevant code needed to reproduce this issue:

  1. Add curve?: string; to interface ErDiagramConfig in packages/mermaid/src/config.type.ts
  2. Add curve: 'basis', to config.er in packages/mermaid/src/defaultConfig.ts
  3. Add er: { curve: 'step' }, to the config object in mermaid.initialize in demos/er.html
  4. For debugging add: console.trace(conf.curve) at the top of drawRelationshipFromLayout in packages/mermaid/src/diagrams/er/erRenderer.js
  5. pnpm run dev

It should be expected that the console.log logs 'step', but instead it logs 'basis'. If you inspect in the browser which files exist, you will see two files containing let currentConfig and an exported getConfig function. This means some code uses a different config than others.

Screenshots

image
image

Code Sample

fork

Setup

  • Mermaid version: 10.1.0
  • Browser and Version: All (since it's a bundler issue), but tested on:
    • Chrome: Version 112.0.5615.138 (Official Build) (64-bit)
    • FireFox: Version 112.0.1 (64-bit)

Additional Context

I've tried messing with these options inside .vite/build.ts, but to no avail (my knowledge of Vite and Rollup is insufficient atm):

Thanks for the great project, loving it!

Hope this bug report helps, let me know if you need more info 😊

@luttje luttje added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant