componentjs / builder2.js

builder for component
50 stars 20 forks source link

Local dependencies in different paths with matching prefixes bug in new dependency lookup #81

Closed bowd closed 10 years ago

bowd commented 10 years ago

This bug was introduced by me with the nested components lookup changes #75

The test shows it pretty well but as a recap:

The top-level component has: two paths: lib1 and lib2.

The top-level component also defines test and test_again as local dependencies.

When the component requires test_again the lookup process finds test as local dependency that matches as a prefix of the require statement, and considers _again as the tail.

This is because we don't enforce the tail to be separate from the main component name by a slash.


By enforcing that slash to be part of the tail in the regexp and also making it optional and default to "" (because now it can't match an empty string anymore because of the slash), we fix this problem and the test passes.

timaschew commented 10 years ago

regexps with .* are dangerous sometimes ;)

good catch, thanks!

timaschew commented 10 years ago

just realized that you need the extension, in component 0.19 it also works without the file extension. So currently it's still a breaking change.