Skip to content

[AssetMapper] Allow to import assets from url or using other resolvers #53999

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

Open
adeys opened this issue Feb 19, 2024 · 2 comments · May be fixed by #54133
Open

[AssetMapper] Allow to import assets from url or using other resolvers #53999

adeys opened this issue Feb 19, 2024 · 2 comments · May be fixed by #54133

Comments

@adeys
Copy link

adeys commented Feb 19, 2024

Description

I'm trying to require the @editorjs/editorjs package but unfortunately the jsdeliver powered endpoint seems to be broken
This is what I get in the downloaded file :

/**
 * Failed to bundle using Rollup v2.79.1.
 * If you believe this to be an issue with jsDelivr, and not with the package itself, please open an issue at https://github.com/jsdelivr/jsdelivr
 */

 throw new Error('Failed to bundle using Rollup v2.79.1. If you believe this to be an issue with jsDelivr, and not with the package itself, please open an issue at https://github.com/jsdelivr/jsdelivr');

It seems to be an error from jsDeliver as the package.json file from EditorJS hasn't been changed lately and the esm import works when using :
import Editor from 'https://esm.sh/@editorjs/editorjs@2.29.0';

Adding an url option may be an easy fix at first, so that user can require any file from anywhere
Adding either another resolver to the import map package resolver (jspm.io, unpkg.com, esm.sh) could help to get around those error cases would also help to not get constrained by errors from CDN

Example

A) importmap:require url option

bin/console importmap:require @editorjs/editorjs --url=https://esm.sh/v135/@editorjs/editorjs@2.29.0/es2022/editorjs.mjs

B) importmap:require resolver option

bin/console importmap:require @editorjs/editorjs --resolver=<resolver>

The resolver option could be any class implementing Symfony\Component\AssetMapper\ImportMap\Resolver\PackageResolverInterface and may be assigned an alias so that it can be used in the importmap:require command

@adeys adeys changed the title [AssetMapper] Allow to import assets from url [AssetMapper] Allow to import assets from url or using other resolvers Feb 19, 2024
@xabbuh xabbuh added the Feature label Feb 20, 2024
@ph-il
Copy link

ph-il commented Feb 26, 2024

@adeys This look like a nice PR for you to create.

@adeys
Copy link
Author

adeys commented Feb 26, 2024

@ph-il I'll make a proposal PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants