Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack warnings trigger build errors when running on CI #1150

Closed
scholtzm opened this issue Dec 4, 2016 · 22 comments
Closed

Webpack warnings trigger build errors when running on CI #1150

scholtzm opened this issue Dec 4, 2016 · 22 comments
Milestone

Comments

@scholtzm
Copy link
Contributor

scholtzm commented Dec 4, 2016

(Initial discussion starts here.)

Pull request #944 adds a new behaviour related to CIs - crash the build during CI whenever linter warnings are encountered.

This PR however introduced new side effect - webpack warnings will also crash the build, e.g.:

This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.

We could consider this particular warning to be harmless.
Since we have no access to webpack config, we cannot use module.noParse option either.

@scholtzm
Copy link
Contributor Author

scholtzm commented Dec 4, 2016

My initial idea was to check warnings to see if there are any related to eslint-loader.

Warnings emitted by eslint-loader contain full loader path, e.g. /long/path/to/node_modules/eslint-loader/index.js.

I couldn't find anything else that would mention eslint or eslint-loader that could be also reliably used to determine that a specific warning comes from ESLint.

@gaearon gaearon added this to the 0.8.2 milestone Dec 5, 2016
@gaearon
Copy link
Contributor

gaearon commented Dec 5, 2016

Agree. I’m not sure about this specific fix but please send a PR to get the ball rolling.
Then we can consider alternatives.

@scholtzm
Copy link
Contributor Author

scholtzm commented Dec 5, 2016

I dug a bit further and couldn't find anything that would provide information about which loader emitted the warning in a reliable manner.

For example an ESLint warning about eqeqeq, loaders property looks like this:

[
  '/system/path/node_modules/babel-loader/index.js?{"babelrc":false,"presets":["/system/path/node_modules/babel-preset-react-app/index.js"]}',
  '/system/path/node_modules/eslint-loader/index.js'
]

There's also issuer and request which are just long ! webpack strings formed from the info above.

edit. Maybe we could use failOnError and failOnWarning provided by eslint-loader.

@kachkaev
Copy link

kachkaev commented Dec 18, 2016

Same issue here. My temporary workaround was to unset CI variable in the build script (using .gitlab-ci.yml):

#...

build-app:
  stage: build-app
  cache:
    paths:
      - node_modules
    key: "node_modules"
    untracked: true
  script:
    - npm install
    - unset CI # <-------- this line helped
    - npm run build
  artifacts:
    paths:
      - build

#...

@gaearon gaearon modified the milestones: 1.0.0, 0.9.0 Jan 23, 2017
@scholtzm
Copy link
Contributor Author

@kachkaev Are there any side effects? Because of this, I'm still stuck at 0.7.5.

@kachkaev
Copy link

@scholtzm I have not noticed any. Please share yours – others (including myself) may face them in the next project.

@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Maybe we can ask Webpack to expose a way to turn that warning off? I never found it useful.

@scholtzm
Copy link
Contributor Author

@kachkaev Thinking about it right now, I think Jest uses CI env var to determine certain settings.

@gaearon As per my initial post here, in my particular case, I'd have to use noParse option. I don't think there is a global setting that would allow us to disable this warning globally. Seems like noParse is the "official" way.

@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

webpack/webpack#4263

@mikew
Copy link

mikew commented Mar 27, 2017

Why not change the logic to process.env.CI && stats.compilation.errors.length?

@gaearon
Copy link
Contributor

gaearon commented May 18, 2017

Because that's the opposite of the intention. The intention is to fail CI on warnings (but only useful warnings coming from ESLint).

FWIW I did try this with master, and I can’t reproduce this specific warning anymore. Which library should I try with?

@scholtzm
Copy link
Contributor Author

In my case, it was triggered by localForage.

@gaearon
Copy link
Contributor

gaearon commented May 18, 2017

Can you provide a code snippet?

@scholtzm
Copy link
Contributor Author

scholtzm commented May 18, 2017

Just simple import will trigger the warning.

https://github.com/scholtzm/arnold/blob/master/src/util/storage.js#L1

@mikew
Copy link

mikew commented May 18, 2017

@gaearon

Because that's the opposite of the intention. The intention is to fail CI on warnings (but only useful warnings coming from ESLint).

That's my point. Eslint has errors and warnings, and changing the behaviour to treat warnings as errors is changing the semantics. When really they should just be changed to errors in cra's eslint config.

@gaearon
Copy link
Contributor

gaearon commented May 18, 2017

Please see past discussions when people repeatedly asked to treat warnings as errors in CI. This is common practice.

@gaearon
Copy link
Contributor

gaearon commented May 18, 2017

@scholtzm Can you check if the issue reproduces on master?

@scholtzm
Copy link
Contributor Author

I will report back this weekend.

@gaearon gaearon added this to the 1.0.1 milestone May 18, 2017
@gaearon gaearon modified the milestones: 100.0.0, 1.0.1, 1.0.x May 18, 2017
@holman
Copy link

holman commented May 22, 2017

fwiw, I've been getting the initial This seems to be a pre-built javascript file warning for some time, but I just upgraded to 1.0.x and it's being suppressed correctly now. ✨

@gaearon
Copy link
Contributor

gaearon commented May 22, 2017

The funny thing is we didn’t actually do anything to suppress it. I have no idea why it’s gone 😄

@gaearon
Copy link
Contributor

gaearon commented May 22, 2017

I’ll close for now but if somebody can reproduce please give me instructions.

@gaearon gaearon closed this as completed May 22, 2017
@holman
Copy link

holman commented May 22, 2017

Haha, MYSTERY FIX

I'll keep an eye out on my end for any weird changes here regardless.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants