Error with AOT Build in seeds

ForumCategory: IssueError with AOT Build in seeds
uprakash asked 1 month ago

Hi Team,
I have deployed new seed and create the prod build using AOT command “npm run build.prod.ext” then we are getting error “Error: undefined, resolving symbol ApplicationModule“.
Can you help me to resolve the problem.
Regards
Uday

1 Answers
uprakash answered 1 month ago

Hi All,
Finally, i have got the solution after spent more than week.. If you not able to run AOT command
“npm run build.prod.exp” then you have to do some changes in your seeds. Please follow the given steps :
 
Step 1.  Modify the angular version in your package.josn file which located in project root directory.
“devDependencies”: {
    “@angular/compiler-cli”: “2.4.10”,
    “@angular/platform-server”: “2.4.10”,
    …….
}
“dependencies”: {
    “@angular/common”: “2.4.0”,
    “@angular/compiler”: “2.4.0”,
    “@angular/core”: “2.4.0”,
    “@angular/forms”: “2.4.0”,
    “@angular/http”: “2.4.0”,
    “@angular/platform-browser”: “2.4.0”,
    “@angular/platform-browser-dynamic”: “2.4.0”,
    “ng2-bootstrap”: “^1.4.2″,
    …
}
Step 2. Run the npm nstall command e.g : sudo npm run install
Step 3. You need to be changes the configuration file for ng2-bootstrap module ( If you are using ng2-bootstap module, othewise ignore it)
File location : – <project>/tools/config/seeds.config.ts

  • Go to SYSTEM_CONFIG_DEV -> paths line and add the highlighted code in your configuration.

      paths: {
      [this.BOOTSTRAP_MODULE]: `${this.APP_BASE}${this.BOOTSTRAP_MODULE}`,
      ‘@angular/common': ‘node_modules/@angular/common/bundles/common.umd.js’,
      ‘@angular/compiler': ‘node_modules/@angular/compiler/bundles/compiler.umd.js’,
      ….
      …..
      ‘ng2-bootstrap': ‘node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.js’,
      ‘rxjs/*': ‘node_modules/rxjs/*’,
      ‘app/*': ‘/app/*’,
      // For test config
      ‘dist/dev/*': ‘/base/dist/dev/*’,
      ‘*': ‘node_modules/*’
    },

  • Go to SYSTEM_BUILDER_CONFIG -> packages line and add highlighted code in your configuration.

     packages: {
      ‘@angular/common': {
        main: ‘index.js’,
        defaultExtension: ‘js’
      },
      ‘@angular/compiler': {
        main: ‘index.js’,
        defaultExtension: ‘js’
      },
      ‘@angular/core/testing': {
        main: ‘index.js’,
        defaultExtension: ‘js’
      },
      ‘@angular/core': {
        main: ‘index.js’,
        defaultExtension: ‘js’
      },
      …,
      …,
      …,
      ‘rxjs': {
        main: ‘Rx.js’,
        defaultExtension: ‘js’
      },
     ‘ng2-bootstrap': {
          main: ‘bundles/ng2-bootstrap.umd.min.js’,
        defaultExtension: ‘js’
      },
     ‘ng2-bootstrap/positioning':
       {
         main: ‘index.js’,
         defaultExtension: ‘js’
       },
       ‘ng2-bootstrap/component-loader':
       {
         main: ‘index.js’,
         defaultExtension: ‘js’
       },
      ‘ng2-bootstrap/utils':
       {
         main: ‘index.js’,
         defaultExtension: ‘js’
       }
    }
Step 4. One more changes, if you are using ng2-bootstrap module in your project. if you are importing ng2-bootsrap module in your module like : import { ModalModule, AlertModule } from ‘ng2-bootstrap/ng2-bootstrap';
then you need to be replace with this one :  import { ModalModule, AlertModule } from ‘ng2-bootstrap';
And if you are using to import in @NgModule Like :
@NgModule({
    imports: [
        CommonModule,
        RouterModule,
        AlertModule,
        ModalModule,
    ……
}
then you have to replace with this one :
@NgModule({
    imports: [
        CommonModule,
        RouterModule,
        AlertModule.forRoot(),
        ModalModule.forRoot(),
    ……
}
 
Step 5. Now you have done all changes in your seeds.you can run AOT command ” sudo npm run build.prod.exp“.
*** Note : - While compilation you will get some error which are in you project like :  “Variable doesn’t exist on type, Supplied parameters do not match any signature of call target , etc“. You need to fix these issues in your project.
 
Thansk
Uday Prakash