UNPKG

als-require

Version:

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

17 lines (11 loc) 764 B
## Require node_modules packages and node modules In case of path which not starts with `.`, Require will look for file in node_modules (by checking in package.json). If such package not found (for example `require('fs')`), result for this package will return empty object. ```js const somePackage = require('some-package'); const somePackage1 = require('./node_modules/some-package/index.js'); const fs = require('fs'); module.exports = {somePackage,somePackage1,fs} ``` In case above `somePackage` and `somePackage1` should return the package, but fs, should return empty object. Pay attention, in browser, using `'./node_modules/some-package/index.js'` instead `'some-package'`, you save extra request/readFile for looking the filename.