Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[AssetMapper] Dynamic imports from vendor code use the wrong URLs #53145

Closed
@benr77

Description

@benr77

Symfony version(s) affected

6.4.0

Description

Using the AssetMapper component, I have everything up and running in my project, except getting MermaidJs to run.

Mermaid itself is installed, but it then dynamically loads in a .js file specific to the type of chart it is trying to render.

In my case, it's looking for /npm/[email protected]/dist/ganttDiagram-db6931fb.js/+esm and this is returning a 404 and the diagram does not get displayed.

How to reproduce

bin/console importmap:require mermaid

I am trying to load Mermaid from a Stimulus controller, but I don't think this is the cause of the problem.

import { Controller } from '@hotwired/stimulus';
import mermaid from 'mermaid';

export default class extends Controller {
    async connect() {
        mermaid.initialize({
            startOnLoad: false,
            securityLevel: 'loose',
            theme: 'base',
            themeVariables: {
                primaryColor: '#ffc107',
            }
        });

        await mermaid.run({
            querySelector: '.mermaid',
        });
    }
}

Mermaid then loads, detects in my HTML that it's a Gantt chart, and then tries to load /npm/[email protected]/dist/ganttDiagram-db6931fb.js/+esm which of course isn't present.

I've tried installing that specifically, but it seems the URL versioning breaks this, as of course the Gantt chart JS file is under a different name once it's installed.

This, and variations of this, do not help:

bin/console importmap:require mermaid/dist/ganttDiagram-db6931fb

How can the asset mapper system handle this? It is even possible?

Possible Solution

How do

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions