filter out legacy JS code from importmap and sort it

also only add extension-less includes for .ts files (was accidentally commented out) and fix some .js imports without extension
This commit is contained in:
Ralf Becker 2021-06-12 11:44:17 +02:00
parent d6c6e14abf
commit ee508c50b9
9 changed files with 17 additions and 11 deletions

View File

@ -12,8 +12,8 @@
egw_action;
*/
import {EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED, egwActionObjectInterface, EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT} from "./egw_action";
import {egwBitIsSet} from "./egw_action_common";
import {EGW_AO_STATE_FOCUSED, EGW_AO_STATE_SELECTED, egwActionObjectInterface, EGW_AI_DRAG_OVER, EGW_AI_DRAG_OUT} from "./egw_action.js";
import {egwBitIsSet} from "./egw_action_common.js";
/**
* This file contains an egw_actionObjectInterface which allows a dhtmlx tree

View File

@ -17,7 +17,6 @@ import { et2_register_widget } from "./et2_core_widget";
import { ClassWithAttributes } from "./et2_core_inheritance";
import { et2_no_init } from "./et2_core_common";
import { et2_vfsSize } from "./et2_widget_vfs";
import "../Resumable/resumable.js";
/**
* Class which implements file upload
*

View File

@ -20,7 +20,6 @@ import {ClassWithAttributes} from "./et2_core_inheritance";
import {et2_no_init} from "./et2_core_common";
import {et2_DOMWidget} from "./et2_core_DOMWidget";
import {et2_vfsSize} from "./et2_widget_vfs";
import "../Resumable/resumable.js";
/**
* Class which implements file upload

View File

@ -27,7 +27,7 @@ import { et2_compileLegacyJS } from "./et2_core_legacyJSFunctions";
import { et2_loadXMLFromURL } from "./et2_core_xml";
import { et2_nextmatch, et2_nextmatch_header_bar } from "./et2_extension_nextmatch";
import '../jsapi/egw_json.js';
import { egwIsMobile } from "../egw_action/egw_action_common";
import { egwIsMobile } from "../egw_action/egw_action_common.js";
/* Include all widget classes here, we only care about them registering, not importing anything
import './et2_widget_template';
import './et2_widget_grid';

View File

@ -85,7 +85,7 @@ import {et2_loadXMLFromURL} from "./et2_core_xml";
import {et2_nextmatch, et2_nextmatch_header_bar} from "./et2_extension_nextmatch";
import {et2_tabbox} from "./et2_widget_tabs";
import '../jsapi/egw_json.js';
import {egwIsMobile} from "../egw_action/egw_action_common";
import {egwIsMobile} from "../egw_action/egw_action_common.js";
/* Include all widget classes here, we only care about them registering, not importing anything
import './et2_widget_template';

View File

@ -19,5 +19,6 @@
/vendor/egroupware/magicsuggest/magicsuggest.js;
/api/js/jquery/splitter.js;
/api/js/jquery/blueimp/js/blueimp-gallery.min.js;
/api/js/Resumable/resumable.js;
*/
jQuery.noConflict();

View File

@ -78,7 +78,7 @@ window.app = {classes: {}};
window.egw_appName = egw_script.getAttribute('data-app');
// split includes in legacy js and modules
const legacy_js_regexp = /\/dhtmlx|jquery/;
const legacy_js_regexp = /\/dhtmlx|jquery|magicsuggest|resumable/;
// check if egw object was injected by window open
if (typeof window.egw == 'undefined')

View File

@ -1124,7 +1124,7 @@ abstract class Framework extends Framework\Extra
/**
* Files imported via script tag in egw.js, because they are no modules
*/
const legacy_js_imports = '/\/dhtmlx|jquery/';
const legacy_js_imports = '#/dhtmlx|jquery|magicsuggest|resumable#';
/**
* Add EGroupware URL prefix eg. '/egroupware' to files AND bundles
@ -1137,8 +1137,6 @@ abstract class Framework extends Framework\Extra
// adding some extra mappings
if (($prefix = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)) === '/') $prefix = '';
$imports['jquery'] = $imports[$prefix.'/vendor/bower-asset/jquery/dist/jquery.js'];
$imports['jqueryui'] = $imports[$prefix.'/vendor/bower-asset/jquery-ui/jquery-ui.js'];
// fix egw_global(.d.ts) import
$imports[$prefix.'/api/js/jsapi/egw_global'] = $prefix.'/api/js/jsapi/egw_global.js?'.

View File

@ -13,6 +13,7 @@
namespace EGroupware\Api\Framework;
use EGroupware\Api;
use EGroupware\Api\Cache;
use EGroupware\Api\Header\UserAgent;
@ -380,12 +381,20 @@ class Bundle
if (!$use_bundle) $target = $file;
$map[$prefix . $file] = $prefix.$target.'?'.filemtime(EGW_SERVER_ROOT.$target);
// typescript unfortunately has currently no option to add ".js" to it's es6 import statements
// therefore we add extra entries without .js extension to the map if (file_exists(EGW_SERVER_ROOT.substr($file, 0, -3) . '.ts'))
// therefore we add extra entries without .js extension to the map
if (file_exists(EGW_SERVER_ROOT.substr($file, 0, -3) . '.ts'))
{
$map[$prefix . substr($file, 0, -3)] = $prefix.$target.'?'.filemtime(EGW_SERVER_ROOT.$target);
}
}
}
// filter out legacy js files not load via import
$map = array_filter($map, function($url)
{
return !preg_match(Api\Framework::legacy_js_imports, $url);
});
ksort($map);
return $map;
}, [], 30);
}