Skip to content

Commit

Permalink
ALTV-431 Get back require of alt-server & alt-shared
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Oct 2, 2024
1 parent 621bfb0 commit 4b8e59b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { defaultLoad, defaultLoadSync } = internalRequire('internal/modules/esm/l
const { initializeImportMeta } = internalRequire('internal/modules/esm/initialize_import_meta')
const { translators } = internalRequire('internal/modules/esm/translators');
const { ModuleWrap } = internalRequire('internal/test/binding').internalBinding('module_wrap');
const BuildInModule = internalRequire('module');

const path = require('path');
const alt = process._linkedBinding('alt');
Expand Down Expand Up @@ -205,6 +206,17 @@ function setupImports(esmLoader) {
};

esmLoader.setCustomizations(altLoader);

// CJS require hook
const _origModuleLoad = BuildInModule._load;
BuildInModule._load = function _load(request, parent, isMain) {
const altModule = altModules.get(request);
if (altModule !== undefined) {
return process._linkedBinding(altModule);
}

return _origModuleLoad(request, parent, isMain);
}
}

// ***** Utils
Expand Down

0 comments on commit 4b8e59b

Please sign in to comment.