2 Object.defineProperty(exports, "__esModule", { value: true });
3 const tslib_1 = require("tslib");
4 const errorHandler_1 = require("./errorHandler");
5 const resolve_from_1 = tslib_1.__importDefault(require("resolve-from"));
6 const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
8 * Require package explicitly installed relative to given path.
9 * Fallback to bundled one if no package was found bottom up.
10 * @param {string} fspath file system path starting point to resolve package
11 * @param {string} pkgName package's name to require
14 function requireLocalPkg(fspath, pkgName, options = { silent: true, ignoreBundled: false }) {
15 let modulePath = resolve_from_1.default.silent(fspath, pkgName);
16 if (modulePath !== void 0) {
18 return requireFunc(modulePath);
21 if (!options.silent) {
22 errorHandler_1.addToOutput(`Failed to load require ${pkgName} from ${modulePath}.${options.ignoreBundled ? `` : ` Using bundled`}`, 'Error');
26 return options.ignoreBundled ? null : requireFunc(pkgName);
28 exports.requireLocalPkg = requireLocalPkg;
29 //# sourceMappingURL=requirePkg.js.map