idea-php-symfony2-plugin icon indicating copy to clipboard operation
idea-php-symfony2-plugin copied to clipboard

Importmap support for resolving packages

Open weaverryan opened this issue 2 years ago • 2 comments

Hi!

I'm not sure if this would best fit into the plugin or inside PHPstorm itself... I'd love to know what you think.

Suppose we have:

// assets/app.js

import _ from 'lodash';

There is no package.json in this project, as it's using AssetMapper. Instead, there is an importmap.php file, which has this:

return [
    // ...
    'lodash' => [
        'url' => 'https://cdn.jsdelivr.net/npm/[email protected]/+esm',
    ],
];

This results in an importmap being output on the page for the browser so that when we import lodash, we are actually getting it from that CDN URL. The "idea" is that PhpStorm would recognize this give auto-completion when coding.

I "think" that doing this involves having PhpStorm "download" (or at least offer us the ability to download it - like when you have a <script src="https://cdn.jsdelivr.net/npm/[email protected]/+esm> inside an HTML file) the file. If I add the <script> tag to base.html.twig, hit "Download", then delete it, I DO get auto-completion (though, as minor secondary issue, PhpStorm still highlights that library with the option to add it to package.json)

Screenshot 2023-06-20 at 11 25 52 AM

WDYT?

weaverryan avatar Jun 20 '23 15:06 weaverryan

from what i know there is a build in feature to resolve external packages via url, maybe there is a way to trigger it via a fake file or there are some extension points that allow to register the modules.

both need to check firstly in detail, but loading an importmap.php will not make it into PhpStorm itself, i guess, and needs to be done via a external plugin.

Haehnchen avatar Jul 03 '23 15:07 Haehnchen

from what i know there is a build in feature to resolve external packages via url, maybe there is a way to trigger it via a fake file or there are some extension points that allow to register the modules

Exactly - the "feature" if resolving external packages via a URL is there... so the question is: can this be hooked into. Unfortunately, I don't know the answer :p

both need to check firstly in detail, but loading an importmap.php will not make it into PhpStorm itself, i guess, and needs to be done via a external plugin.

👍

weaverryan avatar Jul 05 '23 16:07 weaverryan

https://blog.jetbrains.com/phpstorm/2024/04/phpstorm-2024-1-is-now-available/#support-for-symfony’s-assetmapper closed. asset mapper is include in PhpStorm itself, features should go directly into their issue tracker.

Haehnchen avatar Apr 04 '24 15:04 Haehnchen