Node.js: renamed "require_shim" to "loader".

This commit is contained in:
Oisin Canty
2021-05-24 09:01:42 +00:00
parent d643900237
commit c160ea11e4
15 changed files with 16 additions and 16 deletions

View File

@@ -0,0 +1,27 @@
// can only be ran as part of a --require param on the node process
if (module.parent && module.parent.id === "internal/preload") {
const { Module } = require("module")
if (!Module.prototype.require.__unit_loader) {
const http = require("./http")
const websocket = require("./websocket")
const original = Module.prototype.require;
Module.prototype.require = function (id) {
switch(id) {
case "http":
case "unit-http":
return http
case "websocket":
case "unit-http/websocket":
return websocket
}
return original.apply(this, arguments);
}
Module.prototype.require.__unit_loader = true;
}
}