Repository navigation
Modularize javascript - #590
HelgeKrueger wants to merge 5 commits into
Conversation
To use npm to build main.js use: - npm install to download required packages - npm run bundle to create main.js
4de2fc0 to
5edebca
Compare
|
Thanks again :) ! Do we still provide an out of the box compiled main.js? Or do you think that this is a good solution? |
|
My last commit looks odd. It was meant to include the precompiled minified main.js. This should be fixed now. |
npm run bundleUgly it is 600kB compared to 1.2 MB from npm run bundle
5edebca to
fe678a5
Compare
JsHint can be run with npm run jshint Including automatic running of jshint and jasmine test in .travis.yml
3ca208d to
af70db7
Compare
|
I added the jasmine test to travis-ci and added jshint, which is style checker for JavaScript. I also added various missing semicolons, that jshint found. I also pressed the close and comment button by accident. |
There was a problem hiding this comment.
Hmmh, as the web jar is also built in the core/files we should either avoid a separate web/files script or put the web jar building into the web/files I fear :)
|
Thanks again for this work and also for making the tests working even on travis :) ! Is npm installed per default there? Is leaflet.loading.js removed? See the functionality: https://github.com/ebrelsford/Leaflet.loading |
|
npm is installed by default on travis-ci. |
There was a problem hiding this comment.
Leaflet loading inclusion part 1.
|
Thanks! I'm still struggeling to understand how I would enable 'debug mode'. It is still possible to change something in the source code and hit F5 without a build command in-between? And also I've added a bit installation instructions in your initial comment of this PR ... would you mind to explain the different bundle commands (see TODO)? |
|
It looks like watchify is the solution (?) npm install -g watchify
watchify src/main/webapp/js/main-template.js -o src/main/webapp/js/main.jsWill add a new script - do we need to include watchify in package.json too? "watch": "watchify src/main/webapp/js/main-template.js -o src/main/webapp/js/main.js --debug --verbose",BTW: There are million of other ways but watchify is good IMO. Also should we rename |
|
Merged it here 38e1c32 One open question for me: "Also should we rename main.js to bundle.js and main-template.js to index.js or main.js to be more align with the normal namings for npm projects?" |
This pull request splits the main.js file into several node modules and uses browserify to recreate main.js. With node.js installed main.js can be created using
npm run bundleinside thewebfolder.See discussion at https://discuss.graphhopper.com/t/modularize-javascript-code/306/16
Installation:
If you wanted to add the underscore library to the project, then you would use
npm install --save underscorecommand. This command automatically modifies package.json to include underscore and a version info. This means that the next person running nvm install would also download underscore.