Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(browser).forEach(fromModuleName => {
const toModuleName = browser[fromModuleName];
const destPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, fromModuleName)
).asNative;
if (toModuleName == false) {
ignoreFile(destPath, fromModuleName, log);
} else {
const srcPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, toModuleName)
).asNative;
replaceFile(
pkgId,
srcPath,
toModuleName,
destPath,
fromModuleName,
log
);
}
});
}
Object.keys(browser).forEach(fromModuleName => {
const toModuleName = browser[fromModuleName];
const destPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, fromModuleName)
).asNative;
if (toModuleName == false) {
ignoreFile(destPath, fromModuleName, log);
} else {
const srcPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, toModuleName)
).asNative;
replaceFile(
pkgId,
srcPath,
toModuleName,
destPath,
fromModuleName,
log
function replaceMainModule(pkgDir, browser, pkgJson, log) {
const pkgId = `${pkgJson.name}@${pkgJson.version}`;
const main = pkgJson.main || 'index.js';
const srcPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, browser)
).asNative;
const destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, main))
.asNative;
replaceFile(pkgId, srcPath, browser, destPath, main, log);
}
function replaceMainModule(pkgDir, browser, pkgJson, log) {
const pkgId = `${pkgJson.name}@${pkgJson.version}`;
const main = pkgJson.main || 'index.js';
const srcPath = pkgDir.join(
pkgs.resolveModuleFile(pkgDir.asNative, browser)
).asNative;
const destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, main))
.asNative;
replaceFile(pkgId, srcPath, browser, destPath, main, log);
}