mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	debug-require: Throw errors for unknown and unloaded modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							11b0303d55
						
					
				
				
					commit
					d5d6e43453
				
			@@ -86,7 +86,11 @@ export default class DebugRequirePlugin {
 | 
			
		||||
                        source,
 | 
			
		||||
                        `${requireFn}(${JSON.stringify(
 | 
			
		||||
                            debugRequireId,
 | 
			
		||||
                        )}).initialize(${JSON.stringify(Object.fromEntries(ids), null, "\t")});`,
 | 
			
		||||
                        )}).initialize(${JSON.stringify(
 | 
			
		||||
                            Object.fromEntries(ids),
 | 
			
		||||
                            null,
 | 
			
		||||
                            "\t",
 | 
			
		||||
                        )}, modules);`,
 | 
			
		||||
                    ]);
 | 
			
		||||
                },
 | 
			
		||||
            );
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,21 @@
 | 
			
		||||
/* global __webpack_require__ */
 | 
			
		||||
 | 
			
		||||
let webpackModules;
 | 
			
		||||
 | 
			
		||||
function debugRequire(request) {
 | 
			
		||||
    return __webpack_require__(debugRequire.ids[request]);
 | 
			
		||||
    if (!Object.prototype.hasOwnProperty.call(debugRequire.ids, request)) {
 | 
			
		||||
        throw new Error("Cannot find module '" + request + "'");
 | 
			
		||||
    }
 | 
			
		||||
    const moduleId = debugRequire.ids[request];
 | 
			
		||||
    if (!Object.prototype.hasOwnProperty.call(webpackModules, moduleId)) {
 | 
			
		||||
        throw new Error("Module '" + request + "' has not been loaded yet");
 | 
			
		||||
    }
 | 
			
		||||
    return __webpack_require__(moduleId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
debugRequire.initialize = function (ids) {
 | 
			
		||||
debugRequire.initialize = function (ids, modules) {
 | 
			
		||||
    debugRequire.ids = ids;
 | 
			
		||||
    webpackModules = modules;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
module.exports = debugRequire;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user