title: Angular build: Cannot read property 'split' of undefined
body: <p>just upgraded from ng8 to ng11.
  when I run ng serve it works fine, but when I run build for production I get the following error:</p>
  <blockquote>
  <p>Generating ES5 bundles for differential loading...
  An unhandled exception occurred: C:\P.....\src\app\9-es2015.dce42a686e45767441f2.js: Cannot read property 'split' of undefined</p>
  </blockquote>
  <p>I tried removing code to see what is causing the issue and I found the following code in my component, I change the enum to a hardcoded number it works, or if I remove the console.log.
  it seems it's an issue with es2015, changing to es5 solves it.</p>
  <pre><code>import {FormTableData} from '../../../form/service/type/form-table-data';
  import {FormFieldTypes} from '../../../form/service/type/form-field-types.enum';
  
  export class FormEditorFormData {
  
    formData: FormTableData;
    fieldType = FormFieldTypes;
    arr: string[];
  
  
    constructor(n: number,s:string) {
      let type = 0;
      const option: string[] = [];
      for (const s of this.arr) {
        if (s != null) {
          switch (type) {
            case FormFieldTypes.checkbox:
              const cap = 'pp';
              option.forEach( (currentValue) =&gt; {
                console.log(cap);
              });
              break;
          }
        }
      }
    }
  }
  </code></pre>
  <p>FormFieldTypes:</p>
  <pre><code> export enum FormFieldTypes {
    text = 10,
    checkbox = 20,
    numeric = 30,
    option = 40,
    date = 50,
    combo = 60,
    xiny = 70,
    file = 80,
    picture = 90,
    break = 100,
    textArea = 110,
    actionButton = 998,
    none = 999
  }
  </code></pre>
  <p>error log:</p>
  <pre><code>[error] TypeError: C:\Projects\Venditio\admin-client\src\app\9-es2015.8205fce0935da26db9bb.js: Cannot read property 'split' of undefined
      at NodePath.get (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\path\family.js:185:21)
      at BlockScoping.wrapClosure (C:\Projects\Venditio\admin-client\node_modules\@babel\plugin-transform-block-scoping\lib\index.js:534:29)
      at BlockScoping.run (C:\Projects\Venditio\admin-client\node_modules\@babel\plugin-transform-block-scoping\lib\index.js:360:12)
      at PluginPass.BlockStatement|SwitchStatement|Program (C:\Projects\Venditio\admin-client\node_modules\@babel\plugin-transform-block-scoping\lib\index.js:89:24)
      at newFn (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\visitors.js:175:21)
      at NodePath._call (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\path\context.js:55:20)
      at NodePath.call (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\path\context.js:42:17)
      at NodePath.visit (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\path\context.js:92:31)
      at TraversalContext.visitQueue (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:116:16)
      at TraversalContext.visitSingle (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:85:19)
      at TraversalContext.visit (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:144:19)
      at Function.traverse.node (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\index.js:82:17)
      at NodePath.visit (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\path\context.js:99:18)
      at TraversalContext.visitQueue (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:116:16)
      at TraversalContext.visitMultiple (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:80:17)
      at TraversalContext.visit (C:\Projects\Venditio\admin-client\node_modules\@babel\traverse\lib\context.js:142:19)
  </code></pre>
  <p>angular.json:</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;primer&quot;: {
        &quot;projectType&quot;: &quot;application&quot;,
        &quot;schematics&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/primer&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;src/tsconfig.app.json&quot;,
              &quot;aot&quot;: true,
              &quot;assets&quot;: [
                &quot;src/favicon.ico&quot;,
                &quot;src/assets&quot;
              ],
              &quot;styles&quot;: [
               ],
              &quot;scripts&quot;: []
            },
            &quot;configurations&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;maximumError&quot;: &quot;10kb&quot;
                  }
                ]
              }
            }
          },
          &quot;serve&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;primer:build&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;browserTarget&quot;: &quot;primer: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;primer: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;src/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;styles&quot;: [
                &quot;src/styles.css&quot;
              ],
              &quot;scripts&quot;: []
            }
          },
          &quot;lint&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: [
                &quot;src/tsconfig.app.json&quot;,
                &quot;src/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;primer:serve&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;devServerTarget&quot;: &quot;primer:serve:production&quot;
              }
            }
          }
        }
      }
    },
    &quot;defaultProject&quot;: &quot;primer&quot;
  }
  </code></pre>
  <p>tsconfig:</p>
  <pre><code>{
    &quot;compileOnSave&quot;: false,
    &quot;compilerOptions&quot;: {
      &quot;baseUrl&quot;: &quot;./&quot;,
      &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
      &quot;sourceMap&quot;: true,
      &quot;declaration&quot;: false,
      &quot;downlevelIteration&quot;: true,
      &quot;experimentalDecorators&quot;: true,
      &quot;moduleResolution&quot;: &quot;node&quot;,
      &quot;importHelpers&quot;: true,
      &quot;target&quot;: &quot;es2015&quot;,
      &quot;module&quot;: &quot;es2020&quot;,
      &quot;lib&quot;: [
        &quot;es2018&quot;,
        &quot;dom&quot;
      ]
    }
  }
  </code></pre>
  <p>package,json:</p>
  <pre><code>{
    &quot;name&quot;: &quot;primer&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;ng serve&quot;,
      &quot;build&quot;: &quot;ng build --base-href / --deploy-url /venditio-client/ --prod&quot;,
      &quot;build-qa-prod&quot;: &quot;node --max_old_space_size=2048  ./node_modules/.bin/ng build --prod --configuration=qa --base-href / --deploy-url /&quot;,
      &quot;build-qa&quot;: &quot;ng build --configuration=qa --base-href / --deploy-url /venditio-client/ --prod&quot;,
      &quot;test&quot;: &quot;ng test&quot;,
      &quot;lint&quot;: &quot;ng lint&quot;,
      &quot;e2e&quot;: &quot;ng e2e&quot;
    },
    &quot;private&quot;: true,
    &quot;dependencies&quot;: {
      &quot;@angular/animations&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/cdk&quot;: &quot;^11.2.5&quot;,
      &quot;@angular/common&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/compiler&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/core&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/flex-layout&quot;: &quot;^11.0.0-beta.33&quot;,
      &quot;@angular/forms&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/material&quot;: &quot;11.2.5&quot;,
      &quot;@angular/platform-browser&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/platform-browser-dynamic&quot;: &quot;~11.2.6&quot;,
      &quot;@angular/router&quot;: &quot;~11.2.6&quot;,
      &quot;@asymmetrik/ngx-leaflet&quot;: &quot;6.0.1&quot;,
      &quot;@fullcalendar/core&quot;: &quot;^4.3.1&quot;,
      &quot;@ngx-loading-bar/core&quot;: &quot;^4.2.0&quot;,
      &quot;@ngx-loading-bar/router&quot;: &quot;4.2.0&quot;,
      &quot;@ngx-translate/core&quot;: &quot;11.0.1&quot;,
      &quot;@ngx-translate/http-loader&quot;: &quot;4.0.0&quot;,
      &quot;@swimlane/ngx-datatable&quot;: &quot;19.0.0&quot;,
      &quot;angular-calendar&quot;: &quot;0.27.18&quot;,
      &quot;angular-tree-component&quot;: &quot;8.4.0&quot;,
      &quot;chart.js&quot;: &quot;^2.9.4&quot;,
      &quot;core-js&quot;: &quot;^2.6.12&quot;,
      &quot;d3&quot;: &quot;5.12.0&quot;,
      &quot;font-awesome&quot;: &quot;^4.7.0&quot;,
      &quot;intl&quot;: &quot;1.2.5&quot;,
      &quot;leaflet&quot;: &quot;1.5.1&quot;,
      &quot;moment&quot;: &quot;2.24.0&quot;,
      &quot;ng-block-ui&quot;: &quot;^3.0.2&quot;,
      &quot;ng2-charts&quot;: &quot;^2.4.2&quot;,
      &quot;ng2-dragula&quot;: &quot;2.1.1&quot;,
      &quot;ng2-file-upload&quot;: &quot;1.3.0&quot;,
      &quot;ng2-validation&quot;: &quot;4.2.0&quot;,
      &quot;ngx-material-timepicker&quot;: &quot;^5.5.3&quot;,
      &quot;ngx-perfect-scrollbar&quot;: &quot;8.0.0&quot;,
      &quot;ngx-toastr&quot;: &quot;^13.2.1&quot;,
      &quot;primeflex&quot;: &quot;^1.3.0&quot;,
      &quot;primeicons&quot;: &quot;^2.0.0&quot;,
      &quot;primeng&quot;: &quot;^11.3.1&quot;,
      &quot;quill&quot;: &quot;^1.3.7&quot;,
      &quot;rxjs&quot;: &quot;~6.6.0&quot;,
      &quot;screenfull&quot;: &quot;5.0.0&quot;,
      &quot;sweetalert2&quot;: &quot;^10.15.6&quot;,
      &quot;tslib&quot;: &quot;^2.0.0&quot;,
      &quot;zone.js&quot;: &quot;~0.10.2&quot;,
      &quot;rxjs-compat&quot;: &quot;^6.6.6&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@angular-devkit/build-angular&quot;: &quot;^0.1102.5&quot;,
      &quot;@angular/cli&quot;: &quot;^11.2.5&quot;,
      &quot;@angular/compiler-cli&quot;: &quot;11.2.6&quot;,
      &quot;@angular/language-service&quot;: &quot;11.2.6&quot;,
      &quot;@types/jasmine&quot;: &quot;^3.6.7&quot;,
      &quot;@types/jasminewd2&quot;: &quot;^2.0.6&quot;,
      &quot;@types/node&quot;: &quot;^12.20.5&quot;,
      &quot;codelyzer&quot;: &quot;^6.0.0&quot;,
      &quot;jasmine-core&quot;: &quot;~3.6.0&quot;,
      &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
      &quot;karma&quot;: &quot;~6.2.0&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.2&quot;,
      &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
      &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
      &quot;protractor&quot;: &quot;~7.0.0&quot;,
      &quot;ts-node&quot;: &quot;~8.3.0&quot;,
      &quot;tslint&quot;: &quot;~6.1.0&quot;,
      &quot;typescript&quot;: &quot;~4.0.2&quot;
    }
  }
  </code></pre>