Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5268

Changes the start script to tap on the done and failed hooks of the c…

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/mAiNiNfEcTiOn/dev-server-wait-until-compiler-is-done into master Oct 03, 2018
  • Overview 6
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: mAiNiNfEcTiOn

What does this PR do:

  • Changes the start script to tap on the done and failed hooks of the compiler to know the right time to run.

Where should the reviewer start:

  • The packages/react-scripts/scripts/start.js was modified, more specifically the devServer.listen() callback.

What is this trying to solve:

  • When doing yarn start the server boots up, opens the browser, but renders a blank page (with the <script> tags properly injected.
  • After getting that, tried to reproduce the same behaviour with yarn build and serve -s build, which I was unable to. That led me to think that the problem was between the dev server or bundle compilation
  • Next step, I edited the node_modules/react-scripts/scripts/start.js, in the same area I've changed for this PR, but placing only a setTimeout(() => openBrowser(urls.localUrlForBrowser), 5000); ... That solved it - but looked hackish... Led to the obvious question of "What if bundling would take more than X seconds set in the timeout? Not cool"...
    • So I changed the implementation to call on done or failed hooks on the compiler.
    • Last but not the least, I created a function that returns a closure controlling if the browser is already open. I'm totally fine with changing it to make it more readable, or even removing it totally if openBrowser already checks that.

Let me know your thoughts on this and how can I improve it, or if it's something that I shouldn't be doing. I'm all for learning more about it 👍

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mAiNiNfEcTiOn/dev-server-wait-until-compiler-is-done