Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Actually, if the import has side effects, this is a valid usage. |
Ithink 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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
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 importselectBs5from'select-bs5';importselectBs4from'select-bs4';letplugin=(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
todb7f7ea
Comparedb7f7ea
todc1b27d
CompareYes, 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!