I have an angular 11 application - which is like a hosting application(which have universal overlay from where we will load the other angular application)
As of now we have our own runtime js and one vendor js which will be avilable for other angular application as well.
we have a custom webpack.js which is used to build all the applications
we are using webpack 4, so all the build will be in same namespace(eg: webpackjsonp)
Now lets allow other applications to pack their dependencies and own version of angular etc.
so i used custom namespace for other applications.
The problem is my runtime js is not able to load the other namespace files - any idea to resolve the other application files in different namespace?
Runtime js
"use strict";
(function (modules) {
var lastContextPath = null;
var contextModuleRequire = {};
// install a JSONP callback for chunk loading
function webpackJsonpCallback(data) {
var chunkIds = data[0];
var moreModules = data[1];
var executeModules = data[2];
var dependencyModules = [];
if (executeModules && executeModules.length > 0) {
dependencyModules = executeModules[0];
}
// add "moreModules" to the modules object,
// then flag all "chunkIds" as loaded and fire callback
var moduleId, chunkId, i = 0, resolves = [];
for (; i < chunkIds.length; i++) {
chunkId = chunkIds[i];
if (chunkId.split && chunkId.split('~').length > 1) {
lastContextPath = chunkId.split('~')[0];
chunkId = '/' + chunkId.split('~')[0] + '/' + chunkId;
}
else if (!chunkId.split) {
chunkId = '/' + lastContextPath + '/' + chunkId;
}
if (installedChunks[chunkId]) {
resolves.push(installedChunks[chunkId][0]);
}
installedChunks[chunkId] = 0;
}
for (moduleId in moreModules) {
if (Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
if ((moduleId === './src/$$_lazy_route_resource lazy recursive' || (moduleId === './$$_lazy_route_resource lazy recursive')) && modules[moduleId]) {
// don't overwrite, load only once
continue;
}
modules[moduleId] = moreModules[moduleId];
}
}
if (parentJsonpFunction)
parentJsonpFunction(data);
var commonChunks = dependencyModules.filter(function (t) {
return isNaN(t) && t.indexOf('./src') < 0 && t !== 'vendors' && t !== 'runtime';
});
var commonChunkId = commonChunks && commonChunks.length > 0 ? commonChunks[0] : null;
if (commonChunkId) {
lastContextPath = commonChunkId.split('~')[0];
__webpack_require__.e('/' + commonChunkId.split('~')[0] + '/' + commonChunkId).then(function () {
// resolve previous promises
while (resolves.length) {
resolves.shift()();
}
});
}
else {
while (resolves.length) {
resolves.shift()();
}
}
// add entry modules from loaded chunk to deferred list
deferredModules.push.apply(deferredModules, executeModules || []);
// run deferred modules when all chunks ready
return checkDeferredModules();
}
;
function checkDeferredModules() {
var result;
for (var i = 0; i < deferredModules.length; i++) {
var deferredModule = deferredModules[i];
var fulfilled = true;
for (var j = 1; j < deferredModule.length; j++) {
var depId = deferredModule[j];
if (installedChunks[depId] !== 0)
fulfilled = false;
}
if (fulfilled) {
deferredModules.splice(i--, 1);
result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
}
}
return result;
}
// The module cache
var installedModules = {};
// object to store loaded and loading chunks
// undefined = chunk not loaded, null = chunk preloaded/prefetched
// Promise = chunk loading, 0 = chunk loaded
var installedChunks = {
"runtime": 0
};
var deferredModules = [];
// script path function
function jsonpScriptSrc(chunkId) {
return __webpack_require__.p + "" + (chunkId.replace('.js', '')) + ".js";
}
function __get_module_webpack_require(contextPath) {
function __module_webpack_require__(moduleId) {
return __webpack_require__(moduleId);
}
;
__module_webpack_require__.e = function (chunkId) {
return __webpack_require__.e(chunkId, contextPath);
};
__module_webpack_require__.m = __webpack_require__.m;
__module_webpack_require__.c = __webpack_require__.c;
__module_webpack_require__.d = __webpack_require__.d;
__module_webpack_require__.r = __webpack_require__.r;
__module_webpack_require__.t = __webpack_require__.t;
__module_webpack_require__.n = __webpack_require__.n;
__module_webpack_require__.o = __webpack_require__.o;
__module_webpack_require__.p = __webpack_require__.p;
__module_webpack_require__.s = __webpack_require__.s;
__module_webpack_require__.nc = __webpack_require__.nc;
__module_webpack_require__.oe = __webpack_require__.oe;
__module_webpack_require__.mapBundles = __webpack_require__.mapBundles;
return __module_webpack_require__;
}
// The require function
function __webpack_require__(moduleId) {
// Check if module is in cache
if (installedModules[moduleId]) {
return installedModules[moduleId].exports;
}
// Create a new module (and put it into the cache)
var module = installedModules[moduleId] = {
i: moduleId,
l: false,
exports: {}
};
// Execute the module function
var __mod_webpack_require__ = __webpack_require__;
if (lastContextPath && contextModuleRequire) {
if (!contextModuleRequire[lastContextPath]) {
contextModuleRequire[lastContextPath] = __get_module_webpack_require(lastContextPath);
}
__mod_webpack_require__ = contextModuleRequire[lastContextPath];
}
modules[moduleId].call(module.exports, module, module.exports, __mod_webpack_require__);
// Flag the module as loaded
module.l = true;
// Return the exports of the module
return module.exports;
}
// This file contains only the entry chunk.
// The chunk loading function for additional chunks
__webpack_require__.e = function requireEnsure(chunkId, contextPath) {
if (contextPath) {
lastContextPath = contextPath;
}
if (!chunkId.replace) {
chunkId = '/' + lastContextPath + '/' + chunkId;
}
var promises = [];
// JSONP chunk loading for javascript
var installedChunkData = installedChunks[chunkId];
if (installedChunkData !== 0) { // 0 means "already installed".
// a Promise means "currently loading".
if (installedChunkData) {
promises.push(installedChunkData[2]);
}
else {
// setup Promise in chunk cache
var promise = new Promise(function (resolve, reject) {
installedChunkData = installedChunks[chunkId] = [resolve, reject];
});
promises.push(installedChunkData[2] = promise);
// start chunk loading
var script = document.createElement('script');
var onScriptComplete;
script.charset = 'utf-8';
script.timeout = 120;
if (__webpack_require__.nc) {
script.setAttribute("nonce", __webpack_require__.nc);
}
script.src = jsonpScriptSrc(chunkId);
onScriptComplete = function (event) {
// avoid mem leaks in IE.
script.onerror = script.onload = null;
clearTimeout(timeout);
var chunk = installedChunks[chunkId];
if (chunk !== 0) {
if (chunk) {
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
var realSrc = event && event.target && event.target.src;
var error = new Error('Loading chunk ' + chunkId + ' failed.
(' + errorType + ': ' + realSrc + ')');
error.type = errorType;
error.request = realSrc;
chunk[1](error);
}
installedChunks[chunkId] = undefined;
}
};
var timeout = setTimeout(function () {
onScriptComplete({ type: 'timeout', target: script });
}, 120000);
script.onerror = script.onload = onScriptComplete;
document.head.appendChild(script);
}
}
return Promise.all(promises);
};
// expose the modules object (__webpack_modules__)
__webpack_require__.m = modules;
// expose the module cache
__webpack_require__.c = installedModules;
// define getter function for harmony exports
__webpack_require__.d = function (exports, name, getter) {
if (!__webpack_require__.o(exports, name)) {
Object.defineProperty(exports, name, { enumerable: true, get: getter });
}
};
// define __esModule on exports
__webpack_require__.r = function (exports) {
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
// create a fake namespace object
// mode & 1: value is a module id, require it
// mode & 2: merge all properties of value into the ns
// mode & 4: return value when already ns object
// mode & 8|1: behave like require
__webpack_require__.t = function (value, mode) {
if (mode & 1)
value = __webpack_require__(value);
if (mode & 8)
return value;
if ((mode & 4) && typeof value === 'object' && value && value.__esModule)
return value;
var ns = Object.create(null);
__webpack_require__.r(ns);
Object.defineProperty(ns, 'default', { enumerable: true, value: value });
if (mode & 2 && typeof value != 'string')
for (var key in value)
__webpack_require__.d(ns, key, function (key) { return value[key]; }.bind(null, key));
return ns;
};
// getDefaultExport function for compatibility with non-harmony modules
__webpack_require__.n = function (module) {
var getter = module && module.__esModule ?
function getDefault() { return module['default']; } :
function getMod