Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.43k stars 2.78k forks source link

Allow to add JS as `type="module"` #31548

Open Daviid-P opened 1 week ago

Daviid-P commented 1 week ago

https://github.com/Dolibarr/dolibarr/blob/13ec815864bfefd4c435098ff9b6aecd6da7a5ee/htdocs/main.inc.php#L2178

It would be nice to be able to add global JS as type="module"

Maybe by having a 'js_module' in $this->module_parts or by starting the path with module:

$this->module_parts = array(
    'js' => array(
        'module:/evMyModule/js/main.js',
    ),
    'js_module' => array(
        '/evMyModule/js/main.js',
    )
);

Maybe separate between js that goes in the head and js that goes at the end of the body?

Daviid-P commented 1 week ago

BTW, right now I'm doing this using the beforeBodyClose and addHtmlHeader hooks. Because I need to load one after another and this is the only way I found.