Merge pull request #127 from juliandescottes/closurecompiler

Basic wiring of Closure compiler
This commit is contained in:
Julian Descottes 2013-09-28 14:32:59 -07:00
commit 80b336aab5
21 changed files with 103 additions and 25 deletions

5
.gitignore vendored
View File

@ -13,4 +13,7 @@ npm-debug.log
*.stackdump *.stackdump
# builds # builds
build build
# Closure compiler generated JS binary.
closure_compiled_binary.js

View File

@ -11,7 +11,6 @@
*/ */
module.exports = function(grunt) { module.exports = function(grunt) {
var piskelScripts = require('./piskel-script-list.js').scripts; var piskelScripts = require('./piskel-script-list.js').scripts;
var getGhostConfig = function (delay) { var getGhostConfig = function (delay) {
return { return {
@ -84,6 +83,61 @@ module.exports = function(grunt) {
'build/piskel-packaged-min.js' : ['build/piskel-packaged.js'] 'build/piskel-packaged-min.js' : ['build/piskel-packaged.js']
} }
} }
},
closureCompiler: {
options: {
// [REQUIRED] Path to closure compiler
compilerFile: 'closure_compiler_20130823.jar',
// [OPTIONAL] set to true if you want to check if files were modified
// before starting compilation (can save some time in large sourcebases)
//checkModified: true,
// [OPTIONAL] Set Closure Compiler Directives here
compilerOpts: {
/**
* Keys will be used as directives for the compiler
* values can be strings or arrays.
* If no value is required use null
*/
//compilation_level: 'ADVANCED_OPTIMIZATIONS',
compilation_level: 'SIMPLE_OPTIMIZATIONS',
externs: ['piskel-closure-externs.js'],
// Inject some constants in JS code, could we use that for appengine wiring ?
//define: ["'goog.DEBUG=false'"],
warning_level: 'verbose',
jscomp_off: ['checkTypes', 'fileoverviewTags'],
summary_detail_level: 1,
language_in: 'ECMASCRIPT3'
//output_wrapper: '"(function(){%output%}).call(this);"'
},
execOpts: { // [OPTIONAL] Set exec method options
maxBuffer: 999999 * 1024
}
},
compile: {
/**
*[OPTIONAL] Here you can add new or override previous option of the Closure Compiler Directives.
* IMPORTANT! The feature is enabled as a temporary solution to [#738](https://github.com/gruntjs/grunt/issues/738).
* As soon as issue will be fixed this feature will be removed.
*/
TEMPcompilerOpts: {
},
src: [
'js/**/*.js',
//'!js/lib/**/*.js',
'!js/lib/bootstrap/**/*.js',
'!js/lib/jsColor_1_4_0/**/*.js',
'!js/lib/gif/**/*.js',
'piskel-boot.js',
'piskel-script-list.js'
],
// This generated JS binary is currently not used and even excluded from source control using .gitignore.
dest: 'closure_compiled_binary.js'
}
} }
}); });
@ -99,6 +153,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-closure-tools');
grunt.loadNpmTasks('grunt-ghost'); grunt.loadNpmTasks('grunt-ghost');
grunt.loadNpmTasks('grunt-leading-indent'); grunt.loadNpmTasks('grunt-leading-indent');
@ -106,15 +161,17 @@ module.exports = function(grunt) {
grunt.registerTask('lint', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint']); grunt.registerTask('lint', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint']);
// Validate & Test // Validate & Test
grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'connect:test', 'ghost:default']); grunt.registerTask('test', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:default']);
// Validate & Test (faster version) will NOT work on travis !! // Validate & Test (faster version) will NOT work on travis !!
grunt.registerTask('precommit', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'connect:test', 'ghost:local']); grunt.registerTask('precommit', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'compile', 'connect:test', 'ghost:local']);
// Compile JS code (eg verify JSDoc annotation and types, no actual minified code generated).
grunt.registerTask('compile', ['closureCompiler:compile']);
// Validate & Build // Validate & Build
grunt.registerTask('default', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'concat', 'uglify']); grunt.registerTask('default', ['leadingIndent:jsFiles', 'leadingIndent:cssFiles', 'jshint', 'concat', 'compile', 'uglify']);
// Start webserver // Start webserver
grunt.registerTask('serve', ['connect:serve']); grunt.registerTask('serve', ['connect:serve']);
}; };

