1 | ;
|
2 |
|
3 | const path = require("path");
|
4 |
|
5 | module.exports = {
|
6 | requireWithFallback
|
7 | };
|
8 |
|
9 | /**
|
10 | * Require with statCache issue workaround
|
11 | * @param {string} packageNama
|
12 | */
|
13 | function requireWithFallback(packageNama) {
|
14 | // Workaround for
|
15 | // https://github.com/nodejs/node/issues/31803 statCache
|
16 | const mainPath = path.resolve(
|
17 | path.dirname(require.resolve(`${packageNama}/package.json`)),
|
18 | // @ts-ignore
|
19 | require(`${packageNama}/package.json`).main
|
20 | );
|
21 |
|
22 | return require(mainPath);
|
23 | }
|