Skip to content

TSC_COMPILE_ON_ERROR causes build to exit with status 0 even when files aren't emitted #11570

@bs85

Description

@bs85

Describe the bug

When TSC_COMPILE_ON_ERROR=1 is defined, the build.js script always returns an exit code of 0 even when the files are not emitted at all in /build.

Using it in production was a mistake in our case, but it's probably used that way by others. If it isn't suited for production builds, a warning would be nice. If it is intended, the return status should still reflect the files being emitted or not.

Environment

  current version of create-react-app: 3.3.1
  running from /usr/local/share/.config/yarn/global/node_modules/create-react-app

  System:
    OS: Linux 4.15 Ubuntu 18.04.6 LTS (Bionic Beaver)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 12.22.7 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 6.14.15 - /usr/bin/npm
  Browsers:
    Chrome: 95.0.4638.54
    Firefox: 93.0
  npmPackages:
    react: ^17.0.2 => 17.0.2 
    react-dom: ^17.0.2 => 17.0.2 
    react-scripts: 4.0.3 => 4.0.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

npx create-react-app my-app --template typescript
cd my-app

# edit src/App.tsx, add an import to a file that doesn't exist e.g. `import * from './nope'`

TSC_COMPILE_ON_ERROR=true yarn build && echo ok

Expected behavior

As files are not created in /build, exit code should be -1

Actual behavior

Exit code is 0 and the echo ok command executes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions