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

Failed build succeeds on second cache run #507

Open
fantapop opened this issue Aug 5, 2019 · 1 comment
Open

Failed build succeeds on second cache run #507

fantapop opened this issue Aug 5, 2019 · 1 comment

Comments

@fantapop
Copy link

fantapop commented Aug 5, 2019

Expected Behavior

modules with errors in them should not keep built file

Actual Behavior

My build runs. Multiple files have typescript errors causing the build to fail. The build succeeds when trying to run it again. When i disable the cache it fails every time.

Is an error being thrown?

there is no error being thrown.

Steps to Reproduce

I can build a repro if necessary. I see issue #365 and the related fix which is very similar. The errors that I'm seeing however are not throwing an exception. I have 2 work arounds currently. One is to automatically clear the cache in shell based on the return code of the webpack build:

"build-prod": "NODE_ENV=production webpack --config conf/webpack.prod.js --progress || yarn clear-cache

the other is to hook into webpacks stats callback after the build is complete and remove the cache if there are any failures.

const isDevServer = process.argv.find(v => v.includes('webpack-dev-server'));
const isWatch = process.argv.find(v => v.includes('--watch'));
...
...
...

    plugins: [
        {
            apply: compiler => {
                compiler.hooks.done.tap('compliation done', stats => {
                    if (
                        stats.compilation.errors &&
                        stats.compilation.errors.length &&
                        !isDevServer &&
                        !isWatch

                    ) {
                        console.error('\nFailed Build: clearing cache');
                        rimraf(`${root}/node_modules/.cache/hard-source`, () => {
                            console.error('Failed Build: Cache cleared');
                        });
                    }
                });
            },
        },
        new HardSourceWebpackPlugin(),
    ],

It would be more ideal if the hard source plugin did this and removed only cache entries for files which have failed if this is possible.

Operating System, Node, and NPM dependency versions

Ubuntu 18.04,
node 8.10.0, yarn 1.17.3,
    "devDependencies": {
        "@babel/core": "7.4.3",
        "@fortawesome/fontawesome-common-types": "^0.2.17",
        "@types/classnames": "^2.2.7",
        "@types/node": "^11.13.6",
        "@types/numeral": "^0.0.25",
        "@types/react": "^16.8.14",
        "@types/react-dom": "^16.8.4",
        "@types/react-select": "^2.0.17",
        "@typescript-eslint/eslint-plugin": "^1.10.2",
        "@typescript-eslint/parser": "^1.10.2",
        "babel-core": "6",
        "babel-loader": "^7.1.5",
        "babel-plugin-transform-object-rest-spread": "^6.26.0",
        "babel-preset-es2015": "^6.18.0",
        "babel-preset-minify": "^0.5.0",
        "babel-preset-react": "^6.16.0",
        "clean-webpack-plugin": "^2.0.1",
        "copy-webpack-plugin": "^5.0.2",
        "css-loader": "^2.1.1",
        "dtsgenerator": "^2.0.7",
        "eslint": "^5.16.0",
        "eslint-import-resolver-webpack": "^0.11.1",
        "eslint-loader": "^2.1.2",
        "eslint-plugin-import": "^2.17.3",
        "eslint-plugin-react": "^7.13.0",
        "hard-source-webpack-plugin": "^0.13.1",
        "html-loader": "^0.5.5",
        "html-webpack-plugin": "^3.2.0",
        "http-server": "^0.11.1",
        "less": "^3.9.0",
        "less-loader": "^4.1.0",
        "mini-css-extract-plugin": "^0.5.0",
        "optimize-css-assets-webpack-plugin": "^5.0.1",
        "prettier": "^1.18.2",
        "protoc-gen-jsonpb-ts": "^0.1.9",
        "source-map-loader": "^0.2.4",
        "style-loader": "^0.23.1",
        "terser-webpack-plugin": "^1.2.3",
        "ts-loader": "^5.4.3",
        "typescript": "^3.4.4",
        "url-loader": "^1.1.2",
        "webpack": "^4.25.1",
        "webpack-bundle-analyzer": "^3.3.2",
        "webpack-cli": "^3.3.1",
        "webpack-dev-server": "^3.3.0",
        "webpack-merge": "^4.2.1"
    },
@TotooriaHyperion
Copy link

Same problem here.
It ignores error thrown from ts-loader or I guess it never run loader again since there is no change thus hit cache.
So it maybe need save the errors/warnings also into cache.
If this plugin is designed for development, then we shouldn't have use it at production build phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants