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
  • !1254

Don't assume window is defined when polyfilling Promise

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/pugnascotia/master into master Dec 12, 2016
  • Overview 5
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: pugnascotia

I know server-rendering isn't supported, but I was tinkering with loading the production bundle in Nashorn, Java 8's JavaScript engine, and found that the Promise polyfill assumes that window exists. This PR changes the polyfill to attempt to use window first, and global secondly.

For the interested reader, global isn't defined in Nashorn either, but it can be easily defined in order to bring it in-line with Node.

Testing steps:

npm run create-react-app mytestapp
cd mytestapp
npm start
# App starts OK and renders in the browser

npm run build
# App builds successfully.

# Also need to change generated src/index.js to only mount React if document is defined
vim src/index.js
# Start Nashorn interpreter
jjs
> var global = {}
> load('build/static/js/main.26610bf4.js')
# File load without throwing an exception
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pugnascotia/master