{"action":"closed","issue":{"url":"https://api.github.com/repos/gruntjs/grunt-cli/issues/83","labels_url":"https://api.github.com/repos/gruntjs/grunt-cli/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/gruntjs/grunt-cli/issues/83/comments","events_url":"https://api.github.com/repos/gruntjs/grunt-cli/issues/83/events","html_url":"https://github.com/gruntjs/grunt-cli/issues/83","id":106183437,"number":83,"title":"Arrow functions break grunt the first time you run it.","user":{"login":"andrew-luhring","id":1039350,"avatar_url":"https://avatars.githubusercontent.com/u/1039350?v=3","gravatar_id":"","url":"https://api.github.com/users/andrew-luhring","html_url":"https://github.com/andrew-luhring","followers_url":"https://api.github.com/users/andrew-luhring/followers","following_url":"https://api.github.com/users/andrew-luhring/following{/other_user}","gists_url":"https://api.github.com/users/andrew-luhring/gists{/gist_id}","starred_url":"https://api.github.com/users/andrew-luhring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrew-luhring/subscriptions","organizations_url":"https://api.github.com/users/andrew-luhring/orgs","repos_url":"https://api.github.com/users/andrew-luhring/repos","events_url":"https://api.github.com/users/andrew-luhring/events{/privacy}","received_events_url":"https://api.github.com/users/andrew-luhring/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-12T20:28:02Z","updated_at":"2016-01-29T03:12:23Z","closed_at":"2016-01-29T03:12:23Z","body":"Not completely sure whether this is a grunt-contrib-watch issue or a grunt issue so i'm submitting the issue in [both places](https://github.com/gruntjs/grunt-contrib-watch/issues/460), but here's my setup and what's happening:\r\n\r\n# Setup\r\n## Gruntfile.js\r\n\r\n```js\r\nmodule.exports = function(grunt) {\r\n    var request = require('./request.js')\r\n ,  config = {\r\n            pkg: grunt.file.readJSON('package.json')\r\n            , watch: {\r\n                  files: ['./request.js']\r\n                , tasks: ['req']\r\n                , options: {\r\n                    spawn: false\r\n                }\r\n            }\r\n        };\r\n\r\n    grunt.loadNpmTasks('grunt-contrib-watch');\r\n    grunt.initConfig(config);\r\n\r\n    grunt.registerTask('req', function() {\r\n        console.log('\\n\\n\\n\\n\\n');\r\n        request();\r\n        console.log('\\n\\n\\n\\n\\n');\r\n    });\r\n\r\n    grunt.registerTask('default', ['watch']);\r\n};\r\n```\r\n\r\n\r\n## Request.js\r\n\r\n```js\r\n'use strict';\r\nvar http = require('http');\r\nmodule.exports = ()=> {\r\n    console.log('requesting...');\r\n};\r\n```\r\n\r\n\r\n# To reproduce issue:\r\n1. On the command line run ```grunt --verbose --debug```\r\n1. Then add a space or something to request.js and hit save.\r\n\r\n### Result:\r\nGrunt will the grunt watch task, the grunt-watch task will run request.js, it will break.\r\n```\r\nInitializing\r\nCommand-line options: --verbose, --debug=1\r\n\r\nReading \"Gruntfile.js\" Gruntfile...OK\r\n\r\nRegistering Gruntfile tasks.\r\nLoading \"Gruntfile.js\" tasks...ERROR\r\n>> /Users/the_future/Google Drive/Sites/lol/request.js:4\r\n>> module.exports = ()=> {\r\n>>                   ^\r\n>> SyntaxError: Unexpected token )\r\n>>     at exports.runInThisContext (vm.js:73:16)\r\n>>     at Module._compile (module.js:443:25)\r\n>>     at Object.Module._extensions..js (module.js:478:10)\r\n>>     at Module.load (module.js:355:32)\r\n>>     at Function.Module._load (module.js:310:12)\r\n>>     at Module.require (module.js:365:17)\r\n>>     at require (module.js:384:17)\r\n>>     at Object.module.exports (/Users/the_future/Google Drive/Sites/lol/Gruntfile.js:4:19)\r\n>>     at loadTask (/Users/the_future/Google Drive/Sites/lol/node_modules/grunt/lib/grunt/task.js:325:10)\r\n>>     at Task.task.init (/Users/the_future/Google Drive/Sites/lol/node_modules/grunt/lib/grunt/task.js:437:5)\r\n\r\nNo tasks specified, running default tasks.\r\nRunning tasks: default\r\nWarning: Task \"default\" not found. Use --force to continue.\r\nAborted due to warnings.\r\n```\r\n\r\n^ Grunt fails.\r\n\r\n# BUT\r\nNow, change request.js to the following.\r\n\r\n```\r\n'use strict';\r\nvar http = require('http');\r\nmodule.exports = function () {\r\n    console.log('requesting...');\r\n};\r\n```\r\n\r\n1. Run ```grunt --verbose --debug```\r\n1. Add a space or something to request.js and save.\r\n\r\nIt's fine. No es6, no error.\r\n\r\n# BUT\r\n\r\nNOW- without stopping grunt- change request.js back to:\r\n\r\n```js\r\n'use strict';\r\nconst http = require('http');\r\n\r\nmodule.exports = ()=> {\r\n    console.log('requesting...');\r\n};\r\n```\r\n\r\n# Result:\r\n\r\nIT WORKS FINE.\r\n\r\nThe first time you run grunt, it doesn't respect es6 (arrow functions at least). But if you run grunt without any es6 at first, **THEN ADD ES6 CODE** grunt works as expected.\r\n\r\nHence, i'm not sure if this is an issue with grunt or grunt-contrib-watch.\r\n"}}