-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Build initially fails when using both babel and eslint but pass on second attempt #5399
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
Comments
I'm having the same issue. Sharing a thread from the vue forum where others are reporting the same: https://forum.vuejs.org/t/remove-console-not-always-applied/87810/2 |
We also just reproduced that. (MacOS 10.14.6 (18G3020)) |
This actually breaks our current build setup. |
It also happens when you do not choose Babel. |
Steps to reproduce:
|
Another gained insight:
So it seems to be a caching issue |
Apparently a workaround until Vue team fixes it is making the cache directory unwriteable:
|
While there might be a workaround for local building, I haven't figured out a way to make it work with CI/CD workflows. This issue is blocking my ability to use Netlify's automated build and deploy feature from git merges. Just wanted to share that as I think it makes the case for prioritizing this issue (unless someone has a workaround) |
Couldn't you integrate this workaround in your CI/CD environment? |
I was digging a bit deeper and it most probably comes from either I also tested around with |
Now more info on that: Both Analogously this applies for Summed up: |
This is not the same issue as I describe in the issue summary. I am not using typescript, and I do not have a vue-loader folder in It's possible that the issues are related but this is not a workaround for the issue I reported. |
My issue is actually the opposite with respect to the With the It seems likely that depending on your loader usage and linting levels, the build results may actually be different on the first build versus every subsequent build. |
@gdmoore As you can see above a bare repo was created with the minimal set given through The expected result is: [The build MUST fail because console.log are set to error mode]. That is what is important to understand @gdmoore. Here is a new and cleaner-to-apply workaround: // vue.config.js
module.exports = {
chainWebpack: config => {
config.module.rule('vue').uses.delete('cache-loader');
config.module.rule('js').uses.delete('cache-loader');
config.module.rule('ts').uses.delete('cache-loader');
config.module.rule('tsx').uses.delete('cache-loader');
}
}; |
@activenode see the repository in the issue summary. I believe you did not see that I have Babel configured with Also if you do build my repository, notice that when it builds successfully, the console.log statement is not present in the built I suspect that the issue I reported and the issue you are experiencing are strongly related, but not identical. |
So let me try to explain what is happening in your case and clarify my assumption why your issue is the same issue as our issue: You assume that your This however is a "false positive". Your babel comes into effect to remove the console.log from the built file. The babel plugin however does NOT prevent the
but it should look like this in your example:
This will fix your problem. If it does fix your problem it even proves further that we are talking about the same issue :) (or in other words if you would apply the given workaround your repo as it is now would and should always fail without adapting the |
I see, knowing that babel runs after linting leads me to agree that we are talking about the exact same issue. When I build successfully the second build is using the previously-cached results from the first build which have already been transformed to drop the console statement, which now passes linting. There is still a bug (or mis-feature?) here directly related to console and linting: Directives that modify source, like I explicitly have the rules set to disallow console statements so that in my real project if someone changes the babel config, or if babel doesn't run properly, and it doesn't strip console statements, I want the build to fail so that I don't ship a release with console statements in it. If I take your advice, it's possible that I could end up shipping with logs. |
So that means
Not if you leave your existing code of tldr: There is other solutions than using babel for removing console.log . I recommend that you stick with your repo that you have and get errors before compilation when you have console.log in your project (which is why it is so important that THIS github issue gets fixed). Now you could say: "But I would still want console.log for my development build" There is multiple different solutions for this problem:
But then again. This goes beyond the scope of the issue that is described :) |
Having the same issue. Would certainly like some resolution as this is breaking my CI/CD builds. An additional workaround is adding |
Same thing happens to me with a new project... quite unfortunate for Vue, tbh. - step:
name: Build
script:
- npm install
- npm run build || true # Ignoring the output of this step because the first build fails https://github.com/vuejs/vue-cli/issues/5399
- npm run build
artifacts:
- dist/** |
Wait, that produces false positives. The should-fail-build fails correctly in the first build (which is correct) but does not for any additional builds. |
@OddDev |
duplicate of #3065 let eslint emit error as warning in production /** @type {import('@vue/cli-service').ProjectOptions} */
module.exports = {
lintOnSave: true
}; |
Good to know I'm not the only one, still having this issue.
But it feels tricky, as I don't have any linting on the production build.... |
Version
4.3.1
Reproduction link
https://github.com/gdmoore/vue-cli-babel-err
Environment info
Steps to reproduce
What is expected?
Eslint configured for
no-console
but babel configured withtransform-remove-console
, so the console statement should not cause a build error.Build results should be consistent on every build.
What is actually happening?
Build fails on first attempt, succeeds on the second, with no code changes.
Any changes to
main.js
(even trivial ones such as adding or removing comments) will cause the build to break and require two builds again for success.This is a minified case from my actual project, which was generated using
vue create
and choosing Babel and ESLint.I suspect this is a bug with caching or in determining the order to run eslint and babel.
The text was updated successfully, but these errors were encountered: