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

Inconsistent build across machines when building a production bundle using aurelia cli #424

Closed
ghost opened this issue Nov 29, 2016 · 9 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 29, 2016

I'm submitting a bug report

  • Library Version:
    0.22 (cli)

Please tell us about your environment:

  • Operating System:
    Debian Linux, kernel 4.8.7

  • Node Version:
    6.9.1

  • NPM Version:
    3.10.8

  • Browser:
    Tested on Chrome & Firefox

  • Language:
    TypeScript 2.0.10

Current behavior:
I'm trying to setup a jenkins job to automate builds of our aurelia app. When I build the app locally it works 100%, but when I build it on jenkins using the same process, then the files in the script directory is different.

Expected/desired behavior:
The build on my local machine and the Jenkins machine should be consistent

  • What is the expected behavior?
    The build on my local machine and the Jenkins machine should be consistent

  • What is the motivation / use case for changing the behavior?
    Build should be consistent across machines

The following procedure is used to build the build (locally as well as on jenkins):

npm install aurelia-cli
npm install
typings install
au build --env prod

The following error is shown in the browser:

http://localhost/src/main.js Failed to load resource: the server responded with a status of 404 (Not Found)
vendor-bundle.js:2 Error: Script error for "main"(…)r @ vendor-bundle.js:2

The Jenkins environment is running docker containers with the tools installed. Both local and Jenkins machine have exactly the same versions of node, npm and aurelia.

@ghost
Copy link
Author

ghost commented Nov 29, 2016

I built a build with a "dev" environment. This is the error I get from Firefox:

Error: Script error for "main" http://requirejs.org/docs/errors.html#scripterror Stack trace: makeError@http://abc/scripts/vendor-bundle.js:2:26661 newContext/w.onScriptError@http://abc/scripts/vendor-bundle.js:3:6805 vendor-bundle.js:2:21002 r()vendor-bundle.js:2 [15]</t.exports/i.prototype._settlePromiseFromHandler()vendor-bundle.js:2 [15]</t.exports/i.prototype._settlePromise()vendor-bundle.js:2 [15]</t.exports/i.prototype._settlePromise0()vendor-bundle.js:2 [15]</t.exports/i.prototype._settlePromises()vendor-bundle.js:2 [1]</r.prototype._drainQueue()vendor-bundle.js:1 [1]</r.prototype._drainQueues()vendor-bundle.js:1 r/this.drainQueues()vendor-bundle.js:1

@AStoker
Copy link
Contributor

AStoker commented Nov 29, 2016

Might be related to this (#378), not sure. #378 is a problem because the hashes change, and the hashes only change because the source has changed. So if the problem here truly is that the vendor bundle source has changed, then these are related. However, I'd imagine that the order that the vendor bundle has shouldn't be as big a problem, as long as all those modules are in there.
Your particular "dev" build error just says that there's a script error for main, and it's being reported from the vendor bundle since that's where requirejs lives ( the thing that's reporting the error). I'd look at specifically is breaking inside your main file.
If it's not working on the external environment, I'd venture to guess that you have some sources that aren't being published, and that's why it works locally.
So, if you could identify specifically what is breaking in side main, then we can move forward from there :)

@mijdavis2
Copy link

Seeing similar issue. au build results in a different vendor-bundle.js on OSX vs Linux even when package versions are hard set. On Linux it is pretty consistent but sometimes an entire module doesn't seem to get loaded. On OSX this can happen AND I get a specific error on anchorIsContainer:

Looks like on Linux I get the follow which works:

if (ins.shadowSlot || ins.lifting) {
        content.insertBefore(_aureliaPal.DOM.createComment('view'), firstChild);
}

But on OSX:

if (ins.shadowSlot || ins.lifting || ins.elementInstruction !== null && !ins.elementInstruction.anchorIsContainer) {
        content.insertBefore(_aureliaPal.DOM.createComment('view'), firstChild);
}

^which results in Unhandled rejection TypeError: Cannot read property 'anchorIsContainer' of undefined. Replacing that line in the vendor-bundle with what I get on linux fixes the issue but it happens every build. I get the same error when building prod but it's not as easy to find and fix.

@AStoker
Copy link
Contributor

AStoker commented Dec 5, 2016

@mijdavis2, that seems like your two projects are getting different files completely. One of the issues that currently appears with the vendor bundle is the ordering of files change, but the files themselves haven't been changing. Could be that maybe some babel config is different and compiling things differently. But more likely (I think) is that the modules that are being downloaded aren't the same across your system. If you're using NPM, it uses cache versions first, before downloading a different version. So if your Mac has a cached version that's within the scope of your options in the package file, it'll use that, while if your Linux box has a newer/different cached version, NPM will use that. So you can have an identical package file, but have different machine specific files downloaded.

One of the things you can try to do to remedy this is clearing your npm cache on both your projects (npm cache clean), removing your node_modules folder on both projects, and then run npm install on both. That should ensure that you have the same files.

Another approach is the one that we use in the office now, which is using Yarn. It has a lock file (similar to NPM Shrink-wrap) that makes sure that the versions across machines are going to be the same. I'd look into that.

@alpox
Copy link
Contributor

alpox commented Jan 2, 2017

My guess is that this is fixed with #427.
@johangwbasson could you try it with a fresh clone of master?

@mijdavis2
Copy link

Fresh clone from master worked for me.

@AStoker
Copy link
Contributor

AStoker commented Feb 15, 2017

Is this still an issue for you @johangwbasson ?

@ghost
Copy link
Author

ghost commented Feb 16, 2017

We have resolved it by writing our own gulp file.

Thank you

@AStoker
Copy link
Contributor

AStoker commented Feb 16, 2017

Are you able to determine if the original issue is still a problem for you @johangwbasson (I know you solved it a different way, just wanting to know if the standard way of building is working now)? If not, I think we might be okay to close this.

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

No branches or pull requests

4 participants