Create-react-app: How to deal with webpack warning from unmaintained grandparent module?

Created on 2 Apr 2017  ·  8Comments  ·  Source: facebook/create-react-app

Can you reproduce the problem with latest npm?

yes.

Description

Requiring winston generates a warning due to some webpack-warning-deserving code that winston's dependency, colors has.

It's currently impossible AFAICT to tell eslint to ignore it.

I'm opening this bug here because it's impossible to e.g. disable the webpack warning exprContextCritical without ejecting, but using a very popular logging module shouldn't require ejecting.

Alternatively, can anyone suggest an alternative to winston?

Related issues:

Expected behavior

Adding winston to a CRA project should not add warnings on each page load, or it should be possible to deal with a "misbehaving" grandparent.

Actual behavior

import log from "winston";
log.info('hi there')

yields:

Compiled with warnings.

Warning in ./~/colors/lib/colors.js
Critical dependencies:
127:29-43 the request of a dependency is an expression
 @ ./~/colors/lib/colors.js 127:29-43

Warning in ./~/colors/lib/extendStringPrototype.js
Critical dependencies:
106:31-45 the request of a dependency is an expression
 @ ./~/colors/lib/extendStringPrototype.js 106:31-45

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.

Environment

  1. npm ls react-scripts (if you haven’t ejected):
[email protected] /Users/da/src/webpack-warning
└── [email protected] 
  1. node -v: v7.7.2
  2. npm -v: 4.4.4

Then, specify:

  1. Operating system: OSX 10.12.4
  2. Browser and version: Chrome 56.0.2924.87

Reproducible Demo

See minimal repo at https://github.com/davidascher/webpack-warning/

question

Most helpful comment

Longer term we aim to solve it here: https://github.com/webpack/webpack/issues/4263

All 8 comments

I suggest forking colors, removing the dynamic require (or putting it behind a nodejs/webpack&browserify compatible escape hatch to make it web bundle friendly), and releasing a semver-major (2.0).
You can then submit a follow up PR to winston switching to the new module.

Unfortunately we're not going to add an escape hatch for this, so you will need to eject or live with the warning.
Our philosophy is to require no configuration and avoid introducing it where otherwise unnecessary. Adding an escape hatch to bundle __improper__ web packages is one we're definitely not going to support (sorry!).


You can check out bunyan, too.

Let me know if we can help with anything else. :)

Longer term we aim to solve it here: https://github.com/webpack/webpack/issues/4263

Not sure how you plan to fix it, but https://github.com/webpack/webpack/issues/4381 was merged, once released you can use it to suppress those warnings.
Would be happy to do a PR but not sure how you plan and what you plan to ignore :)

Oo that looks promising @timse. Can you please open a new proposal issue for us to talk details? Thanks!

Longer term we aim to solve it here: webpack/webpack#4263

@gaearon now that the suppress warnings feature was added to webpack, do you plan to use it ?
maybe open this issue again?

ill reopen an issue :)

Can you add a link to the new issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alleroux picture alleroux  ·  3Comments

Evan-GK picture Evan-GK  ·  3Comments

AlexeyRyashencev picture AlexeyRyashencev  ·  3Comments

dualcnhq picture dualcnhq  ·  3Comments

jnachtigall picture jnachtigall  ·  3Comments