jspm / npm

NPM Location Service
19 stars 34 forks source link

Support directory requires #6

Closed guybedford closed 10 years ago

guybedford commented 10 years ago

Modules can import a directory by name, which results in the index being loaded from that directory. We should detect these require forms within the local package and convert them into the index reference.

guybedford commented 10 years ago

We can allow this in the following way:

When installing a package from npm, we check for any files called index.js in sub-directories. If such a file is found, we create a file with the same name as the directory, subdirectory.js, containing a direct link to the index file - module.exports = require('./subdirectory/index'). If such a file name already exists, we don't overwrite it. In this way we get a full match with npm behaviour!

guybedford commented 10 years ago

This is now supported.