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 travisBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," ),
19 CLIEngine = require( "eslint" ).CLIEngine;
21 if ( !grunt.option( "filename" ) ) {
22 grunt.option( "filename", "jquery.js" );
26 pkg: grunt.file.readJSON( "package.json" ),
27 dst: readOptionalJSON( "dist/.destination.json" ),
29 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
32 gz: function( contents ) {
33 return gzip.zip( contents, {} ).length;
36 cache: "build/.sizecache.json"
43 plugins: [ "@babel/transform-for-of" ]
47 "test/data/core/jquery-iterability-transpiled.js":
48 "test/data/core/jquery-iterability-transpiled-es6.js"
54 dest: "dist/jquery.js",
60 // Exclude specified modules if the module matching the key is removed
62 ajax: [ "manipulation/_evalUrl", "deprecated/ajax-event-alias" ],
63 callbacks: [ "deferred" ],
64 css: [ "effects", "dimensions", "offset" ],
65 "css/showHide": [ "effects" ],
67 remove: [ "ajax", "effects", "queue", "core/ready" ],
68 include: [ "core/ready-no-deferred" ]
70 event: [ "deprecated/ajax-event-alias", "deprecated/event" ]
76 src: [ "package.json" ]
84 // We have to explicitly declare "src" property otherwise "newer"
85 // task wouldn't work properly :/
87 src: [ "dist/jquery.js", "dist/jquery.min.js" ]
96 // Ignore files from .eslintignore
97 // See https://github.com/sindresorhus/grunt-eslint/issues/119
99 .getConfigForFile( "Gruntfile.js" )
100 .ignorePatterns.map( ( p ) => `!${ p }` )
107 // A special module with basic tests, meant for not fully
108 // supported environments like jsdom. We run it everywhere,
109 // though, to make sure tests are not broken.
136 customContextFile: "test/karma.context.html",
137 customDebugFile: "test/karma.debug.html",
139 ChromeHeadlessNoSandbox: {
140 base: "ChromeHeadless",
141 flags: [ "--no-sandbox" ]
144 frameworks: [ "qunit" ],
145 middleware: [ "mockserver" ],
149 "middleware:mockserver": [
151 require( "./test/middleware-mockserver.js" )
158 // We're running `QUnit.start()` ourselves via `loadTests()`
164 "test/data/jquery-1.9.1.js",
165 "node_modules/sinon/pkg/sinon.js",
166 "node_modules/native-promise-only/lib/npo.src.js",
167 "node_modules/requirejs/require.js",
168 "test/data/testinit.js",
173 pattern: "dist/jquery.*",
191 { pattern: "node_modules/**", included: false, served: true },
193 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
199 reporters: [ "dots" ],
202 captureTimeout: 20 * 1000,
206 browsers: isTravis && travisBrowsers || [ "ChromeHeadless", "FirefoxHeadless" ]
209 browsers: isTravis && travisBrowsers || [ "ChromeHeadless" ],
214 // We're running `QUnit.start()` ourselves via `loadTests()`
224 browsers: isTravis && travisBrowsers || [ "ChromeHeadless" ],
229 // We're running `QUnit.start()` ourselves via `loadTests()`
242 "test/data/jquery-1.9.1.js",
243 "test/data/testinit-jsdom.js",
245 // We don't support various loading methods like esmodules,
246 // choosing a version etc. for jsdom.
249 // A partial replacement for testinit.js#loadTests()
250 "test/data/testrunner.js",
252 // jsdom only runs basic tests
253 "test/unit/basic.js",
256 pattern: "test/**/*.@(js|css|jpg|html|xml|svg)",
262 browsers: [ "jsdom" ]
265 // To debug tests with Karma:
266 // 1. Run 'grunt karma:chrome-debug' or 'grunt karma:firefox-debug'
267 // (any karma subtask that has singleRun=false)
268 // 2. Press "Debug" in the opened browser window to start
269 // the tests. Unlike the other karma tasks, the debug task will
270 // keep the browser window open.
272 browsers: [ "Chrome" ],
276 browsers: [ "Firefox" ],
285 files: [ "<%= eslint.dev.src %>" ],
291 "dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
292 "dist/<%= grunt.option('filename') %>"
295 preserveComments: false,
298 "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
303 banner: "/*! jQuery v<%= pkg.version %> | " +
304 "(c) OpenJS Foundation and other contributors | jquery.org/license */",
314 // Load grunt tasks from NPM packages
315 require( "load-grunt-tasks" )( grunt );
317 // Integrate jQuery specific tasks
318 grunt.loadTasks( "build/tasks" );
320 grunt.registerTask( "lint", [
323 // Running the full eslint task without breaking it down to targets
324 // would run the dist target first which would point to errors in the built
325 // file, making it harder to fix them. We want to check the built file only
326 // if we already know the source files pass the linter.
331 grunt.registerTask( "lint:newer", [
334 // Don't replace it with just the task; see the above comment.
339 grunt.registerTask( "test:fast", "node_smoke_tests" );
340 grunt.registerTask( "test:slow", [
341 "promises_aplus_tests",
345 grunt.registerTask( "test:prepare", [
350 grunt.registerTask( "test", [
356 grunt.registerTask( "dev", [
360 "remove_map_comment",
366 grunt.registerTask( "default", [
371 "remove_map_comment",