Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
Description
Symfony version(s) affected
Assetmapper 6.4
Description
I'm trying to load a jquery plugin on datatables. I'm able to get it to work if the libraries are loaded remotely, but not when assetmapper copies them to the local directory. In throws a 404 related to jquery
How to reproduce
symfony new bug --webapp --version=next&&cd bugcomposer req symfony/asset-mapperbin/console importmap:require datatables.net-bs5 datatables.net-select-bs5bin/console make:controller AppControllersed -i"s|Route('/app'|Route('/'|" src/Controller/AppController.phpcat> assets/app.js<<'END'import jquery from 'jquery'import DataTables from 'datatables.net-bs5'import 'datatables.net-select-bs5';ENDsymfony server:start -d symfony open:local
I originally thought it was an issue with the datatables library, so I created an example script to show the problem, using the esm urls instead of the local files that assetmapper create, but I couldn't recreate the bug.
<scripttype="importmap">{"imports":{"datatables.net-bs5":"https://cdn.jsdelivr.net/npm/datatables.net-bs5@1.13.7/+esm","datatables.net-select-bs5":"https://cdn.jsdelivr.net/npm/datatables.net-select-bs5@1.7.0/+esm"}}</script><scripttype="module">importDataTablefrom'datatables.net-bs5'import'datatables.net-select-bs5'console.log('datatables loaded.');lett=newDataTable('#example');/* console.log(t.id); */</script>
Seehttps://jsfiddle.net/tacman1123/b2f3hj08/44/
I suspect this has something to do with the 'global' jquery, webpack had a autoProvideJquery() option to help with this. I'll also ask the library author, but since I can't provide a jsfiddle example of it not working, I'm wondering if perhaps it's related to AssetMapper.