3 module.exports = function( grunt ) {
4 function readOptionalJSON( filepath ) {
5 var stripJSONComments = require( "strip-json-comments" ),
8 data = JSON.parse( stripJSONComments(
9 fs.readFileSync( filepath, { encoding: "utf8" } )
15 var fs = require( "fs" ),
16 gzip = require( "gzip-js" ),
17 isTravis = process.env.TRAVIS,
18 oldNode = /^v6\./.test( process.version );
20 // Support: Node.js <8
21 // Skip running tasks that dropped support for Node.js 6
22 // in those Node versions.
23 function runIfNewNode( task ) {
24 return oldNode ? "print_old_node_message:" + task : task;
27 if ( !grunt.option( "filename" ) ) {
28 grunt.option( "filename", "jquery.js" );
32 pkg: grunt.file.readJSON( "package.json" ),
33 dst: readOptionalJSON( "dist/.destination.json" ),
35 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
38 gz: function( contents ) {
39 return gzip.zip( contents, {} ).length;
42 cache: "build/.sizecache.json"
49 plugins: [ "@babel/transform-for-of" ]
53 "test/data/core/jquery-iterability-transpiled.js":
54 "test/data/core/jquery-iterability-transpiled-es6.js"
60 dest: "dist/jquery.js",
66 // Exclude specified modules if the module matching the key is removed
68 ajax: [ "manipulation/_evalUrl", "event/ajax" ],
69 callbacks: [ "deferred" ],
70 css: [ "effects", "dimensions", "offset" ],
71 "css/showHide": [ "effects" ],
73 remove: [ "ajax", "effects", "queue", "core/ready" ],
74 include: [ "core/ready-no-deferred" ]
76 sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
83 destPrefix: "external"
86 "sizzle/dist": "sizzle/dist",
87 "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
89 "npo/npo.js": "native-promise-only/lib/npo.src.js",
91 "qunit/qunit.js": "qunit/qunit/qunit.js",
92 "qunit/qunit.css": "qunit/qunit/qunit.css",
93 "qunit/LICENSE.txt": "qunit/LICENSE.txt",
95 "requirejs/require.js": "requirejs/require.js",
97 "sinon/sinon.js": "sinon/pkg/sinon.js",
98 "sinon/LICENSE.txt": "sinon/LICENSE"
104 src: [ "package.json" ]
110 // See https://github.com/sindresorhus/grunt-eslint/issues/119
114 // We have to explicitly declare "src" property otherwise "newer"
115 // task wouldn't work properly :/
117 src: "dist/jquery.js"
120 src: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
126 // A special module with basic tests, meant for
127 // not fully supported environments like Android 2.3,
128 // jsdom or PhantomJS. We run it everywhere, though,
129 // to make sure tests are not broken.
156 customContextFile: "test/karma.context.html",
157 customDebugFile: "test/karma.debug.html",
159 ChromeHeadlessNoSandbox: {
160 base: "ChromeHeadless",
161 flags: [ "--no-sandbox" ]
164 frameworks: [ "qunit" ],
165 middleware: [ "mockserver" ],
169 "middleware:mockserver": [
171 require( "./test/middleware-mockserver.js" )
176 "test/data/jquery-1.9.1.js",
177 "external/sinon/sinon.js",
178 "external/npo/npo.js",
179 "external/requirejs/require.js",
180 "test/data/testinit.js",
184 // Replacement for testinit.js#loadTests()
185 "test/data/testrunner.js",
186 "test/unit/basic.js",
188 "test/unit/callbacks.js",
189 "test/unit/deferred.js",
190 "test/unit/deprecated.js",
191 "test/unit/support.js",
193 "test/unit/queue.js",
194 "test/unit/attributes.js",
195 "test/unit/event.js",
196 "test/unit/selector.js",
197 "test/unit/traversing.js",
198 "test/unit/manipulation.js",
201 "test/unit/serialize.js",
203 "test/unit/effects.js",
204 "test/unit/offset.js",
205 "test/unit/dimensions.js",
206 "test/unit/animation.js",
207 "test/unit/tween.js",
208 "test/unit/ready.js",
210 { pattern: "dist/jquery.*", included: false, served: true },
211 { pattern: "src/**", included: false, served: true },
212 { pattern: "external/**", included: false, served: true },
214 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
219 reporters: [ "dots" ],
222 captureTimeout: 20 * 1000,
227 // The Chrome sandbox doesn't work on Travis.
228 browsers: [ isTravis ? "ChromeHeadlessNoSandbox" : "ChromeHeadless" ]
234 "test/data/jquery-1.9.1.js",
235 "test/data/testinit-jsdom.js",
237 // We don't support various loading methods like AMD,
238 // choosing a version etc. for jsdom.
241 // Replacement for testinit.js#loadTests()
242 "test/data/testrunner.js",
244 // jsdom only runs basic tests
245 "test/unit/basic.js",
247 { pattern: "external/**", included: false, served: true },
249 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
255 browsers: [ "jsdom" ]
258 // To debug tests with Karma:
259 // 1. Run 'grunt karma:chrome-debug' or 'grunt karma:firefox-debug'
260 // (any karma subtask that has singleRun=false)
261 // 2. Press "Debug" in the opened browser window to start
262 // the tests. Unlike the other karma tasks, the debug task will
263 // keep the browser window open.
265 browsers: [ "Chrome" ],
269 browsers: [ "Firefox" ],
278 files: [ "<%= eslint.dev.src %>" ],
284 "dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
285 "dist/<%= grunt.option('filename') %>"
288 preserveComments: false,
291 "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
296 // Support: Android 4.0 only
297 // UglifyJS 3 breaks Android 4.0 if this option is not enabled.
298 // This is in lieu of setting ie8 for all of mangle, compress, and output
301 banner: "/*! jQuery v<%= pkg.version %> | " +
302 "(c) JS Foundation and other contributors | jquery.org/license */",
308 // typeofs transformation is unsafe for IE9-10
309 // See https://github.com/mishoo/UglifyJS2/issues/2198
317 // Load grunt tasks from NPM packages
318 require( "load-grunt-tasks" )( grunt );
320 // Integrate jQuery specific tasks
321 grunt.loadTasks( "build/tasks" );
323 // Support: Node.js <8
324 // Print a message on Node.js <8 notifying the task is skipped there.
325 grunt.registerTask( "print_old_node_message", function() {
326 var task = [].slice.call( arguments ).join( ":" );
327 grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
330 grunt.registerTask( "lint", [
333 // Running the full eslint task without breaking it down to targets
334 // would run the dist target first which would point to errors in the built
335 // file, making it harder to fix them. We want to check the built file only
336 // if we already know the source files pass the linter.
341 grunt.registerTask( "lint:newer", [
344 // Don't replace it with just the task; see the above comment.
349 grunt.registerTask( "test:fast", "node_smoke_tests" );
350 grunt.registerTask( "test:slow", [
351 "promises_aplus_tests",
353 // Support: Node.js <8
354 // Karma no longer supports Node.js <8 as it relies on async-await internally.
355 runIfNewNode( "karma:jsdom" )
358 grunt.registerTask( "test", [
363 grunt.registerTask( "dev", [
367 "remove_map_comment",
373 grunt.registerTask( "default", [
377 "remove_map_comment",