Alias

A straightforward way to import npm dependencies into your module is to use their relative paths, like we do for any other code. For example:

Having to supply the relative path to node_modules is not cool though and, besides that, it may cause problems when a module doing that is imported later as an npm dependency of another project, since the paths will change.

Knowing that, Metal.js allows importing npm dependencies like you would from a regular node module, just by referencing their names. Note that this will only work when using Metal.js's build tools or adding a similar logic to your build process yourself (though we provide a babel preset with this logic that you can use separately too).

With aliases, the previous example can be rewritten like this: