{"action":"closed","issue":{"url":"https://api.github.com/repos/BrowserSync/gulp-browser-sync/issues/54","labels_url":"https://api.github.com/repos/BrowserSync/gulp-browser-sync/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/BrowserSync/gulp-browser-sync/issues/54/comments","events_url":"https://api.github.com/repos/BrowserSync/gulp-browser-sync/issues/54/events","html_url":"https://github.com/BrowserSync/gulp-browser-sync/issues/54","id":95198425,"number":54,"title":"Using babel in express  causes delay in page load","user":{"login":"rossthedevigner","id":5264084,"avatar_url":"https://avatars.githubusercontent.com/u/5264084?v=3","gravatar_id":"","url":"https://api.github.com/users/rossthedevigner","html_url":"https://github.com/rossthedevigner","followers_url":"https://api.github.com/users/rossthedevigner/followers","following_url":"https://api.github.com/users/rossthedevigner/following{/other_user}","gists_url":"https://api.github.com/users/rossthedevigner/gists{/gist_id}","starred_url":"https://api.github.com/users/rossthedevigner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rossthedevigner/subscriptions","organizations_url":"https://api.github.com/users/rossthedevigner/orgs","repos_url":"https://api.github.com/users/rossthedevigner/repos","events_url":"https://api.github.com/users/rossthedevigner/events{/privacy}","received_events_url":"https://api.github.com/users/rossthedevigner/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-15T13:48:01Z","updated_at":"2015-08-04T00:24:17Z","closed_at":"2015-08-04T00:24:17Z","body":"I'm trying to configure my build to use BrowserSync, Express, Nodemon, and Babel. What I've found is that if I include `require('babel/register');` in my `entry.js` file, the initial load time for the page is 30s~. \r\n\r\nIf I remove `require('babel/register');` the app loads immediately as expected or if I perform a manual refresh. \r\n\r\nThis is based on @sogko recipe.\r\n\r\nHere is my configuration\r\n\r\n**browserSync**\r\n```js\r\ngulp.task('browserSync', ['nodemon'], function() {\r\n  browserSync({\r\n    proxy: \"http://localhost:5000\",\r\n    port: 3000,\r\n    notify: true,\r\n    files: [\r\n      //config.dest + '/**/*',\r\n      '!' + config.dest + '/**/*.map'\r\n    ]\r\n  });\r\n});\r\n```\r\n\r\n**server.js**\r\n```js\r\n// 'build' is browserify\r\n \r\ngulp.task('nodemon', ['build'], function(cb) {\r\n  var called = false;\r\n  return nodemon({\r\n      // nodemon our expressjs server\r\n      script: './app/server/entry.js',\r\n      ext: 'js html',\r\n      env: {\r\n        'NODE_ENV': 'development'\r\n      },\r\n      verbose: true,\r\n      // watch core server file(s) that require server restart on change\r\n      watch: ['./app/server/']\r\n    })\r\n    .on('start', function onStart() {\r\n      if (!called) {\r\n        cb();\r\n      }\r\n      called = true;\r\n    })\r\n    .on('restart', function onRestart() {\r\n      setTimeout(function reload() {\r\n        console.log('restart?')\r\n        browserSync.reload({\r\n          stream: false   //\r\n        });\r\n      }, 500);\r\n    });\r\n});\r\n```\r\n\r\n**entry.js**\r\n```js\r\n'use strict';\r\n \r\n// if I remove this line, the app loads immediately\r\n// otherwise there is a 30s 'waiting for localhost'\r\nrequire('babel/register');\r\n \r\nvar enableDestroy = require('server-destroy');\r\nvar http = require('http');\r\nvar app = require('./app');\r\n \r\nvar PORT = process.env.PORT || 5000;\r\n \r\nvar server = http.createServer(app);\r\n \r\n// listen on port\r\nserver.listen(PORT, function() {\r\n  console.log('express server listening on port: ' + PORT);\r\n});\r\n \r\nenableDestroy(server);\r\n```\r\n\r\n\r\n**app.js**\r\n```js\r\n'use strict';\r\n \r\nvar express = require('express');\r\nvar _ = require('lodash');\r\nvar path = require('path');\r\nvar compression = require('compression');\r\nvar cookieParser = require('cookie-parser');\r\nvar bodyParser = require('body-parser');\r\nvar logger = require('morgan');\r\nvar swig = require('swig');\r\n \r\nconsole.log(\". = %s\", path.resolve(\".\"));\r\nconsole.log(\"__dirname = %s\", path.resolve(__dirname));\r\n \r\n// express\r\nvar port = process.env.PORT || 5000;\r\nvar env = process.env.NODE_ENV || 'development';\r\nvar app = express();\r\n \r\napp.engine('html', swig.renderFile);\r\napp.set('view engine', 'html');\r\napp.set('views', path.join(__dirname, 'views'));\r\napp.set('view cache', false);\r\n \r\n \r\n// routing\r\napp.get('/', function(req, resp, next) {\r\n  resp.render('base', { content: '' });\r\n});\r\n \r\n// debug logger\r\nif (env === 'development') {\r\n  // app.use(logger('combined'));\r\n}\r\n \r\nexport default app;\r\n```\r\n"}}