Skip to content

Hilary grunt#2517

Closed
stuartf wants to merge 40 commits into
oaeproject:Hilaryfrom
stuartf:hilary-grunt
Closed

Hilary grunt#2517
stuartf wants to merge 40 commits into
oaeproject:Hilaryfrom
stuartf:hilary-grunt

Conversation

@stuartf

@stuartf stuartf commented Dec 12, 2012

Copy link
Copy Markdown
Contributor

production build in grunt

Comment thread grunt.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is for institutions to be able to add their own widgets next to oae-core, e.g. oae-gt. These widgets should be included in the production build as well.

@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

I just tried this, and during the build I got the following error:

/Users/nicolaas/Desktop/SakaiOAE/ui/newOAE/3akai-ux/target/optimized/ui/css/oae.main.css
Cannot inline css import, skipping: /shared/vendor/css/auth-buttons.css
/Users/nicolaas/Desktop/SakaiOAE/ui/newOAE/3akai-ux/target/optimized/ui/css/oae.main.css
Cannot inline css import, skipping: /shared/vendor/css/jquery.gritter.css
/Users/nicolaas/Desktop/SakaiOAE/ui/newOAE/3akai-ux/target/optimized/ui/css/oae.main.css
Cannot inline css import, skipping: /shared/vendor/css/jquery.autoSuggest.css

Also, when trying to run this in the browser, the UI is not loading at all. First of all, it can't find any of the above CSS files, as they should have been inlined.

It also can't find the oae.bootstrap.js file, which it tries to locate at /shared/oae/api/ab72e9d3.oae.bootstrap.cachcd382602.e.caced0d91c5.he.cache.js but actually just is in /shared/oae/api/ab72e9d3.oae.bootstrap.cache.js.

It looks like all of the individual api.js files are still there, which I think will cause too many requests for an initial pageload. In the old UI, all API files were merged into oae.dependencies. We should try to do something similar.

@stuartf

stuartf commented Dec 12, 2012

Copy link
Copy Markdown
Contributor Author

all the individual api files are actually inlined into the [hash].oae.api.cache.js file, they remain in place so they can be referenced individually, but reading in oae.api won't result in additional calls. The old build left them in place as well. I'm looking into the filename mangling.

@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

I also just noticed that there is no node_modules folder in the optimized folder.

@stuartf

stuartf commented Dec 13, 2012

Copy link
Copy Markdown
Contributor Author

I think this fixes all the listed issues, you'll have to use the version of grunt-ver in my master though until chrisdanford/grunt-ver#2 is resolved

Comment thread .npmignore Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been removed

@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

stuartf: can we point our package.json to your grunt-ver repo until the referenced issue is resolved?

@stuartf

stuartf commented Dec 14, 2012

Copy link
Copy Markdown
Contributor Author

I've switched grunt-ver over to my repo in package.json and deleted the stray npmignore

@bertpareyn

Copy link
Copy Markdown
Contributor

Can you take a look at the conflict?

Nicolaas Matthijs added 2 commits December 15, 2012 17:54
@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

I fixed the merge conflict and pushed it to my hilary-grunt branch.

All of the files now seem properly hashed, but unfortunately this isn't working when tried in the browser. The first failure is in /shared/oae/api/oae.bootstrap.js, which still has ,require(["oae/api/oae.core.509094a8"] inside of it, causing a 404. It looks like most of the require statements have not been replaced by their hashed version.

Any chance you can have a look at this before Monday's demo?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very clever solution to an otherwise hairy problem. I haven't looked too deep into the mechanics here yet, but am wondering if it is possible to take the cultureMap a step further and have it store the full path+hash, keyed by the locale, rather than just the hash. So the consuming code wouldn't always need to construct it with the hash?

The result would be that this consumer code would rather be:

var bundlesToLoad = ['/ui/bundles/default.properties', cultureMap.bundles[locale]];

And the hash = '.' + cultureMap.bundles[locale]; code wouldn't need to exist here or in l10n.

This only makes sense if the hash isn't needed for other purposes than just constructing the URL to the culture bundle.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous build system had a better approach for this problem. It would just hash the bundles folder and replace the bundles path inside of the codebase. As these would generate unique paths for the bundles, there was no need for something like the cultureMap. My preference would be to try to avoid the culturemap if possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the code get the hash value of the bundle directory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to do an in-code string replacement of the unhashed path with the hashed path.

@mrvisser

mrvisser commented Feb 4, 2013

Copy link
Copy Markdown
Contributor

Sorry this hasn't had much review love over the past little while. Testing passes, just a few general comments I'd like addressed but otherwise looks good to merge. Good work @stuartf !

I imagine now that this tests out well, hashing would be next? Are there any known issues with the hashing procedure? Some initial testing shows that it doesn't work OOTB, but that isn't unexpected given we asked to have concat/minification working first.

@stuartf

stuartf commented Feb 5, 2013

Copy link
Copy Markdown
Contributor Author

Pushed fixes for the review issues, I've left the dynamic hash resolution as is for now, because it might have to change when we fix the other hashing issues.

@mrvisser

mrvisser commented Feb 7, 2013

Copy link
Copy Markdown
Contributor

Doing a git grep "oae/", there are still define statements that use the full path and not the alias of the module. The ones that look to me like they may need to be changed are:

