Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(cb-barrels): Add barrels cookbook recipe #1419

Closed
wants to merge 42 commits into from

Conversation

jmcooper
Copy link

Add the cookbook recipe demonstrating how to create barrels to simplify module imports.

@Foxandxss
Copy link
Member

Foxandxss commented May 17, 2016

I like it, but I would make it follow the style-guide. That means having /heroes/heroes.component.ts|html|css, /heroes/hero-detail/hero-detail.component.ts|html|css. Service renamed as hero.service.ts, model renamed to hero.model.ts and both put into a shared folder. That way you will have more barrels too so the cookbook would be more interesting.

Leaving that aside, I have no problem with the prose :)

EDIT: Service is having the right name, you just mistyped it.
EDIT 2: You can use a .filetree to represent... you file tree.

@Foxandxss
Copy link
Member

Oh, final call here is from @wardbell :)

@jim-cooper
Copy link

I like your suggestions @Foxandxss. I'll make those changes.

@jim-cooper
Copy link

There is one problem I just realized. Adding the SystemJs package in the index.html works great for running the example, locally, but it doesn't work on plunker. Unfortunately, the main needs to be index.js locally, but index.ts (notice the js vs the ts) on plunker. Not sure the best way to solve that. Seems like something the plunker builder would have to handle.

@Foxandxss
Copy link
Member

I see what you mean. I will give it a thought.

@jim-cooper
Copy link

@Foxandxss I've made the edits you recommended and I think it's much better now, thanks for the suggestions. Let me know if you have any thoughts on the plunker issue.

.file shared
.children
.file hero.service.ts
.file hero.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo.

@Foxandxss
Copy link
Member

The hero-list is also a barrel, so it needs to export too :)

@Foxandxss
Copy link
Member

Could you also please fix the indentation? You are mixing spaces with tabs. We use 2 spaces.

Be more DRY when referencing examples and excerpts. E.g.,
```jade
+makeExcerpt('quickstart/ts/app/app.component.ts', 'import',
'app/app.component.ts (import)')
```
can now be just
```jade
+makeExcerpt('app/app.component.ts', 'import')
```
Defined new mixin for examples named `makeProjExample` using this new
scheme.
The original `makeExample` has been left untouched.

Applied new mixins to quickstart.

closes angular#1420
@jmcooper
Copy link
Author

Not sure what you mean by the hero-list component. If you mean the heros.component, it is being exported in the barrel. Can you clarify? :)

Also copy edited the TS version a bit.
@Foxandxss
Copy link
Member

If we see the style-guide, each folder is a barrel. That means that app/heroes exports a barrel, app/heroes/hero-detail/ exports a barrel, app/heroes/shared another barrel, etc.

@jmcooper
Copy link
Author

Ahh, I see what you're saying. You said hero-list is a barrel, I think you meant hero-detail. But I wasn't under the impression from the "whys" listed in the style guide that we were suggesting creating barrels for a single import, but rather to aggregate multiple imports. hero-detail is being aggregated at a higher level with the other imports, should we really create an index file for a single import?

@Foxandxss
Copy link
Member

We are promoting that on the style guide, but I will double check first.

@Foxandxss
Copy link
Member

After a conversation, yes, we add that even if it is one export.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

1 similar comment
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@jmcooper
Copy link
Author

Ok, I've added the barrel for hero-detail and made the other changes.

However, it looks like the Plunker change isn't quite right. It appears to be only updating the first package in the list from .js to .ts and leaving the others. Once that's fixed I'll rebase again to grab it.

Btw, sorry for the "Merge branch..." commit, accidentally did a pull instead of a rebase on that last one.

@jmcooper
Copy link
Author

Also, not sure why the CLA changed to no. It's because of the commits from other authors that I pulled in. Was I not supposed to rebase those changes into my branch?

@0x-r4bbit
Copy link
Contributor

@jmcooper you've pushed commits from other ppl.

You should rebase your changes so that they don't appear here.

@wardbell
Copy link
Contributor

wardbell commented May 20, 2016

Jim ... I'll look soon. No you're not supposed to merge which is why it looks like you changed 177 files. You don't want to submit a PR with 42 commits either.

But we understand. Git is PITA. We'll get you straightened out.

@wardbell
Copy link
Contributor

Closing because (a) it's in Jim's fork and I can't help, (b) it's a tangle of unrelated commits, and (c) I think I was able to straighten this out in an IdeaBlade fork of angular.io.

I believe the proper contents are in PR #1458

@wardbell wardbell closed this May 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.