mzgoddard / hard-source-webpack-plugin

https://www.npmjs.com/package/hard-source-webpack-plugin
ISC License
2.71k stars 160 forks source link

Cache is corrupted .... Last compilation did not finish saving. Building new cache. #405

Closed gauravmahto closed 6 years ago

gauravmahto commented 6 years ago

Expected Behavior

Should properly detect and use the existing cache.

Actual Behavior

Even if the cache is in good condition, it fails to recognize it and builds a new cache every time. P.S. I do observe that the rebuilds are still faster than the first build. But do worry about the integrity of files being compiled based on the existing cache.

Is an error being thrown?

Yes. Below is the stack trace.

First - build output: hardsource:6c0f43d8] Writing new cache 6c0f43d8... [hardsource:6c0f43d8] Tracking node dependencies with: package.json, node_modules/*.

Rebuild output: [hardsource:6c0f43d8] Using 100 MB of disk space. [hardsource:6c0f43d8] Tracking node dependencies with: package.json, node_modules/. [hardsource:6c0f43d8] Reading from cache 6c0f43d8... [hardsource:6c0f43d8] Cache is corrupted. TypeError: Cannot read property 'concat' of undefined at _loaders.thaw.map.loader (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\lib\util\serial.js:78:58) at Array.map () at Object.thaw (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\lib\util\serial.js:69:55) at Object.thaw (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\lib\util\serial.js:171:28) at contextNormalModuleResolve (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\lib\CacheModuleResolver.js:202:38) at Object.keys.forEach.key (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\index.js:342:29) at Array.forEach () at source (D:\Perforce_CXWeb\CallXpress\CX_Next\CXWeb\NodeJS\node_modules\hard-source-webpack-plugin\index.js:341:33) at at process._tickDomainCallback (internal/process/next_tick.js:228:7) [hardsource:6c0f43d8] Last compilation did not finish saving. Building new cache.*

Looking at the source:

const RuleSet = require('webpack/lib/RuleSet');
            ruleSet = extra.compiler.__hardSource_ruleSet = new RuleSet(
              extra.compiler.options.module.defaultRules.concat(
                extra.compiler.options.module.rules,
              ),
            );

defaultRules - Undefined?

Steps to Reproduce

  • My env. was using webpack v3.10.0 hard-source-webpack-plugin v0.11.0
  • In previous version i.e. v0.6.4 No such error was reported.

Operating System, Node, and NPM dependency versions

Win 10 - x64
Node 8.11.2

"dependencies": {
    "@angular/animations": "4.4.6",
    "@angular/common": "4.4.6",
    "@angular/core": "4.4.6",
    "@angular/forms": "4.4.6",
    "@angular/http": "4.4.6",
    "@angular/platform-browser": "4.4.6",
    "@angular/platform-browser-dynamic": "4.4.6",
    "@angular/platform-server": "4.4.6",
    "@angular/router": "4.4.6",
    "@ngx-translate/core": "7.0.0",
    "@uirouter/angular": "1.0.1",
    "angular-2-local-storage": "1.0.1",
    "angular-in-memory-web-api": "0.3.1",
    "app-module-path": "1.0.6",
    "body-parser": "1.13.2",
    "change-case": "2.3.1",
    "compression": "1.6.2",
    "core-js": "2.5.1",
    "crc": "3.5.0",
    "express": "4.16.3",
    "express-session": "1.15.6",
    "express-winston": "2.5.1",
    "helmet": "3.9.0",
    "jsonwebtoken": "8.1.1",
    "lodash": "4.17.10",
    "merge": "1.2.0",
    "morgan": "1.6.1",
    "nconf": "0.10.0",
    "ngx-bootstrap": "1.7.1",
    "ngx-cookie-service": "1.0.9",
    "node-cache": "4.1.0",
    "reflect-metadata": "0.1.10",
    "request": "2.87.0",
    "request-promise-native": "1.0.5",
    "rxjs": "5.5.11",
    "sax": "1.2.1",
    "session-file-store": "1.2.0",
    "uid-safe": "2.1.5",
    "uuid": "3.1.0",
    "winston": "2.4.0",
    "winston-daily-rotate-file": "1.7.2",
    "xmldom": "0.1.22",
    "yargs": "4.7.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@angular/compiler": "4.4.6",
    "@angular/compiler-cli": "4.4.6",
    "@types/body-parser": "1.16.8",
    "@types/chai": "4.1.2",
    "@types/chai-as-promised": "7.1.0",
    "@types/chai-spies": "0.0.0",
    "@types/chai-subset": "1.3.1",
    "@types/compression": "0.0.35",
    "@types/crc": "3.4.0",
    "@types/expect": "1.20.3",
    "@types/express": "4.11.1",
    "@types/express-session": "1.15.8",
    "@types/express-winston": "2.4.3",
    "@types/handlebars": "4.0.36",
    "@types/helmet": "0.0.37",
    "@types/jasmine": "2.8.6",
    "@types/jasminewd2": "2.0.3",
    "@types/jsonwebtoken": "7.2.5",
    "@types/lodash": "4.14.108",
    "@types/mocha": "5.0.0",
    "@types/nconf": "0.0.37",
    "@types/node": "9.4.2",
    "@types/request": "2.47.0",
    "@types/request-promise-native": "1.0.14",
    "@types/sax": "1.0.0",
    "@types/session-file-store": "1.2.0",
    "@types/uuid": "3.4.3",
    "@types/uid-safe": "2.1.1",
    "@types/winston": "2.3.8",
    "@types/xmldom": "0.1.29",
    "@types/yargs": "11.0.0",
    "angular-mocks": "1.6.1",
    "angular2-template-loader": "0.6.2",
    "awesome-typescript-loader": "4.0.1",
    "chai": "3.5.0",
    "chai-as-promised": "7.1.1",
    "chai-spies": "0.7.1",
    "chai-subset": "1.6.0",
    "commander": "2.9.0",
    "css-loader": "0.28.7",
    "del": "2.2.0",
    "expect": "1.20.2",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.5",
    "find-in-files": "0.4.0",
    "glob": "7.0.6",
    "gulp": "3.9.1",
    "gulp-batch": "1.0.5",
    "gulp-chmod": "2.0.0",
    "gulp-concat": "2.6.0",
    "gulp-data": "1.2.1",
    "gulp-ejs": "3.1.3",
    "gulp-env": "0.4.0",
    "gulp-htmlhint": "2.1.0",
    "gulp-if": "2.0.0",
    "gulp-ignore": "2.0.2",
    "gulp-jshint": "2.1.0",
    "gulp-jshint-checkstyle-reporter": "1.1.0",
    "gulp-merge-json": "0.4.0",
    "gulp-mocha": "5.0.0",
    "gulp-ng-constant": "1.1.0",
    "gulp-preprocess": "2.0.0",
    "gulp-protractor": "4.1.0",
    "gulp-rename": "1.2.2",
    "gulp-rev-all": "0.8.24",
    "gulp-sass": "3.1.0",
    "gulp-sourcemaps": "2.6.1",
    "gulp-stylelint": "7.0.0",
    "gulp-tap": "0.1.3",
    "gulp-tslint": "8.1.3",
    "gulp-tslint-jenkins-reporter": "1.1.1",
    "gulp-typescript": "4.0.2",
    "gulp-uglify": "3.0.0",
    "gulp-watch": "5.0.0",
    "gulp-webserver": "0.9.1",
    "gulp-zip": "4.0.0",
    "handlebars": "4.0.5",
    "hard-source-webpack-plugin": "0.11.0",
    "html-webpack-plugin": "2.30.1",
    "htmlhint-stylish": "1.0.3",
    "jasmine": "3.0.0",
    "jasmine-reporters": "2.3.0",
    "jasmine-spec-reporter": "4.2.1",
    "jshint": "2.9.5",
    "jshint-stylish": "2.2.1",
    "karma": "2.0.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-jasmine": "1.1.1",
    "karma-junit-reporter": "1.2.0",
    "karma-ng-html2js-preprocessor": "1.0.0",
    "karma-sourcemap-loader": "0.3.7",
    "karma-webpack": "2.0.9",
    "kss": "3.0.0-beta.18",
    "michelangelo": "0.6.1",
    "mocha": "5.0.5",
    "mocha-jenkins-reporter": "0.3.10",
    "mocha-junit-reporter": "1.17.0",
    "nock": "9.0.2",
    "node-mocks-http": "1.6.7",
    "node-sass": "4.7.2",
    "nodemon": "1.11.0",
    "preprocess-loader": "0.2.2",
    "protractor": "5.3.0",
    "protractor-jasmine2-screenshot-reporter": "0.5.0",
    "q": "1.4.1",
    "raw-loader": "0.5.1",
    "recursive-readdir-sync": "1.0.6",
    "run-sequence": "2.2.1",
    "sass-import-resolve": "1.0.9",
    "sass-loader": "6.0.6",
    "shelljs": "0.6.0",
    "source-map-loader": "0.2.3",
    "string-replace-loader": "2.1.1",
    "stylelint-checkstyle-formatter": "0.1.1",
    "stylelint-config-standard": "18.2.0",
    "stylelint-order": "0.8.1",
    "stylelint-scss": "3.1.0",
    "stylelint-selector-bem-pattern": "2.0.0",
    "through2": "2.0.1",
    "to-string-loader": "1.1.5",
    "tslint": "5.10.0",
    "typescript": "2.9.1",
    "uglify-es": "3.3.9",
    "uglifyjs-webpack-plugin": "1.0.0-beta.3",
    "url-loader": "0.6.2",
    "vinyl": "1.1.1",
    "vinyl-named-with-path": "1.0.0",
    "wd": "1.5.0",
    "wd-bridge": "0.0.2",
    "webpack": "3.10.0",
    "webpack-merge": "4.1.0",
    "webpack-stream": "4.0.0",
    "material-design-icons": "3.0.1",
    "source-sans-pro": "git://github.com/adobe-fonts/source-sans-pro.git#release",
    "http-proxy-middleware": "0.18.0"
  }
mzgoddard commented 6 years ago

@gauravmahto Thank you for opening this issue. I accounted for webpack 4 and forgot to account for webpack 3 RuleSet creation in serializing Module resolutions.

gauravmahto commented 6 years ago

@mzgoddard Thank you for such a great plugin. I tested the latest v0.11.1 and it's working like a charm. 👍