-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver-resolve.js
More file actions
23 lines (20 loc) · 845 Bytes
/
server-resolve.js
File metadata and controls
23 lines (20 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// used in replacement of tsconfig-resolve paths
// simpler and clearer just to resolve the paths used in the tsconfig
// without having to have supplied a tsconfig
const replacers = {
"@onzag/itemize-text-engine": "@onzag/itemize-text-engine/nodejs",
"@onzag/itemize": "@onzag/itemize/nodejs",
};
const replacersKeys = Object.keys(replacers);
const Module = require("module");
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request, _parent) {
for (let key of replacersKeys) {
if (request.startsWith(key)) {
const replaced = request.replace(key, replacers[key]);
const modifiedArguments = [replaced, ...[].slice.call(arguments, 1)];
return originalResolveFilename.apply(this, modifiedArguments);
}
}
return originalResolveFilename.apply(this, arguments);
};