Closed ghost closed 11 years ago
Update: it seems like id
is just the raw string that appears in the require()
statement. This might not be worth fixing since I can always just re-normalize the filename parameter.
It has to appear twice so that anything that consumes the output is aware that both of those ids exist. An alternative would be to have an 'aliases' field alongside the filename. But I think that is worse since the existence of require('bar')
and require('bar.js')
is if in different source files will not be put under the alias (since they will be under their respective parent files).
Basically, the output of required is meant to be a direct mapping of ids required to the filenames those lead to.
Given this source,
x.js
:and this program,
req.js
:This output is not ideal since
./bar
and./bar.js
are the same file.