UNPKG

521 BJavaScriptView Raw
1'use strict';
2
3const path = require("path");
4
5module.exports = {
6 requireWithFallback
7};
8
9/**
10 * Require with statCache issue workaround
11 * @param {string} packageNama
12 */
13function 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}