mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 02:27:01 +00:00
change
This commit is contained in:
@@ -76,8 +76,10 @@
|
||||
this._internalModuleListIsSet = false;
|
||||
this._bundleFileMap = {};
|
||||
this._bundleMapping = {};
|
||||
/** @type Object.<string, string[]> */
|
||||
/** @type {Object.<string, string[]>} */
|
||||
this._bundleDependenciesMap = {};
|
||||
/** @type {Object.<string, boolean>} */
|
||||
this._bundleIsLoadedMap = {};
|
||||
|
||||
this._addLibsConfigCallCount = 0;
|
||||
this._addLibsConfigCallMaxCount = 2;
|
||||
@@ -507,7 +509,7 @@
|
||||
if (name in this._bundleMapping) {
|
||||
let bundleName = this._bundleMapping[name];
|
||||
|
||||
this._addBundle(bundleName).then(() => {
|
||||
this._requireBundle(bundleName).then(() => {
|
||||
let classObj = this._getClass(name);
|
||||
|
||||
if (!classObj) {
|
||||
@@ -606,11 +608,15 @@
|
||||
* @param {string} name
|
||||
* @return {Promise}
|
||||
*/
|
||||
_addBundle: function (name) {
|
||||
_requireBundle: function (name) {
|
||||
if (this._bundleIsLoadedMap[name]) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let dependencies = this._bundleDependenciesMap[name] || [];
|
||||
|
||||
if (!dependencies.length) {
|
||||
return this._addBundleInternal(name);
|
||||
return this._addBundle(name);
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
@@ -618,7 +624,7 @@
|
||||
|
||||
Promise.all(list)
|
||||
.then(() => {
|
||||
return this._addBundleInternal(name);
|
||||
return this._addBundle(name);
|
||||
})
|
||||
.then(() => resolve());
|
||||
});
|
||||
@@ -629,7 +635,7 @@
|
||||
* @param {string} name
|
||||
* @return {Promise}
|
||||
*/
|
||||
_addBundleInternal: function (name) {
|
||||
_addBundle: function (name) {
|
||||
let src = this._bundleFileMap[name];
|
||||
|
||||
if (!src) {
|
||||
@@ -656,7 +662,11 @@
|
||||
return new Promise(resolve => {
|
||||
document.head.appendChild(scriptEl);
|
||||
|
||||
scriptEl.addEventListener('load', () => resolve());
|
||||
scriptEl.addEventListener('load', () => {
|
||||
this._bundleIsLoadedMap[name] = true;
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
"templatePatterns": [
|
||||
"client/modules/crm/res/templates/**/*.tpl"
|
||||
],
|
||||
"allPatterns": [
|
||||
"lookupPatterns": [
|
||||
"client/modules/crm/src/**/*.js"
|
||||
]
|
||||
},
|
||||
@@ -119,8 +119,8 @@
|
||||
"dependentOn": [
|
||||
"lib!Summernote"
|
||||
],
|
||||
"libs": ["Summernote"],
|
||||
"allPatterns": [
|
||||
"requiredLibs": ["Summernote"],
|
||||
"lookupPatterns": [
|
||||
"client/modules/crm/src/**/*.js"
|
||||
]
|
||||
},
|
||||
@@ -132,8 +132,8 @@
|
||||
"lib!Flotr",
|
||||
"lib!espo-funnel-chart"
|
||||
],
|
||||
"libs": ["Flotr", "espo-funnel-chart"],
|
||||
"allPatterns": [
|
||||
"requiredLibs": ["Flotr", "espo-funnel-chart"],
|
||||
"lookupPatterns": [
|
||||
"client/modules/crm/src/**/*.js"
|
||||
]
|
||||
},
|
||||
@@ -144,8 +144,8 @@
|
||||
"dependentOn": [
|
||||
"lib!full-calendar"
|
||||
],
|
||||
"libs": ["full-calendar"],
|
||||
"allPatterns": [
|
||||
"requiredLibs": ["full-calendar"],
|
||||
"lookupPatterns": [
|
||||
"client/modules/crm/src/**/*.js"
|
||||
]
|
||||
},
|
||||
@@ -156,8 +156,8 @@
|
||||
"dependentOn": [
|
||||
"lib!vis"
|
||||
],
|
||||
"libs": ["vis"],
|
||||
"allPatterns": [
|
||||
"requiredLibs": ["vis"],
|
||||
"lookupPatterns": [
|
||||
"client/modules/crm/src/**/*.js"
|
||||
]
|
||||
},
|
||||
@@ -174,7 +174,7 @@
|
||||
"modulePaths": {
|
||||
"crm": "client/modules/crm"
|
||||
},
|
||||
"allPatterns": [
|
||||
"lookupPatterns": [
|
||||
"client/src/**/*.js"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ class BundlerGeneral {
|
||||
* chunks: Object.<string, {
|
||||
* files?: string[],
|
||||
* patterns?: string[],
|
||||
* allPatterns?: string[],
|
||||
* lookupPatterns?: string[],
|
||||
* templatePatterns?: string[],
|
||||
* noDuplicates?: boolean,
|
||||
* dependentOn?: string[],
|
||||
* libs?: string[],
|
||||
* requiredLibs?: string[],
|
||||
* }>,
|
||||
* modulePaths?: Record.<string, string>,
|
||||
* allPatterns: string[],
|
||||
* lookupPatterns: string[],
|
||||
* order: string[],
|
||||
* }} config
|
||||
* @param {{
|
||||
@@ -97,7 +97,7 @@ class BundlerGeneral {
|
||||
|
||||
let bundleFile = this.filePattern.replace('{*}', name);
|
||||
|
||||
let libs = this.config.chunks[name].libs;
|
||||
let libs = this.config.chunks[name].requiredLibs;
|
||||
|
||||
if (libs) {
|
||||
let part = JSON.stringify(libs.map(item => 'lib!' + item));
|
||||
@@ -150,9 +150,9 @@ class BundlerGeneral {
|
||||
let params = this.config.chunks[name];
|
||||
|
||||
let patterns = params.patterns;
|
||||
let allPatterns = []
|
||||
.concat(this.config.allPatterns)
|
||||
.concat(params.allPatterns || []);
|
||||
let lookupPatterns = []
|
||||
.concat(this.config.lookupPatterns)
|
||||
.concat(params.lookupPatterns || []);
|
||||
|
||||
let bundledFiles = [];
|
||||
let bundledTemplateFiles = [];
|
||||
@@ -171,7 +171,7 @@ class BundlerGeneral {
|
||||
let data = bundler.bundle({
|
||||
files: params.files,
|
||||
patterns: patterns,
|
||||
allPatterns: allPatterns,
|
||||
lookupPatterns: lookupPatterns,
|
||||
libs: this.libs,
|
||||
ignoreFiles: ignoreFiles,
|
||||
dependentOn: params.dependentOn,
|
||||
|
||||
@@ -57,7 +57,7 @@ class Bundler {
|
||||
* @param {{
|
||||
* files?: string[],
|
||||
* patterns: string[],
|
||||
* allPatterns?: string[],
|
||||
* lookupPatterns?: string[],
|
||||
* ignoreFiles?: string[],
|
||||
* dependentOn?: string[],
|
||||
* libs: {
|
||||
@@ -79,7 +79,7 @@ class Bundler {
|
||||
.concat(this.#obtainFiles(params.patterns, params.files))
|
||||
.filter(file => !params.ignoreFiles.includes(file));
|
||||
|
||||
let allFiles = this.#obtainFiles(params.allPatterns || params.patterns);
|
||||
let allFiles = this.#obtainFiles(params.lookupPatterns || params.patterns);
|
||||
|
||||
let ignoreLibs = params.libs
|
||||
.filter(item => item.key && !item.bundle)
|
||||
@@ -229,7 +229,7 @@ class Bundler {
|
||||
|
||||
let modulePaths = modules.map(name => {
|
||||
if (!moduleFileMap[name]) {
|
||||
throw Error(`Can't obtain ${name}. Might be missing in allPatterns.`);
|
||||
throw Error(`Can't obtain ${name}. Might be missing in lookupPatterns.`);
|
||||
}
|
||||
|
||||
return moduleFileMap[name];
|
||||
|
||||
Reference in New Issue
Block a user