UNPKG

als-require

Version:

A utility for using CommonJS require in the browser and creating bundles.

13 lines (12 loc) 453 B
function getNodeModules(path,logger) { const warn = () => { logger.warn(`The module "${path}" can't be imported and will be replaced with {}`) return false } try { const newPath = require.resolve(path) if(newPath === path) return warn() // it's a standart nodejs modules return newPath.replace(process.cwd(),'').replace(/\\/g,'/') } catch (error) { return warn() } } module.exports = getNodeModules