jvandemo/generator-angularjs-library

Could you add documentation on the files generated

ceoaliongroo opened this issue · 5 comments

Hi,

Great work with your repo, i like the idea to use yours instead others because the organization of the code. But it's kind of confusing

Could you explain with you copy this file in the generator?

| |---- yourLibraryName.prefix
| |---- yourLibraryName.suffix

Thanks

Hi Carlos,

Thank you for your kind words.

The .prefix and .suffix files are generated to wrap the concatenated source files in the build process.

Here's what happens during concatenation:

.prefix file is added:

(function(window, document) {

then all library files are added:

// All the code your wrote

and finally .suffix file is added:

})(window, document);

Resulting in a distribution file that looks like this:

(function(window, document) {

    // All the code your wrote

})(window, document);

This allows us to wrap the complete library in an anonymous function so the library has no impact on the global namespace.

I will add this to the documentation as well.

Hope that helps!

Jurgen

Why is document passed in?

window and document have been removed in v2.

Would these two wrapper files be a good place to transform the generated library into an AMD module?

@rony76, the wrapper files will no longer be necessary in future releases so I wouldn't recommend using them.

The new AngularJS styleguide makes them obsolete so they will disappear in the next major release. Thanks!