I am encountering an issue with my Angular application that has a .tsconfig file set to target ES6.
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"es2018.promise"
]
}
}
The Angular component in Typescript:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { DispositifsDATIRoutingModule } from './dispositifsDATI.routes';
import { SharedModule } from '../shared/shared.module';
import { DISPOSITIFS_DATI_COMPONENTS } from './index';
import { InputUtilitiesModule } from 'ng-uikit-pro-standard';
import { MaterialChipsModule, BadgeModule, IconsModule, WavesModule } from 'ng-uikit-pro-standard';
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
SharedModule,
HttpClientModule,
DispositifsDATIRoutingModule,
InputUtilitiesModule,
MaterialChipsModule,
BadgeModule,
IconsModule,
WavesModule
],
declarations: [DISPOSITIFS_DATI_COMPONENTS]
})
export class DispositifsDATIModule { }
After transpilation by webpack, it results in the following:
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DispositifsDATIModule", function() { return DispositifsDATIModule; });
This causes a runtime error:
ReferenceError: Cannot access 'DispositifsDATIModule' before initialization
I am unsure of what is causing this issue. Could it be related to how ES6 is configured in the webpack setup?
EDIT: It appears to be a known issue in Angular and/or TypeScript concerning ES2015.