Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you publish a sample of what gulp-angular-filesort actually does and for what cases it is necessary to use it? #45

Closed
zhekaus opened this issue Mar 12, 2016 · 2 comments

Comments

@zhekaus
Copy link

zhekaus commented Mar 12, 2016

The thing is I can’t see any issues with AnglarJS caused by source files order.
I realized it when I saw that gulp-angular-filesort doesn’t actually sort files in a way I thought.

I’ve thought that gulp-angular-filesort looks at angular.module statements and sort files according to specified dependency in the brackets. It looks like I was wrong, ‘cause it doesn’t.

@joakimbeng
Copy link
Member

When this plugin was released it was common for an AngularJS project to define a module in one file and reuse it in another, i.e:

// module.js:
angular.module('module', ['dep1', 'dep2']);

// module-controller.js
angular.module('module').controller('ModuleController', ...);

If one were to include the two files in the wrong order like this:

<script src="module-controller.js"></script>
<script src="module.js"></script>

Your application would crash. That's what this module is supposed to fix (and have done as far as I know) by reordering them to be:

<script src="module.js"></script>
<script src="module-controller.js"></script>

But if each and every file defines their own modules there is no need for this plugin! Because then a module won't be used before it's been declared.

I am also quite certain that AngularJS was more picky when it came to module load order back in the day, but think it's solved now. So there may be more reasons to not use this plugin today than when it was first released. (I wouldn't know actually because I haven't used AngularJS in quite a while)


Side note: IMO this plugin shouldn't be used at all, use something like Browserify or Webpack instead!

This was referenced Mar 23, 2016
@zhekaus
Copy link
Author

zhekaus commented Mar 24, 2016

Thanks so much! I've got it.

@zhekaus zhekaus closed this as completed Mar 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants