Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
presetFile = require.resolve('liferay-npm-bundler-preset-standard');
} else if (config.preset === '' || config.preset === false) {
// don't load preset
} else {
presetFile = resolveModule.sync(config.preset, {
basedir: '.',
});
}
if (presetFile) {
const originalConfig = Object.assign({}, config);
Object.assign(
config,
merge.recursive(readJsonSync(presetFile), originalConfig)
);
config.pluginsBaseDir = getPackageDir(presetFile);
}
// Normalize
config['/'] = config['/'] || {};
config['config'] = config['config'] || {};
config.packages = config.packages || {};
}
config = readJsonSync('.npmbundlerrc');
} catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
// Apply preset if necessary
if (config.preset) {
const presetFile = resolveModule.sync(config.preset, {
basedir: '.',
});
// Merge preset with base configuration
config = Object.assign(readJsonSync(presetFile), config);
pluginsBaseDir = getPackageDir(presetFile);
}
// Normalize
config.packages = config.packages || {};
return config;
}
function getModuleName(filenameRelative, srcPrefixes) {
const filenameAbsolute = path.resolve(filenameRelative);
const pkgDir = pkgs.getPackageDir(filenameRelative);
let moduleName = filenameAbsolute.substring(pkgDir.length + 1);
if (moduleName.toLowerCase().endsWith('.js')) {
moduleName = moduleName.substring(0, moduleName.length - 3);
}
for (let i = 0; i < srcPrefixes.length; i++) {
const srcPrefix = path.normalize(srcPrefixes[i]);
if (moduleName.startsWith(srcPrefix)) {
moduleName = moduleName.substring(srcPrefix.length);
break;
}
}
__filename: function(filePath) {
const pkgDir = getPackageDir(filePath);
let filename = filePath.substring(pkgDir.length + 1);
return `var __filename = '/${filename}';`;
},
clearImmediate: 'require("liferay-node-setimmediate");',