3 ms·
Are there any trade-offs to this approach? This seems so obvious to me I'm confused why it is more widely used.
by nmjohn 11y ago
Are there any trade-offs to this approach? This seems so obvious to me I'm confused why it is more widely used.
- zebracanevra 11y agoIn node, require()'ing a dependency is stateless - it searches ./node_modules/ for the module, then ../n_m/ then ../../n_m/, etc, until it finds an appropriately named module. In JSPM/SystemJS, require()'ing/importing a module is still by name (as it supports NPM modules), but the package.json file has to be parsed in order to map module names to an installed module version. Note, this mapping is only done in the developer environment - once you build a bundle all the mapping is statically compiled into one file.