title: The 'compilation' argument must be an instance of Compilation
body: <p>Been getting this error when running 'ng build' on my Angular 12.0.2 project</p>
  <pre><code>./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
  TypeError: The 'compilation' argument must be an instance of Compilation
      at getCompilationHooks (D:\Dev\Git_Merc\mercury\node_modules\webpack\lib\javascript\JavascriptModulesPlugin.js:125:10)
      at D:\Dev\Git_Merc\mercury\node_modules\webpack\lib\javascript\CommonJsChunkFormatPlugin.js:43:19
      at Hook.eval [as call] (eval at create (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\HookCodeFactory.js:19:10), &lt;anonymous&gt;:7:1)
      at Hook.CALL_DELEGATE [as _call] (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\Hook.js:14:14)
      at Compiler.newCompilation (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1030:30)
      at D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1073:29
      at Hook.eval [as callAsync] (eval at create (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\HookCodeFactory.js:33:10), &lt;anonymous&gt;:15:1)
      at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\Hook.js:18:14)
      at Compiler.compile (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1068:28)
      at Compiler.runAsChild (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:520:8)
  </code></pre>
  <p>I've been googling around but can't find anything that solves my issue.  I'm not sure what's triggering this.</p>
  <p>Versions:</p>
  <pre><code>Angular CLI: 12.0.2
  Node: 14.17.0
  Package Manager: npm 7.14.0
  OS: win32 x64
  
  Angular: 12.0.1
  ... animations, common, compiler, compiler-cli, core, forms
  ... language-service, platform-browser, platform-browser-dynamic
  ... router
  
  Package                           Version
  -----------------------------------------------------------
  @angular-devkit/architect         0.1200.2
  @angular-devkit/build-angular     12.0.2
  @angular-devkit/build-optimizer   0.1200.2
  @angular-devkit/core              12.0.2
  @angular-devkit/schematics        12.0.2
  @angular/cli                      12.0.2
  @schematics/angular               12.0.2
  ng-packagr                        12.0.2
  rxjs                              7.1.0
  typescript                        4.2.4
  webpack                           5.38.0
  </code></pre>
  <hr />
  <h2>Update 1 - adding requested information from @Heretic Monkey</h2>
  <p>The command I'm running is <code>ng build</code>.</p>
  <p>My <code>angular.json</code> is as follows:</p>
  <pre><code>{
    &quot;$schema&quot;: &quot;./node_modules/@angular/cli/lib/config/schema.json&quot;,
    &quot;version&quot;: 1,
    &quot;newProjectRoot&quot;: &quot;projects&quot;,
    &quot;projects&quot;: {
      &quot;Agent-Angular&quot;: {
        &quot;projectType&quot;: &quot;application&quot;,
        &quot;schematics&quot;: {
          &quot;@schematics/angular:component&quot;: {
            &quot;style&quot;: &quot;scss&quot;
          }
        },
        &quot;root&quot;: &quot;&quot;,
        &quot;sourceRoot&quot;: &quot;src&quot;,
        &quot;prefix&quot;: &quot;app&quot;,
        &quot;architect&quot;: {
          &quot;build&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:browser&quot;,
            &quot;options&quot;: {
              &quot;outputPath&quot;: &quot;dist/Agent-Angular&quot;,
              &quot;index&quot;: &quot;src/index.html&quot;,
              &quot;main&quot;: &quot;src/main.ts&quot;,
              &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
              &quot;tsConfig&quot;: &quot;tsconfig.app.json&quot;,
              &quot;assets&quot;: [
                &quot;src/favicon.ico&quot;,
                &quot;src/assets&quot;,
                &quot;src/web.config&quot;
              ],
              &quot;styles&quot;: [
                &quot;src/styles.scss&quot;,
                &quot;node_modules/@mercury/merc-pattern-lib/styles.scss&quot;
              ],
              &quot;scripts&quot;: [
                &quot;node_modules/popper.js/dist/umd/popper.min.js&quot;
              ],
              &quot;vendorChunk&quot;: true,
              &quot;extractLicenses&quot;: false,
              &quot;buildOptimizer&quot;: false,
              &quot;sourceMap&quot;: true,
              &quot;optimization&quot;: false,
              &quot;namedChunks&quot;: true
            },
            &quot;configurations&quot;: {
              &quot;local&quot;: {
                &quot;fileReplacements&quot;: [
                  {
                    &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
                    &quot;with&quot;: &quot;src/environments/environment.local.ts&quot;
                  }
                ]
              },
              &quot;nonprod&quot;: {
                &quot;fileReplacements&quot;: [
                  {
                    &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
                    &quot;with&quot;: &quot;src/environments/environment.nonprod.ts&quot;
                  }
                ]
              },
              &quot;production&quot;: {
                &quot;fileReplacements&quot;: [
                  {
                    &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
                    &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;
                  }
                ],
                &quot;optimization&quot;: true,
                &quot;outputHashing&quot;: &quot;all&quot;,
                &quot;sourceMap&quot;: false,
                &quot;namedChunks&quot;: false,
                &quot;extractLicenses&quot;: true,
                &quot;vendorChunk&quot;: false,
                &quot;buildOptimizer&quot;: true,
                &quot;budgets&quot;: [
                  {
                    &quot;type&quot;: &quot;initial&quot;,
                    &quot;maximumWarning&quot;: &quot;2mb&quot;,
                    &quot;maximumError&quot;: &quot;5mb&quot;
                  },
                  {
                    &quot;type&quot;: &quot;anyComponentStyle&quot;,
                    &quot;maximumWarning&quot;: &quot;6kb&quot;
                  }
                ]
              }
            }
          },
          &quot;serve&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;Agent-Angular:build&quot;
            },
            &quot;configurations&quot;: {
              &quot;local&quot;: {
                &quot;browserTarget&quot;: &quot;Agent-Angular:build:local&quot;
              },
              &quot;nonprod&quot;: {
                &quot;browserTarget&quot;: &quot;Agent-Angular:build:nonprod&quot;
              },
              &quot;production&quot;: {
                &quot;browserTarget&quot;: &quot;Agent-Angular:build:production&quot;
              }
            }
          },
          &quot;extract-i18n&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:extract-i18n&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;Agent-Angular:build&quot;
            }
          },
          &quot;test&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;,
            &quot;options&quot;: {
              &quot;main&quot;: &quot;src/test.ts&quot;,
              &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
              &quot;tsConfig&quot;: &quot;tsconfig.spec.json&quot;,
              &quot;karmaConfig&quot;: &quot;karma.conf.js&quot;,
              &quot;assets&quot;: [
                &quot;src/favicon.ico&quot;,
                &quot;src/assets&quot;,
                &quot;src/web.config&quot;
              ],
              &quot;styles&quot;: [
                &quot;src/styles.scss&quot;
              ],
              &quot;scripts&quot;: [
                &quot;node_modules/popper.js/dist/umd/popper.min.js&quot;
              ]
            }
          },
          &quot;lint&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: [
                &quot;tsconfig.app.json&quot;,
                &quot;tsconfig.spec.json&quot;,
                &quot;e2e/tsconfig.json&quot;
              ],
              &quot;exclude&quot;: [
                &quot;**/node_modules/**&quot;
              ]
            }
          },
          &quot;e2e&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:protractor&quot;,
            &quot;options&quot;: {
              &quot;protractorConfig&quot;: &quot;e2e/protractor.conf.js&quot;,
              &quot;devServerTarget&quot;: &quot;Agent-Angular:serve&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;devServerTarget&quot;: &quot;Agent-Angular:serve:production&quot;
              }
            }
          }
        }
      },
      &quot;cee-ctilib&quot;: {
        &quot;projectType&quot;: &quot;library&quot;,
        &quot;root&quot;: &quot;projects/cee-ctilib&quot;,
        &quot;sourceRoot&quot;: &quot;projects/cee-ctilib/src&quot;,
        &quot;prefix&quot;: &quot;lib&quot;,
        &quot;architect&quot;: {
          &quot;build&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:ng-packagr&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: &quot;projects/cee-ctilib/tsconfig.lib.json&quot;,
              &quot;project&quot;: &quot;projects/cee-ctilib/ng-package.json&quot;
            }
          },
          &quot;test&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;,
            &quot;options&quot;: {
              &quot;main&quot;: &quot;projects/cee-ctilib/src/test.ts&quot;,
              &quot;tsConfig&quot;: &quot;projects/cee-ctilib/tsconfig.spec.json&quot;,
              &quot;karmaConfig&quot;: &quot;projects/cee-ctilib/karma.conf.js&quot;
            }
          },
          &quot;lint&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: [
                &quot;projects/cee-ctilib/tsconfig.lib.json&quot;,
                &quot;projects/cee-ctilib/tsconfig.spec.json&quot;
              ],
              &quot;exclude&quot;: [
                &quot;**/node_modules/**&quot;
              ]
            }
          }
        }
      },
      &quot;entities&quot;: {
        &quot;projectType&quot;: &quot;library&quot;,
        &quot;root&quot;: &quot;projects/entities&quot;,
        &quot;sourceRoot&quot;: &quot;projects/entities/src&quot;,
        &quot;prefix&quot;: &quot;lib&quot;,
        &quot;architect&quot;: {
          &quot;build&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:ng-packagr&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: &quot;projects/entities/tsconfig.lib.json&quot;,
              &quot;project&quot;: &quot;projects/entities/ng-package.json&quot;
            }
          },
          &quot;test&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;,
            &quot;options&quot;: {
              &quot;main&quot;: &quot;projects/entities/src/test.ts&quot;,
              &quot;tsConfig&quot;: &quot;projects/entities/tsconfig.spec.json&quot;,
              &quot;karmaConfig&quot;: &quot;projects/entities/karma.conf.js&quot;
            }
          },
          &quot;lint&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: [
                &quot;projects/entities/tsconfig.lib.json&quot;,
                &quot;projects/entities/tsconfig.spec.json&quot;
              ],
              &quot;exclude&quot;: [
                &quot;**/node_modules/**&quot;
              ]
            }
          }
        }
      }
    },
    &quot;defaultProject&quot;: &quot;Agent-Angular&quot;,
    &quot;cli&quot;: {
      &quot;analytics&quot;: false,
      &quot;defaultCollection&quot;: &quot;@ngrx/schematics&quot;
    }
  }
  </code></pre>
  <hr />
  <h2>Update 2 - adding package.json</h2>
  <pre><code>{
    &quot;name&quot;: &quot;agent-angular&quot;,
    &quot;version&quot;: &quot;0.0.0&quot;,
    &quot;description&quot;: &quot;Mercury Chat Application&quot;,
    &quot;scripts&quot;: {
      &quot;ng&quot;: &quot;ng&quot;,
      &quot;format:src&quot;: &quot;prettier --config ./prettier.config.js --ignore-path ./.prettierignore --write \&quot;src/**/*.\&quot;{ts,js,json,scss,less,css}&quot;,
      &quot;format:projects&quot;: &quot;prettier --config ./prettier.config.js --ignore-path ./.prettierignore --write \&quot;projects/**/*.\&quot;{ts,js,json,scss,less,css}&quot;,
      &quot;format:e2e&quot;: &quot;prettier --config ./prettier.config.js --ignore-path ./.prettierignore --write \&quot;e2e/**/*.\&quot;{ts,js,json,scss,less,css}&quot;,
      &quot;format:root&quot;: &quot;prettier --config ./prettier.config.js --ignore-path ./.prettierignore --write \&quot;*.\&quot;{ts,js,json,scss,less,css}&quot;,
      &quot;format:all&quot;: &quot;npm run format:src &amp;&amp; npm run format:projects &amp;&amp; npm run format:e2e &amp;&amp; npm run format:root&quot;,
      &quot;lint&quot;: &quot;ng lint&quot;,
      &quot;e2e&quot;: &quot;ng e2e&quot;,
      &quot;start&quot;: &quot;npm run &amp;&amp; ng serve --prod&quot;,
      &quot;build&quot;: &quot;npm run &amp;&amp; ng build --prod --base-href=./&quot;,
      &quot;build:dev&quot;: &quot;npm run &amp;&amp; ng build&quot;,
      &quot;unit:test&quot;: &quot;ng test&quot;,
      &quot;unit:test:main&quot;: &quot;ng test Agent-Angular --code-coverage&quot;,
      &quot;unit:test:entities&quot;: &quot;ng test entities --code-coverage&quot;,
      &quot;unit:test:cee-ctilib&quot;: &quot;ng test cee-ctilib --code-coverage&quot;,
      &quot;unit:test:debug&quot;: &quot;ng test --browsers Chrome --watch true&quot;,
      &quot;unit:test:entities:debug&quot;: &quot;ng test entities --browsers Chrome --watch true&quot;,
      &quot;start:local&quot;: &quot;ng serve -c local --host local.mercury.comcast.net  --port 443 --ssl --ssl-key ./cert/local.mercury.comcast.net.key --ssl-cert ./cert/local.mercury.comcast.net.crt&quot;,
      &quot;start:dev&quot;: &quot;ng serve -c dev --host dev.mercury.comcast.net  --port 443 --ssl --ssl-key ./cert/localhost.key --ssl-cert ./cert/localhost.crt&quot;,
      &quot;build:cti&quot;: &quot;ng-packagr -p ./projects/cee-ctilib/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./cee-ctilib&quot;,
      &quot;build:header&quot;: &quot;ng-packagr -p ./projects/header/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./header&quot;,
      &quot;build:convo-header&quot;: &quot;ng-packagr -p ./projects/convo-header/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./convo-header&quot;,
      &quot;build:convo-details&quot;: &quot;ng-packagr -p ./projects/convo-details/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./convo-details&quot;,
      &quot;build:convo-list&quot;: &quot;ng-packagr -p ./projects/convo-list/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./convo-list&quot;,
      &quot;build:convo-window&quot;: &quot;ng-packagr -p ./projects/convo-window/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./convo-window&quot;,
      &quot;build:agent-settings&quot;: &quot;ng-packagr -p ./projects/agent-settings/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./agent-settings&quot;,
      &quot;build:entities&quot;: &quot;ng-packagr -p ./projects/entities/ng-package.json &amp;&amp; cd ./dist &amp;&amp; npm pack ./entities&quot;,
      &quot;build:all-libraries&quot;: &quot;npm run build:cti &amp;&amp; npm run build:header &amp;&amp; npm run build:convo-header &amp;&amp; npm run build:convo-details &amp;&amp; npm run build:convo-list &amp;&amp; npm run build:convo-window &amp;&amp; npm run build:agent-settings &amp;&amp; npm run build:entities&quot;,
      &quot;refreshNpmrc&quot;: &quot;vsts-npm-auth -config .npmrc&quot;,
      &quot;prepareForPr&quot;: &quot;ng lint --fix &amp;&amp; ng build --prod &amp;&amp; ng test&quot;
    },
    &quot;private&quot;: false,
    &quot;dependencies&quot;: {
      &quot;@angular/animations&quot;: &quot;12.0.1&quot;,
      &quot;@angular/common&quot;: &quot;12.0.1&quot;,
      &quot;@angular/compiler&quot;: &quot;12.0.1&quot;,
      &quot;@angular/core&quot;: &quot;12.0.1&quot;,
      &quot;@angular/forms&quot;: &quot;12.0.1&quot;,
      &quot;@angular/platform-browser&quot;: &quot;12.0.1&quot;,
      &quot;@angular/platform-browser-dynamic&quot;: &quot;12.0.1&quot;,
      &quot;@angular/router&quot;: &quot;12.0.1&quot;,
      &quot;@auth0/angular-jwt&quot;: &quot;^5.0.2&quot;,
      &quot;@azure/msal-angular&quot;: &quot;^2.0.0-beta.1&quot;,
      &quot;@azure/msal-browser&quot;: &quot;^2.12.1&quot;,
      &quot;@ctrl/ngx-emoji-mart&quot;: &quot;^5.1.0&quot;,
      &quot;@jsier/retrier&quot;: &quot;^1.2.4&quot;,
      &quot;@mercury/merc-ng-core&quot;: &quot;^5.1.0&quot;,
      &quot;@mercury/merc-pattern-lib&quot;: &quot;^2.11.0&quot;,
      &quot;@microsoft/applicationinsights-web&quot;: &quot;^2.5.11&quot;,
      &quot;@microsoft/signalr&quot;: &quot;^5.0.6&quot;,
      &quot;@ngrx/effects&quot;: &quot;^12.0.0&quot;,
      &quot;@ngrx/entity&quot;: &quot;^12.0.0&quot;,
      &quot;@ngrx/store&quot;: &quot;^12.0.0&quot;,
      &quot;angular-oauth2-oidc&quot;: &quot;^10.0.3&quot;,
      &quot;dayjs&quot;: &quot;^1.10.4&quot;,
      &quot;guid-typescript&quot;: &quot;^1.0.9&quot;,
      &quot;ngx-quill&quot;: &quot;^13.2.0&quot;,
      &quot;npm&quot;: &quot;^6.14.11&quot;,
      &quot;popper&quot;: &quot;^1.0.1&quot;,
      &quot;popper.js&quot;: &quot;1.16.0&quot;,
      &quot;quill&quot;: &quot;^1.3.7&quot;,
      &quot;quill-placeholder-module&quot;: &quot;^0.3.1&quot;,
      &quot;rxjs&quot;: &quot;^7.0.1&quot;,
      &quot;ts-retry&quot;: &quot;^2.3.1&quot;,
      &quot;tslib&quot;: &quot;^2.2.0&quot;,
      &quot;vsts-npm-auth&quot;: &quot;^0.41.0&quot;,
      &quot;zone.js&quot;: &quot;~0.11.4&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@angular-devkit/build-angular&quot;: &quot;^12.0.0&quot;,
      &quot;@angular-devkit/build-optimizer&quot;: &quot;^0.1200.0&quot;,
      &quot;@angular/cli&quot;: &quot;^12.0.1&quot;,
      &quot;@angular/compiler-cli&quot;: &quot;12.0.1&quot;,
      &quot;@angular/language-service&quot;: &quot;12.0.1&quot;,
      &quot;@ngrx/schematics&quot;: &quot;^12.0.0&quot;,
      &quot;@ngrx/store-devtools&quot;: &quot;^12.0.0&quot;,
      &quot;@types/deep-freeze&quot;: &quot;^0.1.2&quot;,
      &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
      &quot;@types/jasminewd2&quot;: &quot;2.0.8&quot;,
      &quot;@types/node&quot;: &quot;^12.11.1&quot;,
      &quot;codelyzer&quot;: &quot;^6.0.0&quot;,
      &quot;deep-freeze&quot;: &quot;^0.0.1&quot;,
      &quot;jasmine-core&quot;: &quot;~3.7.1&quot;,
      &quot;jasmine-json-test-reporter&quot;: &quot;1.0.0-beta&quot;,
      &quot;jasmine-marbles&quot;: &quot;0.6.0&quot;,
      &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
      &quot;karma&quot;: &quot;^6.3.2&quot;,
      &quot;karma-chrome-launcher&quot;: &quot;^3.1.0&quot;,
      &quot;karma-cli&quot;: &quot;^2.0.0&quot;,
      &quot;karma-coverage-istanbul-reporter&quot;: &quot;^3.0.3&quot;,
      &quot;karma-htmlfile-reporter&quot;: &quot;^0.3.8&quot;,
      &quot;karma-jasmine&quot;: &quot;^4.0.1&quot;,
      &quot;karma-jasmine-html-reporter&quot;: &quot;^1.6.0&quot;,
      &quot;karma-json-reporter&quot;: &quot;^1.2.1&quot;,
      &quot;karma-typescript-es6-transform&quot;: &quot;^5.5.1&quot;,
      &quot;karma-webpack&quot;: &quot;^5.0.0&quot;,
      &quot;mockdate&quot;: &quot;^3.0.5&quot;,
      &quot;ng-packagr&quot;: &quot;^12.0.0&quot;,
      &quot;prettier&quot;: &quot;1.18.2&quot;,
      &quot;protractor&quot;: &quot;~7.0.0&quot;,
      &quot;protractor-jasmine2-html-reporter&quot;: &quot;0.0.7&quot;,
      &quot;rxjs-marbles&quot;: &quot;^7.0.0&quot;,
      &quot;ts-node&quot;: &quot;8.4.1&quot;,
      &quot;tslint&quot;: &quot;^6.1.3&quot;,
      &quot;typescript&quot;: &quot;4.2.4&quot;,
      &quot;webpack&quot;: &quot;^5.37.1&quot;
    },
    &quot;author&quot;: &quot;Mercury Team&quot;,
    &quot;license&quot;: &quot;&quot;
  }
  </code></pre>