Binary file not shown.

View File

@ -1,5 +1,5 @@
// TODO(grosbouddha): put under pskl namespace. // TODO(grosbouddha): put under pskl namespace.
Events = { var Events = {
TOOL_SELECTED : "TOOL_SELECTED", TOOL_SELECTED : "TOOL_SELECTED",
TOOL_RELEASED : "TOOL_RELEASED", TOOL_RELEASED : "TOOL_RELEASED",

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.BaseTool * @provide pskl.drawingtools.BaseTool
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.Circle * @provide pskl.drawingtools.Circle
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.ColorPicker * @provide pskl.drawingtools.ColorPicker
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.Eraser * @provide pskl.drawingtools.Eraser
* *
* @require Constants * @require Constants

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.Move * @provide pskl.drawingtools.Move
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.PaintBucket * @provide pskl.drawingtools.PaintBucket
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.Rectangle * @provide pskl.drawingtools.Rectangle
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.SimplePen * @provide pskl.drawingtools.SimplePen
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.Stroke * @provide pskl.drawingtools.Stroke
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.BaseSelect * @provide pskl.drawingtools.BaseSelect
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.RectangleSelect * @provide pskl.drawingtools.RectangleSelect
* *
* @require pskl.utils * @require pskl.utils

View File

@ -1,4 +1,4 @@
/* /**
* @provide pskl.drawingtools.ShapeSelect * @provide pskl.drawingtools.ShapeSelect
* *
* @require pskl.utils * @require pskl.utils

View File

@ -44,7 +44,7 @@
x0 : Math.min(x0, x1), x0 : Math.min(x0, x1),
y0 : Math.min(y0, y1), y0 : Math.min(y0, y1),
x1 : Math.max(x0, x1), x1 : Math.max(x0, x1),
y1 : Math.max(y0, y1), y1 : Math.max(y0, y1)
}; };
}, },
@ -172,6 +172,6 @@
widthBoundDpi = Math.floor(width / pictureWidth); widthBoundDpi = Math.floor(width / pictureWidth);
return Math.min(heightBoundDpi, widthBoundDpi); return Math.min(heightBoundDpi, widthBoundDpi);
}, }
}; };
})(); })();

View File

@ -24,7 +24,7 @@ if (typeof Function.prototype.bind !== "function") {
}; };
} }
/* /**
* @provide pskl.utils * @provide pskl.utils
* *
* @require Constants * @require Constants

View File

@ -18,6 +18,7 @@
"grunt-contrib-jshint": "0.5.4", "grunt-contrib-jshint": "0.5.4",
"grunt-contrib-uglify": "0.2.2", "grunt-contrib-uglify": "0.2.2",
"grunt-ghost": "1.0.12", "grunt-ghost": "1.0.12",
"grunt-leading-indent" : "0.1.0" "grunt-leading-indent": "0.1.0",
"grunt-closure-tools": "~0.8.3"
} }
} }

View File

@ -11,14 +11,14 @@
window.exports = {}; window.exports = {};
var scriptIndex = 0; var scriptIndex = 0;
window.loadNextScript = function () { window.loadNextScript = function () {
if (scriptIndex == exports.scripts.length) { if (scriptIndex == window.exports.scripts.length) {
pskl.app.init(); pskl.app.init();
// cleanup // cleanup
delete window.exports; delete window.exports;
delete window.loadDebugScripts; delete window.loadDebugScripts;
delete window.done; delete window.done;
} else { } else {
loadScript(exports.scripts[scriptIndex], "loadNextScript()"); loadScript(window.exports.scripts[scriptIndex], "loadNextScript()");
scriptIndex ++; scriptIndex ++;
} }
}; };

17
piskel-closure-externs.js Normal file
View File

@ -0,0 +1,17 @@
/**
* @fileoverview Externs for Piskel
*
* @externs
*/
// Piskel externs.
var exports;
var $;
var console;
var pskl;
// Piskel libs externs.
var define;
var jQuery;
var getComputedStyle;
var URL;