1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.dynamicRequireNoCache = exports.dynamicRequire = void 0;
|
4 | const fslib_1 = require("@yarnpkg/fslib");
|
5 |
|
6 | exports.dynamicRequire = eval(`require`);
|
7 | function dynamicRequireNoCache(path) {
|
8 | const physicalPath = fslib_1.npath.fromPortablePath(path);
|
9 | const currentCacheEntry = exports.dynamicRequire.cache[physicalPath];
|
10 | delete exports.dynamicRequire.cache[physicalPath];
|
11 | let result;
|
12 | try {
|
13 | result = (0, exports.dynamicRequire)(physicalPath);
|
14 | const freshCacheEntry = exports.dynamicRequire.cache[physicalPath];
|
15 | const dynamicModule = eval(`module`);
|
16 | const freshCacheIndex = dynamicModule.children.indexOf(freshCacheEntry);
|
17 | if (freshCacheIndex !== -1) {
|
18 | dynamicModule.children.splice(freshCacheIndex, 1);
|
19 | }
|
20 | }
|
21 | finally {
|
22 | exports.dynamicRequire.cache[physicalPath] = currentCacheEntry;
|
23 | }
|
24 | return result;
|
25 | }
|
26 | exports.dynamicRequireNoCache = dynamicRequireNoCache;
|