Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Deterministic build order #284

Closed
srolel opened this issue Aug 21, 2015 · 10 comments
Closed

Deterministic build order #284

srolel opened this issue Aug 21, 2015 · 10 comments

Comments

@srolel
Copy link
Contributor

srolel commented Aug 21, 2015

The bundled output's internal package order seems to be random. I'm using a hash for versioning that means it changes every time, so I always cache-bust when I upload, regardless of actual changes.

@guybedford
Copy link
Member

Good point, we should make the order well-defined based on the dependency structure.

@guybedford guybedford changed the title Bundled packages order Deterministic build order Aug 21, 2015
@guybedford
Copy link
Member

Fixed by @Munter in #309.

@guybedford
Copy link
Member

Released in 0.14.0.

@carlosagsmendes
Copy link

@Munter and @guybedford I'm facing some issues when hashing due to inconsistencies in the modules order.

In the Trace.getTreeModulesPostOrder I get the following order:

Order in getTreeModulesPostOrder

In the builder.bundle I get the following order in the output.modules:

Order in builderBundle

I'm using the in-memory process:

builder.bundle('myModule.js', { minify: true }).then(function(output) {
  output.source;    // generated bundle source
  output.sourceMap; // generated bundle source map
  output.modules;   // array of module names defined in the bundle
});

And in the builder.bundle I get the following order in the output.source:

editors/single-file-upload/single-file-upload-template.html!github:systemjs/plugin-text@0.0.2
github:blueimp/jQuery-File-Upload@9.11.2/jquery.fileupload
github:blueimp/jQuery-File-Upload@9.11.2
github:blueimp/jQuery-File-Upload@9.11.2/jquery.fileupload-process
github:blueimp/jQuery-File-Upload@9.11.2/jquery.fileupload-validate
github:blueimp/jQuery-File-Upload@9.11.2/jquery.iframe-transport
editors/single-file-upload/single-file-upload-bootstrapper
editors/single-file-upload/single-file-upload-viewmodel
infrastructure/jquery-file-upload-custom

The order is always different.

Shouldn't it always be the same?

Thanks

@Munter
Copy link
Contributor

Munter commented Oct 7, 2015

Hmm. There was a big refactoring with breaking changes which happened just around the time where the post order traversal was merged in. Maybe we missed a call to get the order somewhere

@guybedford
Copy link
Member

@carlosagsmendes thanks for posting! This was an oversight in the promises chains, fixed in c8c947e.

@carlosagsmendes
Copy link

Thanks @guybedford I've just tested it with the 0.14.9 version and I'm still getting different results with multiple runs.

output.modules order (when building in memory) is still not consistent:

Run1:

Run1

Run2:

Run2

Items 3 and 4 order changed.

Here's how they are being imported:

import 'jquery-file-upload';
import 'jquery-ui/ui/widget';
import 'jquery-file-upload/jquery.fileupload-process';
import 'jquery-file-upload/jquery.fileupload-validate';
// This is only for IE9
import 'jquery-file-upload/jquery.iframe-transport';

@guybedford
Copy link
Member

@carlosagsmendes when you say the last export is only for IE9 are you setting that via metadata.deps perhaps? I'm just wondering where the non-determinism is creeping in.

@carlosagsmendes
Copy link

Hi, no, this is just a simple comment so we can remember why we're doing this import.

Here's a copy of my package.json. Could it be something related with dependencies?

https://gist.github.com/carlosagsmendes/eaa44a2e262e07a98f92#file-package-json-L153

@guybedford
Copy link
Member

@carlosagsmendes output.modules is not actually deterministic, while the build itself should be. Are you definitely seeing the output source file as non-deterministic here as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants