0

I have upgrade by TypeScript version and the new files are getting this Object.defineProperty(exports, "__esModule", { value: true }); Is there a way I an stop this line getting created? I am getting this Uncaught ReferenceError: exports is not defined

Old File

var core_1 = require("@angular/core");
var AgentsService_1 = require("../Services/AgentsService");
var ViewManager_1 = require("./ViewManager");

New File

Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@angular/core");
const AgentsService_1 = require("../Services/AgentsService");
const ViewManager_1 = require("./ViewManager");

tsconfig.json

{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "moduleResolution": "node",
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": false,
    "sourceMap": true,
    "noResolve": false,
    "noEmitOnError": true,
    "outDir": "dist/debug"
  },
  "filesGlob": [
    "./**/*.ts",
    "!./node_modules"
  ],
  "exclude": [
    "node_modules",
    "jspm_packages",
    "typings",
    "dist",
    "typings/*",
    "typings/main.d.ts",
    "typings/main",
    "Scripts"
  ],
  "compileOnSave": true,
  "buildOnSave": true
}

enter image description here

ts Class

import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { Title }  from '@angular/platform-browser';
import { NgModule, Component, Inject, enableProdMode } from "@angular/core";
import { HttpModule } from "@angular/http";
import { BrowserModule } from "@angular/platform-browser";
import { RouterModule, Router, NavigationEnd }   from "@angular/router";
import { LocationStrategy, HashLocationStrategy, APP_BASE_HREF } from "@angular/common";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";

import { ViewManager } from "../../Bll/ViewManager";
import { GridManager } from "../../Bll/GridManager";
import { BusyIndicatorComponent } from "../../Components/BusyIndicator";

import { PaginationComponent } from "../../Components/Common/Pagination";
import { PageSize } from "../../Components/Common/PageSize";
import { GridFilter } from "../../Components/Common/GridFilter";
import { PaginatePipe } from "../../Components/Common/PaginatePipe";

import { TemplatesUpdateComponent } from "../../Components/TemplatesManagement/TemplatesUpdateComponent";
import { TemplatesUpdatePopupsComponent } from "../../Components/TemplatesManagement/TemplatesUpdatePopupsComponent";
import { HumanReadableListOfChangesReportPopup } from "../../Components/TemplatesManagement/HumanReadableListOfChangesReportPopup";
import { SelectInternalReviewersComponent } from "../../Components/Review/SelectInternalReviewersComponent";
import { SelectMdReviewersComponent } from "../../Components/Review/SelectMdReviewersComponent";

import { TemplatesDevelopmentPage } from "./Development";
import { TemplatesPublishedPage } from "./Published";
import { TemplatesArchivedPage } from "./Archived";
import { AgentTemplatesPage } from "./AgentTemplates";

import { ServiceResponseWrapper } from "../../Services/ServiceResponseWrapper";
import { TemplatesManagementService } from "../../Services/TemplatesManagementService";
import { TemplateService } from "../../Services/TemplateService";
import { PaginationManager } from "../../Bll/PaginationManager";
import { TemplatesManagementGrid } from "../../Components/TemplatesManagement/TemplatesManagementGrid";
import { CredentialService } from "../../Services/CredentialService";
import { ReviewService } from "../../Services/ReviewService";
import { UserService } from "../../Services/UserService";
import { DateService } from "../../Services/DateService";

import { MessageBus } from "../../Events/MessageBus";

import { NotificationManager } from "../../Bll/NotificationManager";

@Component({
    selector: ".templatesmanagement-shell",
    templateUrl: "/Views/Pages/TemplatesManagement/Index.html"
})
export class TemplatesManagementComponent {

    constructor(
        @Inject(Router) private router: Router,
        @Inject(Title) private title: Title)
    {
        router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {
                var url = (<NavigationEnd>event).url;
                this.setTopMenuItems(url);
            }
        });
    }

    private setTopMenuItems(url: string) {
        $(".templates-menu-item").addClass("active");
        $(".templates-menu-item").find("ul > li").removeClass("active");
        $(".style-guide-note-menu-item").removeClass("active");

        switch (url) {
            case "/":
            case "/":
                $(".templates-development-menu-item").addClass("active");
                this.title.setTitle("Templates - Development");
                break;
            case "/publish":
                $(".templates-published-menu-item").addClass("active");
                this.title.setTitle("Templates - Published");
                break;
            case "/archive":
                $(".templates-archived-menu-item").addClass("active");
                this.title.setTitle("Templates - Archived");
                break;
            case "/agents":
                $(".templates-menu-item").removeClass("active");
                $(".style-guide-note-menu-item").addClass("active");
                $(".templates-agents-menu-item").addClass("active");
                this.title.setTitle("Agent Templates");
                break;
        }
    }

}

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        FormsModule,
        ReactiveFormsModule,
        RouterModule.forRoot([
            { path: "", component: TemplatesDevelopmentPage },
            { path: "publish", component: TemplatesPublishedPage },
            { path: "archive", component: TemplatesArchivedPage },
            { path: "agents", component: AgentTemplatesPage }
        ])
    ],
    declarations: [
        TemplatesManagementComponent,
        TemplatesDevelopmentPage,
        TemplatesPublishedPage,
        TemplatesArchivedPage,
        AgentTemplatesPage,
        TemplatesManagementGrid,
        TemplatesUpdateComponent,
        TemplatesUpdatePopupsComponent,
        HumanReadableListOfChangesReportPopup,
        SelectInternalReviewersComponent,
        SelectMdReviewersComponent,
        BusyIndicatorComponent,
        PaginationComponent,
        PageSize,
        GridFilter,
        PaginatePipe
    ],
    providers: [
        CredentialService,
        TemplatesManagementService,
        TemplateService,
        ReviewService,
        ServiceResponseWrapper,
        ViewManager,
        PaginationManager,
        GridManager,
        UserService,
        DateService,
        MessageBus,
        NotificationManager,
        { provide: LocationStrategy, useClass: HashLocationStrategy },
        { provide: APP_BASE_HREF, useValue: "/" }
    ],
    bootstrap: [TemplatesManagementComponent]
})
export class TemplatesManagementModule {

}

enableProdMode();

platformBrowserDynamic().bootstrapModule(TemplatesManagementModule);
Jefferson
  • 173
  • 2
  • 12
  • 32
  • 1
    why is removing that necessary? See [here](https://stackoverflow.com/questions/50943704/whats-the-purpose-of-object-definepropertyexports-esmodule-value-0) for why that is added. – davidhu Aug 18 '22 at 04:15
  • I am getting this `Uncaught ReferenceError: exports is not defined` error – Jefferson Aug 18 '22 at 15:00
  • Try adding `export {}` in the source file in case it is not a module already (i.e. if it does not `import` or `export` anything) – apokryfos Aug 18 '22 at 15:30
  • I have included the ts class I do see a export class TemplatesManagementComponent is that what you mean? – Jefferson Aug 18 '22 at 15:54

0 Answers0