brunch / commonjs-require-definition

Common.js require definition.
MIT License
13 stars 12 forks source link

Add support for file extensions and main aliases #14

Closed goshacmd closed 8 years ago

goshacmd commented 8 years ago

By using aliases for more than just components we can support requiring files with their full extension so that a JavaScript file and a template can have the same name with different extensions.

This also sets up main aliases for use with npm. When package.json defines a “main” alias the file can keep its original path for relative requires, but the package name can be aliased to it.

e.g. node_modules/moment/moment.js is referenced relatively by modules within the moment npm module. So it must keep moment/moment.js as its path. But it should also be able to be required using just moment.

This is just a rebased version of #12

goshacmd commented 8 years ago

@paulmillr