st-bundle
Version:
CLI for watching and bundling SpringType projects.
22 lines (21 loc) • 819 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const utils_1 = require("../utils/utils");
function handleBrowserField(packageMeta, absPath) {
if (typeof packageMeta.browser !== 'object') {
return;
}
for (const key in packageMeta.browser) {
const targetValue = packageMeta.browser[key];
if (typeof targetValue === 'string') {
if (path.extname(key) === '.js') {
const targetAbsPath = path.join(packageMeta.packageRoot, key);
if (utils_1.fileExists(targetAbsPath) && absPath === targetAbsPath) {
return path.join(path.join(packageMeta.packageRoot, targetValue));
}
}
}
}
}
exports.handleBrowserField = handleBrowserField;