node_modules/oae-core/changepic/javascript/changepic.js:define(['jquery', 'underscore', 'oae/api/oae.core', 'jquery-plugins/imgareaselect/jquery.imgareaselect'], function($, _, oae) {
shared/oae/api/oae.api.i18n.js:define(['exports', 'jquery', 'oae/api/oae.api.config', 'oae/api/oae.api.util', 'oae.culture-map', 'jquery.properties-parser'], function(exports, $, configAPI, utilAPI, cultu
shared/oae/api/oae.api.l10n.js:define(['exports', 'underscore', 'oae/api/oae.api.config', 'oae.culture-map', 'globalize'], function(exports, _, configAPI, cultureMap) {
shared/oae/api/oae.api.util.js:define(['exports', 'jquery', 'underscore', 'oae/api/oae.api.i18n', 'jquery.validate', 'vendor/js/trimpath'], function(exports, $, _, i18nAPI) {
shared/oae/api/oae.api.widget.js:define(['exports', 'jquery', 'underscore', 'oae/api/oae.api.config', 'oae/api/oae.api.i18n', 'oae/api/oae.api.util', 'jquery.ba-bbq'], function(exports, $, _, configAPI, i

Should these change?

@stuartf

stuartf commented Feb 8, 2013

Copy link
Copy Markdown
Contributor Author

Looking at the full paths vs aliases, if they're in oae.api they generally don't have to be changed, but I think they can be. The ones in changepic definitely need to be fixed, I'll get those fixed on Monday.

@mrvisser

Copy link
Copy Markdown
Contributor

@stuartf I've submit a PR to your PR which fixes an issue with timeouts. Looks like the aliases for oae.api.util and oae.api.i18n were not the right way to go, but rather define oae.api directly as you suggested.

@stuartf

stuartf commented Feb 11, 2013

Copy link
Copy Markdown
Contributor Author

@mrvisser I didn't take your patch unmodified, but the above should be equivalent.

@mrvisser

Copy link
Copy Markdown
Contributor

@stuartf There were some more issues in the setup when merged with activities. The source of the problem was that there was a cross-dependency between infinitescroll and oae.core, since they require eachother. This was introduced by 4acd48b .

I've submit a PR to yours again with the changes.

Conflicts:
	shared/vendor/js/jquery-plugins/jquery.infinitescroll-sakai.js
@stuartf

stuartf commented Feb 12, 2013

Copy link
Copy Markdown
Contributor Author

merged your commit

* Upgrading to require.js 2.1.4
* Fixing x-dependency issue in oae.api.util

Conflicts:
	shared/oae/api/oae.bootstrap.js
@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

I just tried this locally, and it doesn't look like I can get this to work. I get the following error:

ReferenceError: exports is not defined     ...refix:"if (",suffix:") {",paramMin:1},"else":{delta:0,prefix:"} else {"},elseif:...            oae.api.js (line 1)
Error: Load timeout for modules: oae.api!_unnormalized2 http://requirejs.org/docs/errors.html#timeout      ...is.depMaps.push(a),r.completeLoad(u),c([u],i)}),n.load(e.name,c,i,o)})),r.enable...           require.js (line 1)

However, I can see the output, and it doesn't quite reflect the way in which the old production build used to work. I see the following HTTP requests when opening the page:

http://cambridge.oae.com/
http://cambridge.oae.com/ui/css/oae.main.css
http://cambridge.oae.com/shared/vendor/js/require.js
http://cambridge.oae.com/shared/oae/api/oae.bootstrap.js
http://cambridge.oae.com/shared/oae/api/oae.core.js
http://cambridge.oae.com/shared/oae/api/oae.api.js
http://cambridge.oae.com/shared/vendor/js/jquery.js
http://cambridge.oae.com/shared/vendor/js/underscore.js
http://cambridge.oae.com/shared/vendor/js/jquery-ui.custom.js
http://cambridge.oae.com/shared/vendor/js/l10n/globalize.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jqmodal.sakai-edited.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.ba-bbq.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.ba-hashchange.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.contentchange.sakai-edited.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.equal-height-columns.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.fileSize.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.form.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.gritter.sakai-edit.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.infinitescroll-sakai.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.properties-parser.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.serializeObject.js
http://cambridge.oae.com/shared/vendor/js/jquery-plugins/jquery.validate.js
http://cambridge.oae.com/shared/oae/api/oae.culture-map.js

We can see that there is only 1 CSS file (2 if there would be a page CSS file), which is the expected optimal behaviour. However, in the old production build, all of the JS libraries and OAE apis would be condensed into a single file (oae.dependencies), which significantly cuts down the number of requests and improves performance.

I'm fine with 2 separate files, one for oae.core and one for all 3rd party libraries, but I don't think we should have all of the files loaded individually. Is there anything we're currently doing with Require.JS that's preventing the old production build behaviour?

@mrvisser

Copy link
Copy Markdown
Contributor

I discovered the "exports" issue while working on hashing locally, that was my bad as I cleaned things up for the PR.

I just finished up hashing locally, I'll look at doing this as well. Since hashing finished so quickly after the "define" functionality was fixed, I think I may just resubmit a PR with it all completed. Hopefully later today.

Comment thread nginx.conf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the README to reflect these changes?

@nicolaasmatthijs

Copy link
Copy Markdown
Contributor

Did a review as well.

@mrvisser

Copy link
Copy Markdown
Contributor

I've addressed @nicolaasmatthijs 's comments in a fork in my hilary-grunt branch. I will close this and submit a new PR with Stuart's work here plus hashing and review fixes.

@mrvisser mrvisser closed this Feb 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants