Repository: create-react-app
Issue: react-scripts v5 error: Uncaught ReferenceError: exports is not defined
Labels: needs triage,issue: bug report

### Describe the bug

CommonJS exports don't seem to be compatible with react-scripts v5

### Environment

<details>
<summary>npx create-react-app --info output</summary>

<pre><code>Environment Info:

  current version of create-react-app: 5.0.0
  running from C:\Users\____\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  Binaries:
    Node: 14.17.5 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.21.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 96.0.4664.110
    Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.62)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found
</code></pre>
</details>


### Steps to reproduce

1. Create new cra project `npx create-react-app my-app`
2. Go into the project `cd my-app`
3. Install @time-input-polyfill/react `npm i @time-input-polyfill/react`
4. Update `src/App.js` to use the installed time input polyfill using ES6 import syntax ([Example file](https://github.com/Dan503/cra-exports-not-defined-error/blob/main/src/App.js))
5. Run the project `npm run start`

### Expected behavior

It should run without any errors.

### Actual behavior

I get the following error in the **browser** console. React compiles just fine.

```
Uncaught ReferenceError: exports is not defined
    node_modules time-input-polyfill/utils/npm/common/supportsTime.js@http://localhost:3000/static/js/bundle.js:42653
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    node_modules time-input-polyfill/react/src/core/TimeInputPolyfill.js@http://localhost:3000/static/js/bundle.js:873
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    node_modules time-input-polyfill/react/index.js@http://localhost:3000/static/js/bundle.js:768
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:67
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:195
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    <anonymous> http://localhost:3000/static/js/bundle.js:43889
    <anonymous> http://localhost:3000/static/js/bundle.js:43891
bundle.js:42653:1
    js http://localhost:3000/static/js/bundle.js:42653
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:873
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:768
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:67
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    fn http://localhost:3000/static/js/bundle.js:42921
    js http://localhost:3000/static/js/bundle.js:195
    factory http://localhost:3000/static/js/bundle.js:43250
    __webpack_require__ http://localhost:3000/static/js/bundle.js:42700
    <anonymous> http://localhost:3000/static/js/bundle.js:43889
    <anonymous> http://localhost:3000/static/js/bundle.js:43891
```

### Reproducible demo

I've performed the replication steps in this repository:

https://github.com/Dan503/cra-exports-not-defined-error

## Additional details

I am aware that this is most likely an issue with the time-input-polyfill code. I'm the maintainer of `@time-input-polyfill/react` and I need some help understanding what I need to change to make it work in new React projects that doesn't break for old CommonJS projects.

This was not an issue when using react-scripts v4. It became an issue when v5 was released.