Skip to content

formatWebpackMessages shouldn't use chalk #8583

Closed
@MOZGIII

Description

@MOZGIII

Describe the bug

I have an error below:

index.js:8 Uncaught ReferenceError: process is not defined
    at Object../node_modules/chalk/index.js (index.js:8)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object../node_modules/react-dev-utils/formatWebpackMessages.js (formatWebpackMessages.js:10)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object../node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/ErrorOverlayEntry.js (ErrorOverlayEntry.js:5)
    at __webpack_require__ (bootstrap:734)
    at fn (bootstrap:100)
    at Object.0 (index.tsx:12)

It's caused by a deep dependency of my app, but I deduced the right place to correct this may be here.

I'm not using CRA directly, and running this in an electron app that has sandboxed access to a subset of nodejs API.

Environment

  • react-dev-utils 9.1.0; master in the repo currently has the same behavior.
  • webpack 4, babel 7 and so on, but this is irrelevant as workarounds won't cover my use case.

Expected behavior

I expect react-dev-utils/formatWebpackMessages.js to not use chalk, since it's not used in the cli context. chalk requires Node APIs to be available.

Actual behavior

I got an exception. cause chalk has const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');. It's not adopted for browser use.

Reproducible demo

Sorry.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions