title: "Unexpected token: punc ())" when building for production
body: <p>If I try to test-build my application with <code>ng build --prod --aot</code> I get the following, quite short, error message:</p>
  <pre><code>$ ng build --prod
                                                                                           
  Date: 2019-01-26T17:26:45.018Z
  Hash: 979690c7a363996f24b8
  Time: 28274ms
  chunk {0} runtime.ea8176a0aa687d0c7546.js (runtime) 2.23 kB [entry] [rendered]
  chunk {1} common.78f3e0cd7d0f774768aa.js (common) 583 bytes  [rendered]
  chunk {2} main.5f97cda0f273b510e26a.js (main) 973 kB [initial] [rendered]
  chunk {3} polyfills.c2a7344c1c84ba3d2a73.js (polyfills) 58.2 kB [initial] [rendered]
  chunk {4} styles.1094b1dd78a0fa2c8fa7.css (styles) 85 kB [initial] [rendered]
  chunk {5} 5.92565e561816566c4426.js () 3.74 MB  [rendered]
  chunk {6} 6.a4ec6e690b75a22ddb72.js () 6.3 kB  [rendered]
  
  ERROR in 5.92565e561816566c4426.js from Terser
  Unexpected token: punc ()) [5.92565e561816566c4426.js:25865,4]
  </code></pre>
  <p>No idea what's causing this. How can I fix this? Last time I checked this worked.</p>
  <p>I have already tried <code>rm -rf node_modules/</code>.</p>
  <hr />
  <p><strong>package.json</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;name&quot;: &quot;mz-admin&quot;,
    &quot;version&quot;: &quot;0.0.0&quot;,
    &quot;license&quot;: &quot;MIT&quot;,
    &quot;scripts&quot;: {
      &quot;ng&quot;: &quot;ng&quot;,
      &quot;start&quot;: &quot;node server.js&quot;,
      &quot;build&quot;: &quot;ng build --prod&quot;,
      &quot;test&quot;: &quot;ng test&quot;,
      &quot;lint&quot;: &quot;ng lint&quot;,
      &quot;e2e&quot;: &quot;ng e2e&quot;
    },
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;8.12.0&quot;,
      &quot;npm&quot;: &quot;6.4.1&quot;
    },
    &quot;private&quot;: true,
    &quot;dependencies&quot;: {
      &quot;@agm/core&quot;: &quot;^1.0.0-beta.3&quot;,
      &quot;@angular/animations&quot;: &quot;7.1.0&quot;,
      &quot;@angular/cdk&quot;: &quot;^7.1.0&quot;,
      &quot;@angular/cli&quot;: &quot;7.0.6&quot;,
      &quot;@angular/common&quot;: &quot;7.1.0&quot;,
      &quot;@angular/compiler&quot;: &quot;7.1.0&quot;,
      &quot;@angular/compiler-cli&quot;: &quot;7.1.0&quot;,
      &quot;@angular/core&quot;: &quot;7.1.0&quot;,
      &quot;@angular/flex-layout&quot;: &quot;^7.0.0-beta.19&quot;,
      &quot;@angular/forms&quot;: &quot;7.1.0&quot;,
      &quot;@angular/http&quot;: &quot;7.1.0&quot;,
      &quot;@angular/material&quot;: &quot;^7.1.0&quot;,
      &quot;@angular/material-moment-adapter&quot;: &quot;^7.1.0&quot;,
      &quot;@angular/platform-browser&quot;: &quot;7.1.0&quot;,
      &quot;@angular/platform-browser-dynamic&quot;: &quot;7.1.0&quot;,
      &quot;@angular/router&quot;: &quot;7.1.0&quot;,
      &quot;@fortawesome/angular-fontawesome&quot;: &quot;^0.3.0&quot;,
      &quot;@fortawesome/fontawesome-svg-core&quot;: &quot;^1.2.4&quot;,
      &quot;@fortawesome/free-brands-svg-icons&quot;: &quot;^5.3.1&quot;,
      &quot;@fortawesome/free-solid-svg-icons&quot;: &quot;^5.3.1&quot;,
      &quot;@ngx-share/button&quot;: &quot;^7.0.0&quot;,
      &quot;@ngx-share/core&quot;: &quot;^7.0.0&quot;,
      &quot;@types/braintree-web&quot;: &quot;^3.6.4&quot;,
      &quot;angular-mentions&quot;: &quot;^0.8.0&quot;,
      &quot;braintree-web&quot;: &quot;^3.41.0&quot;,
      &quot;braintree-web-drop-in&quot;: &quot;^1.14.1&quot;,
      &quot;chart.js&quot;: &quot;^2.7.2&quot;,
      &quot;core-js&quot;: &quot;^2.5.7&quot;,
      &quot;express&quot;: &quot;^4.16.3&quot;,
      &quot;http-status-codes&quot;: &quot;^1.3.0&quot;,
      &quot;ng-pick-datetime&quot;: &quot;^7.0.0&quot;,
      &quot;ngx-logger&quot;: &quot;^3.1.0&quot;,
      &quot;ngx-moment&quot;: &quot;^3.1.0&quot;,
      &quot;ngx-quill&quot;: &quot;^4.5.0&quot;,
      &quot;paypal-checkout&quot;: &quot;^4.0.239&quot;,
      &quot;quill&quot;: &quot;^1.3.6&quot;,
      &quot;quill-mention&quot;: &quot;git+https://github.com/silentsnooc/quill-mention.git&quot;,
      &quot;rxjs&quot;: &quot;^6.3.2&quot;,
      &quot;typescript&quot;: &quot;^3.1.6&quot;,
      &quot;zone.js&quot;: &quot;^0.8.26&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@angular-devkit/build-angular&quot;: &quot;^0.10.6&quot;,
      &quot;@angular/language-service&quot;: &quot;7.1.0&quot;,
      &quot;@types/googlemaps&quot;: &quot;^3.30.16&quot;,
      &quot;@types/jasmine&quot;: &quot;^3.3.0&quot;,
      &quot;@types/jasminewd2&quot;: &quot;^2.0.6&quot;,
      &quot;@types/node&quot;: &quot;~10.12.10&quot;,
      &quot;codelyzer&quot;: &quot;^4.5.0&quot;,
      &quot;enhanced-resolve&quot;: &quot;^4.1.0&quot;,
      &quot;express-http-proxy&quot;: &quot;^1.5.0&quot;,
      &quot;jasmine-core&quot;: &quot;~3.3.0&quot;,
      &quot;jasmine-spec-reporter&quot;: &quot;~4.2.1&quot;,
      &quot;karma&quot;: &quot;~3.1.1&quot;,
      &quot;karma-chrome-launcher&quot;: &quot;~2.2.0&quot;,
      &quot;karma-coverage-istanbul-reporter&quot;: &quot;^2.0.4&quot;,
      &quot;karma-jasmine&quot;: &quot;~2.0.1&quot;,
      &quot;karma-jasmine-html-reporter&quot;: &quot;^1.4.0&quot;,
      &quot;protractor&quot;: &quot;^5.4.1&quot;,
      &quot;ts-node&quot;: &quot;~7.0.1&quot;,
      &quot;tslint&quot;: &quot;^5.11.0&quot;,
      &quot;webpack-bundle-analyzer&quot;: &quot;^3.0.3&quot;
    }
  }
  </code></pre>
  <p><strong>Part of the build log</strong></p>
  <pre><code>[1m[33mWARNING in Terser Plugin: Dropping unused variable template [6.a4ec6e690b75a22ddb72.js:136,12][39m[22m
  
  [1m[33mWARNING in Terser Plugin: Dropping unused variable routes [6.a4ec6e690b75a22ddb72.js:148,4][39m[22m
  
  [1m[31mERROR in 5.92565e561816566c4426.js from Terser
  Unexpected token: punc ()) [5.92565e561816566c4426.js:25865,4][39m[22m
  Child [1mmini-css-extract-plugin node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!node_modules/postcss-loader/src/index.js??extracted!node_modules/sass-loader/lib/loader.js??ref--14-3!src/styles.scss[39m[22m:
                     [1mAsset[39m[22m     [1mSize[39m[22m  [1mChunks[39m[22m  [1m[39m[22m[1m[39m[22m[1mChunk Names[39m[22m
      [1m[32m3rdpartylicenses.txt[39m[22m  1 bytes        [1m[39m[22m  [1m[32m[39m[22m
      Entrypoint [1mmini-css-extract-plugin[39m[22m = [1m[32m*[39m[22m
      chunk    {[1m[33m0[39m[22m} [1m[32m*[39m[22m (mini-css-extract-plugin) 102 KiB[1m[33m [entry][39m[22m[1m[32m [rendered][39m[22m
  Child [1mmini-css-extract-plugin node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!node_modules/postcss-loader/src/index.js??extracted!node_modules/sass-loader/lib/loader.js??ref--14-3!src/theme.scss[39m[22m:
                     [1mAsset[39m[22m     [1mSize[39m[22m  [1mChunks[39m[22m  [1m[39m[22m[1m[39m[22m[1mChunk Names[39m[22m
      [1m[32m3rdpartylicenses.txt[39m[22m  1 bytes        [1m[39m[22m  [1m[32m[39m[22m
      Entrypoint [1mmini-css-extract-plugin[39m[22m = [1m[32m*[39m[22m
      chunk    {[1m[33m0[39m[22m} [1m[32m*[39m[22m (mini-css-extract-plugin) 55.6 KiB[1m[33m [entry][39m[22m[1m[32m [rendered][39m[22m
  
  WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:14309,21]
  
  WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:14510,25]
  
  WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:15652,21]
  
  WARNING in Terser Plugin: global_defs ngDevMode redefined [main.5f97cda0f273b510e26a.js:15658,21]
  </code></pre>
  <hr />
  <p>With <code>--source-map</code></p>
  <pre><code>$ ng build --prod --aot --source-map 
                                                                                                                 
  Date: 2019-01-26T22:31:44.106Z
  Hash: 51afc4cc158a10e520c6
  Time: 45390ms
  chunk {0} runtime.b29d49d6f279fff34f57.js, runtime.b29d49d6f279fff34f57.js.map (runtime) 2.29 kB [entry] [rendered]
  chunk {1} common.70409de1782336a79716.js, common.70409de1782336a79716.js.map (common) 639 bytes  [rendered]
  chunk {2} main.01e8ea6a2dd33c4e19d8.js, main.01e8ea6a2dd33c4e19d8.js.map (main) 970 kB [initial] [rendered]
  chunk {3} polyfills.22294cd4941de9604b91.js, polyfills.22294cd4941de9604b91.js.map (polyfills) 61.7 kB [initial] [rendered]
  chunk {4} styles.97ca4c55e9ba593fdf4c.css, styles.97ca4c55e9ba593fdf4c.css.map (styles) 85.5 kB [initial] [rendered]
  chunk {5} 5.33da963a3dd6decc5efc.js, 5.33da963a3dd6decc5efc.js.map () 1.9 MB  [rendered]
  chunk {6} 6.85bd192b02e86745d878.js, 6.85bd192b02e86745d878.js.map () 6.35 kB  [rendered]
  </code></pre>
  <p>Without <code>--source-map</code></p>
  <pre><code>$ ng build --prod --aot 
                                                                                           
  Date: 2019-01-26T22:32:18.173Z
  Hash: b5bcaa2123bb6718baf2
  Time: 28403ms
  chunk {0} runtime.0935b498984fda7c2e4f.js (runtime) 2.23 kB [entry] [rendered]
  chunk {1} common.78f3e0cd7d0f774768aa.js (common) 583 bytes  [rendered]
  chunk {2} main.2ae834dcaf8208d7aecd.js (main) 970 kB [initial] [rendered]
  chunk {3} polyfills.588b345e325a2549098e.js (polyfills) 61.7 kB [initial] [rendered]
  chunk {4} styles.088d5b7a7a0995d1df55.css (styles) 85.4 kB [initial] [rendered]
  chunk {5} 5.7e99fa00323b77c4e1c2.js () 3.82 MB  [rendered]
  chunk {6} 6.954a4978d0c6c411bb2f.js () 6.3 kB  [rendered]
  
  ERROR in 5.7e99fa00323b77c4e1c2.js from Terser
  Unexpected token: punc ()) [5.7e99fa00323b77c4e1c2.js:27338,4]
  </code></pre>
  <p>With <code>--source-map --named-chunks</code></p>
  <pre><code>$ ng build --prod --source-map --named-chunks
                                                                                                                          
  Date: 2019-01-26T23:00:18.699Z
  Hash: c37b8f2ccfedbbf077fa
  Time: 61888ms
  chunk {0} runtime.a670ad696846ba781d64.js, runtime.a670ad696846ba781d64.js.map (runtime) 2.37 kB [entry] [rendered]
  chunk {1} common.d7fbf062c6d87ac4ade2.js, common.d7fbf062c6d87ac4ade2.js.map (common) 639 bytes  [rendered]
  chunk {2} component-application-application-module-ngfactory.22de247f215039a3cf63.js, component-application-application-module-ngfactory.22de247f215039a3cf63.js.map (component-application-application-module-ngfactory) 1.9 MB  [rendered]
  chunk {3} main.2897da054822ebda9646.js, main.2897da054822ebda9646.js.map (main) 973 kB [initial] [rendered]
  chunk {4} module-embedding-calendar-calendar-module-ngfactory.5b0025d2f887a5d7b22d.js, module-embedding-calendar-calendar-module-ngfactory.5b0025d2f887a5d7b22d.js.map (module-embedding-calendar-calendar-module-ngfactory) 6.4 kB  [rendered]
  chunk {5} polyfills.04ae14cfab6dbb09ad49.js, polyfills.04ae14cfab6dbb09ad49.js.map (polyfills) 61.7 kB [initial] [rendered]
  chunk {6} styles.52c1571339895f2464fa.css, styles.52c1571339895f2464fa.css.map (styles) 85.5 kB [initial] [rendered]
  </code></pre>
  <p>It seems that</p>
  <pre><code>ng build --prod --named-chunks --verbose --build-optimizer=false --source-map
  </code></pre>
  <p>finally does the trick - with this, I am finally getting the source of the error:</p>
  <pre><code>ERROR in component-application-application-module-ngfactory.7eb30a010bb7783ce652.js from Terser
  Unexpected token: punc ()) [./node_modules/quill-mention/src/quill.mention.js:183,0][component-application-application-module-ngfactory.7eb30a010bb7783ce652.js:29528,4]
  </code></pre>