-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Fix jsdelivr import parsing with no imported value #52508
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
[AssetMapper] Fix jsdelivr import parsing with no imported value #52508
Conversation
Actually, if the import has side effects, this is a valid usage. |
I think in this case the side effect is to add the plugin to the global jquery object. |
You're right. I guess i'm pleading into the void: "Can we please stop causing side effects with modules!!!" :) |
src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php
Outdated
Show resolved
Hide resolved
I'm no expert, but I also think the idea of explicitly adding the plugin to jquery is better than automatically adding it, even though it's an additional line of code. Because modules don't allow for conditional imports, I don't see how it's possible to selectively add theme-specific plugins. That is, if there's are select-bs4, select-bs5 and select-tailwind plugins, and merely importing them adds the plugin to jquery, there's no way to say "no, just bs5". Better, I think would be import selectBs5 from 'select-bs5';
import selectBs4 from 'select-bs4';
let plugin = (theme=='bs4') ? selectBs4 : selectBs5;
$.addPlugin(plugin); Allan is working on version 2 of datatables, as importmaps and javascript modules become more prominent perhaps he'll allow something like that. |
@tacman that's something to discuss elsewhere. AssetMapper has to handle JS files as they exist. |
a789bdf
to
db7f7ea
Compare
db7f7ea
to
dc1b27d
Compare
Yes, it's working now, the datatables modules are working. And fontawesome is working when I add those lines, I'm not sure if there's supposed to be a way to simply import. |
Another new import syntax found by @tacman! I think this one is kind of a bug in the library - a module environment should not
import 'foo'
(i.e. import a module and not actually use any value), but our job is just to find these, not judge them ;).FYI - I have an issue on jsdelivr proposing that they create an API endpoint to expose this info, so we don't need to parse it. They agree and already were thinking about this - jsdelivr/jsdelivr#18538 - so this may be something helpful in the future.
Cheers!