1 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;
19 if ( !grunt.option( "filename" ) ) {
20 grunt.option( "filename", "jquery.js" );
24 pkg: grunt.file.readJSON( "package.json" ),
25 dst: readOptionalJSON( "dist/.destination.json" ),
27 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
30 gz: function( contents ) {
31 return gzip.zip( contents, {} ).length;
34 cache: "build/.sizecache.json"
41 plugins: [ "@babel/transform-for-of" ]
45 "test/data/core/jquery-iterability-transpiled.js":
46 "test/data/core/jquery-iterability-transpiled-es6.js"
52 dest: "dist/jquery.js",
58 // Exclude specified modules if the module matching the key is removed
60 ajax: [ "manipulation/_evalUrl", "event/ajax" ],
61 callbacks: [ "deferred" ],
62 css: [ "effects", "dimensions", "offset" ],
63 "css/showHide": [ "effects" ],
65 remove: [ "ajax", "effects", "queue", "core/ready" ],
66 include: [ "core/ready-no-deferred" ]
74 destPrefix: "external"
77 "npo/npo.js": "native-promise-only/lib/npo.src.js",
79 "qunit/qunit.js": "qunit/qunit/qunit.js",
80 "qunit/qunit.css": "qunit/qunit/qunit.css",
81 "qunit/LICENSE.txt": "qunit/LICENSE.txt",
83 "requirejs/require.js": "requirejs/require.js",
85 "sinon/sinon.js": "sinon/pkg/sinon.js",
86 "sinon/LICENSE.txt": "sinon/LICENSE"
92 src: [ "package.json" ]
98 // See https://github.com/sindresorhus/grunt-eslint/issues/119
102 // We have to explicitly declare "src" property otherwise "newer"
103 // task wouldn't work properly :/
105 src: "dist/jquery.js"
108 src: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
114 // A special module with basic tests, meant for not fully
115 // supported environments like jsdom. We run it everywhere,
116 // though, to make sure tests are not broken.
143 customContextFile: "test/karma.context.html",
144 customDebugFile: "test/karma.debug.html",
146 ChromeHeadlessNoSandbox: {
147 base: "ChromeHeadless",
148 flags: [ "--no-sandbox" ]
151 frameworks: [ "qunit" ],
152 middleware: [ "mockserver" ],
156 "middleware:mockserver": [
158 require( "./test/middleware-mockserver.js" )
163 "test/data/jquery-1.9.1.js",
164 "external/sinon/sinon.js",
165 "external/npo/npo.js",
166 "external/requirejs/require.js",
167 "test/data/testinit.js",
171 // Replacement for testinit.js#loadTests()
172 "test/data/testrunner.js",
173 "test/unit/basic.js",
175 "test/unit/callbacks.js",
176 "test/unit/deferred.js",
177 "test/unit/deprecated.js",
178 "test/unit/support.js",
180 "test/unit/queue.js",
181 "test/unit/attributes.js",
182 "test/unit/event.js",
183 "test/unit/selector.js",
184 "test/unit/traversing.js",
185 "test/unit/manipulation.js",
188 "test/unit/serialize.js",
190 "test/unit/effects.js",
191 "test/unit/offset.js",
192 "test/unit/dimensions.js",
193 "test/unit/animation.js",
194 "test/unit/tween.js",
195 "test/unit/ready.js",
197 { pattern: "dist/jquery.*", included: false, served: true },
198 { pattern: "src/**", included: false, served: true },
199 { pattern: "external/**", included: false, served: true },
201 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
206 reporters: [ "dots" ],
209 captureTimeout: 20 * 1000,
214 // The Chrome sandbox doesn't work on Travis.
215 browsers: [ isTravis ? "ChromeHeadlessNoSandbox" : "ChromeHeadless" ]
221 "test/data/jquery-1.9.1.js",
222 "test/data/testinit-jsdom.js",
224 // We don't support various loading methods like AMD,
225 // choosing a version etc. for jsdom.
228 // Replacement for testinit.js#loadTests()
229 "test/data/testrunner.js",
231 // jsdom only runs basic tests
232 "test/unit/basic.js",
234 { pattern: "external/**", included: false, served: true },
236 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
242 browsers: [ "jsdom" ]
245 // To debug tests with Karma:
246 // 1. Run 'grunt karma:chrome-debug' or 'grunt karma:firefox-debug'
247 // (any karma subtask that has singleRun=false)
248 // 2. Press "Debug" in the opened browser window to start
249 // the tests. Unlike the other karma tasks, the debug task will
250 // keep the browser window open.
252 browsers: [ "Chrome" ],
256 browsers: [ "Firefox" ],
265 files: [ "<%= eslint.dev.src %>" ],
271 "dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
272 "dist/<%= grunt.option('filename') %>"
275 preserveComments: false,
278 "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
283 banner: "/*! jQuery v<%= pkg.version %> | " +
284 "(c) JS Foundation and other contributors | jquery.org/license */",
294 // Load grunt tasks from NPM packages
295 require( "load-grunt-tasks" )( grunt );
297 // Integrate jQuery specific tasks
298 grunt.loadTasks( "build/tasks" );
300 grunt.registerTask( "lint", [
303 // Running the full eslint task without breaking it down to targets
304 // would run the dist target first which would point to errors in the built
305 // file, making it harder to fix them. We want to check the built file only
306 // if we already know the source files pass the linter.
311 grunt.registerTask( "lint:newer", [
314 // Don't replace it with just the task; see the above comment.
319 grunt.registerTask( "test:fast", "node_smoke_tests" );
320 grunt.registerTask( "test:slow", [
321 "promises_aplus_tests",
325 grunt.registerTask( "test", [
330 grunt.registerTask( "dev", [
334 "remove_map_comment",
340 grunt.registerTask( "default", [
344 "remove_map_comment",