1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.installCommonjsResolveHooksIfNecessary = void 0;
|
4 |
|
5 |
|
6 |
|
7 | function installCommonjsResolveHooksIfNecessary(tsNodeService) {
|
8 | const Module = require('module');
|
9 | const originalResolveFilename = Module._resolveFilename;
|
10 | const originalFindPath = Module._findPath;
|
11 | const shouldInstallHook = tsNodeService.options.experimentalResolver;
|
12 | if (shouldInstallHook) {
|
13 | const { Module_findPath, Module_resolveFilename } = tsNodeService.getNodeCjsLoader();
|
14 | Module._resolveFilename = _resolveFilename;
|
15 | Module._findPath = _findPath;
|
16 | function _resolveFilename(request, parent, isMain, options, ...rest) {
|
17 | if (!tsNodeService.enabled())
|
18 | return originalResolveFilename.call(this, request, parent, isMain, options, ...rest);
|
19 | return Module_resolveFilename.call(this, request, parent, isMain, options, ...rest);
|
20 | }
|
21 | function _findPath() {
|
22 | if (!tsNodeService.enabled())
|
23 | return originalFindPath.apply(this, arguments);
|
24 | return Module_findPath.apply(this, arguments);
|
25 | }
|
26 | }
|
27 | }
|
28 | exports.installCommonjsResolveHooksIfNecessary = installCommonjsResolveHooksIfNecessary;
|
29 |
|
\ | No newline at end of file |