Ajax: remove event dependency from the ajax module
[jquery.git] / Gruntfile.js
blobd332c00f1e45326bbfeb2d4012996633d278b9f4
1 module.exports = function( grunt ) {
2         "use strict";
4         function readOptionalJSON( filepath ) {
5                 var data = {};
6                 try {
7                         data = grunt.file.readJSON( filepath );
8                 } catch ( e ) {}
9                 return data;
10         }
12         var gzip = require( "gzip-js" ),
13                 srcHintOptions = readOptionalJSON( "src/.jshintrc" );
15         // The concatenated file won't pass onevar
16         // But our modules can
17         delete srcHintOptions.onevar;
19         grunt.initConfig({
20                 pkg: grunt.file.readJSON( "package.json" ),
21                 dst: readOptionalJSON( "dist/.destination.json" ),
22                 "compare_size": {
23                         files: [ "dist/jquery.js", "dist/jquery.min.js" ],
24                         options: {
25                                 compress: {
26                                         gz: function( contents ) {
27                                                 return gzip.zip( contents, {} ).length;
28                                         }
29                                 },
30                                 cache: "build/.sizecache.json"
31                         }
32                 },
33                 build: {
34                         all: {
35                                 dest: "dist/jquery.js",
36                                 minimum: [
37                                         "core",
38                                         "selector"
39                                 ],
40                                 // Exclude specified modules if the module matching the key is removed
41                                 removeWith: {
42                                         ajax: [ "manipulation/_evalUrl", "event/ajax" ],
43                                         callbacks: [ "deferred" ],
44                                         css: [ "effects", "dimensions", "offset" ],
45                                         sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
46                                 }
47                         }
48                 },
49                 npmcopy: {
50                         all: {
51                                 options: {
52                                         destPrefix: "external"
53                                 },
54                                 files: {
55                                         "sizzle/dist": "sizzle/dist",
56                                         "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
58                                         "qunit/qunit.js": "qunitjs/qunit/qunit.js",
59                                         "qunit/qunit.css": "qunitjs/qunit/qunit.css",
60                                         "qunit/MIT-LICENSE.txt": "qunitjs/MIT-LICENSE.txt",
62                                         "requirejs/require.js": "requirejs/require.js",
64                                         "sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
65                                         "sinon/LICENSE.txt": "sinon/LICENSE"
66                                 }
67                         }
68                 },
69                 jsonlint: {
70                         pkg: {
71                                 src: [ "package.json" ]
72                         },
74                         bower: {
75                                 src: [ "bower.json" ]
76                         }
77                 },
78                 jshint: {
79                         all: {
80                                 src: [
81                                         "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
82                                 ],
83                                 options: {
84                                         jshintrc: true
85                                 }
86                         },
87                         dist: {
88                                 src: "dist/jquery.js",
89                                 options: srcHintOptions
90                         }
91                 },
92                 jscs: {
93                         src: "src/**/*.js",
94                         gruntfile: "Gruntfile.js",
96                         // Right now, check only test helpers
97                         test: [ "test/data/testrunner.js" ],
98                         release: [ "build/*.js", "!build/release-notes.js" ],
99                         tasks: "build/tasks/*.js"
100                 },
101                 testswarm: {
102                         tests: [
103                                 "ajax",
104                                 "attributes",
105                                 "callbacks",
106                                 "core",
107                                 "css",
108                                 "data",
109                                 "deferred",
110                                 "dimensions",
111                                 "effects",
112                                 "event",
113                                 "manipulation",
114                                 "offset",
115                                 "queue",
116                                 "selector",
117                                 "serialize",
118                                 "support",
119                                 "traversing"
120                         ]
121                 },
122                 watch: {
123                         files: [ "<%= jshint.all.src %>" ],
124                         tasks: "dev"
125                 },
126                 uglify: {
127                         all: {
128                                 files: {
129                                         "dist/jquery.min.js": [ "dist/jquery.js" ]
130                                 },
131                                 options: {
132                                         preserveComments: false,
133                                         sourceMap: true,
134                                         sourceMapName: "dist/jquery.min.map",
135                                         report: "min",
136                                         beautify: {
137                                                 "ascii_only": true
138                                         },
139                                         banner: "/*! jQuery v<%= pkg.version %> | " +
140                                                 "(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
141                                                 "jquery.org/license */",
142                                         compress: {
143                                                 "hoist_funs": false,
144                                                 loops: false,
145                                                 unused: false
146                                         }
147                                 }
148                         }
149                 }
150         });
152         // Load grunt tasks from NPM packages
153         require( "load-grunt-tasks" )( grunt );
155         // Integrate jQuery specific tasks
156         grunt.loadTasks( "build/tasks" );
158         grunt.registerTask( "lint", [ "jshint", "jscs" ] );
160         // Short list as a high frequency watch task
161         grunt.registerTask( "dev", [ "build:*:*", "lint" ] );
163         // Default grunt
164         grunt.registerTask( "default", [ "jsonlint", "dev", "uglify", "dist:*", "compare_size" ] );