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

Dependencies order is not always the same given the same input #10

Closed
fabiospampinato opened this issue Sep 3, 2015 · 7 comments
Closed

Comments

@fabiospampinato
Copy link

Running the plugin multiple times gives different orders of files. I guess mainly because when 2 files have no dependencies the order doesn't really matter, but I think the result should be consistent, probably an initial alphanumeric sort of the files would be enough.

@backflip
Copy link
Owner

backflip commented Sep 7, 2015

Hey Fabio

This definitely shouldn't happen. Is this behavior gone if you remove the plugin? Do you already have a test case by any chance?

@fabiospampinato
Copy link
Author

What do you mean? If I remove the plugin of course it will not happen since I won't call it.

I have a test case, you can clone the repository I'm working on (that's where I found the problem) and run gulp clean && gulp js-temp. The problem is indeed in the js-temp task, what it does is:

  1. Sort all the js files (to solve this issue)
  2. Resolve the dependencies
  3. Prefix path's basenames with a number indicating the position in the dependencies list
  4. Basically writing the stream to a .temp directory

So that later when I call the js task it will:

  1. Sort the js files from the .temp directory, and since they are prefixed as explained previously they will be in the proper order
  2. Write the stream

As you probably guessed, removing the .pipe ( sort () ) call at the beginning of the js-temp task generates the problem (unless you are very lucky and they get outputted in the same order for 2 or more times in a row, I guess). Now if you run again the gulp js-temp you'll notice that there are multiple files with the same prefix in the .temp folder, hence the order has not been preserved.

@backflip
Copy link
Owner

backflip commented Sep 9, 2015

What do you mean? If I remove the plugin of course it will not happen since I won't call it.

Are you sure gulp.src reliably returns the same result every time it runs?

But anyway, I well check out your test case.

@fabiospampinato
Copy link
Author

Ah, I don't know, but if I have to guess I'd say that it's not, since that when sorting it your plugin's behaviour is consistent.

Anyway is something the plugin should deal with I think.

@backflip
Copy link
Owner

backflip commented Jan 3, 2019

@fabiospampinato, I'm very sorry about dropping the ball here. I decided to add a note to the README since this turned out to be an issue with gulp.src: #21

@backflip backflip closed this as completed Jan 3, 2019
@fabiospampinato
Copy link
Author

@backflip no problem, a while after I opened the issue I ended up making my own plugin for this.

@backflip
Copy link
Owner

backflip commented Jan 3, 2019

@fabiospampinato, yep, I discovered this while skimming through your impressive commit history to find the state from September 2015. :D

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