Skip to content

[AssetMapper] Unable to use large packages on jsDelivr (highcharts) with AssetMapper #52533

Closed
@evertharmeling

Description

@evertharmeling

Description

Let me start with, sorry Ryan for messing around again 😊

When running:
symfony console importmap:require highcharts

I get the following error:

Screenshot 2023-11-10 at 09 43 01

This is mainly just caused by the jsDelivr API and looking at the package they try to give some more info. They mention, for highcharts specific, to look at the dist (repo) of the package.

However the highcharts-dist package is not available and therefor it's (still) not possible to use the command like symfony console importmap:require highcharts-dist for that.

Long story short

How should in this case highcharts (or any package which exceeds the limit) be used in combination with asset-mapper?

  • Is there a way?
    • If not, should we add support for it or explicitly don't support it as it's basically a problem caused by jsDelivr?

Either way we should add something to the documentation about such a scenario?

Possible approaches

  • Even using the install jsDelivr snippet and add that in my base template gave me a 403 error. Looking at highcharts-dist documentation it would be possible to use their own CDN, but that's not supported in asset-mapper at the moment.
    • Should we revert deprecate the url option in the ImportMapConfigReader? And somehow add support for this scenario?
    • Also using a custom 'install 'snippet would gave me errors like An import map is added after module script load was triggered. So we should fix this with the importmap() function / in the importmap.php file.
  • Ability to add a custom PackageResolverInterface and have a multiple resolvers chain?

I even went rogue trying to have sort of an hybrid asset-mapper/webpack-encore approach and downloading the highcharts package with yarn and trying to map the assets:

framework:
    asset_mapper:
        paths:
            assets/: ''
            node_modules/highcharts/css: 'highcharts-css'
            node_modules/highcharts/es-modules/Core/Chart: 'highstock-es'

But that gave me a similar error

Screenshot 2023-11-10 at 10 36 45
It may be possible if the code related to the highcharts implementation was completely handled with webpack-encore and then bundled and imported with importmap but didn't try that (yet). It's pretty ugly but if that's the only way...

Example

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