Closed jonathanong closed 10 years ago
Just wanted to comment on this, I think these should be allowed to be different after trying to build a full-fledged application with component.
Say I have a directory structure:
- views/
- app/
- index/
- users/
- index/
If I wanted to give each "action" a separate component.json
, I would have naming clashes since I'd have more than one index
component. This is not really a problem until you introduce anything beyond scripts/styles. (images/fonts/etc) Then, the builder drops all the assets from each component named index
into the same directory.
I was hoping that by giving my "action" components prefixes in their name
field, (ie. "app-index" and "users-index" respectively) I could work around this, but that's not the case. The only workaround at this point is to define all this at the controller level, which is fine but could be better.
Perhaps this is just a corner-case, but I think there could be other legitimate use-cases for allowing the "name" to differ from the directory name, and this decision could be reconsidered.
Yeah I agree, but I don't think making component names different than their containing folder's is a solution - that would just make things confusing. We need to make local components unique regardless of their name. This is more of a builder issue than a spec issue though. Not sure how to solve it yet without going full retard with custom aliases (which isn't that bad, just more work and confusion).
i'm also thinking of implementing locals
for public components. this way, you can have your model
or whatever in a completely different repo, but still have it modular and versioned. all of its paths and locals will be "private" and not shared with the rest of the app.
this is pretty future though since i don't really see an easy way of implementing this unless we end up just downloading entire repositories.
i was thinking about how to rename locals so that there won't be any conflicts. how about path.relative(process.cwd(), basename).replace(/^(\.\.\/)*/, '').
where basename is the folder the local component is located in? we replace all the leading ../
and the windows-equivalent. the full names of local components will start with /
to differentiate them against dependencies.
ex. lib/boot
will be require('/lib/boot')
and lib/boot/image.png
will be copied/symlinked as build/lib/boot/image.png
.
if we do this or any non-trivial naming of local components, i think auto-requiring the "boot" component should be default.
we should also make this optional, though. only necessary if you use multiple paths.
i.e.
locals/app/component.json
must have"name": "app"
. i think this is obvious, just not in the spec.