travelist / angular2-fontawesome

Angular5 Components and Directives for Fontawesome
MIT License
87 stars 20 forks source link

Error: Unexpected token: name (FaComponent_1) - when building for prod with systemjs builder #6

Closed elpddev closed 8 years ago

elpddev commented 8 years ago

Hi. First, Thanks for all the hard work.

I wanted to share how I have solved that error.

I'm using angular cli seed, before that angular2 seed. In both of them I got that error when I've tried to build for production.

In angular cli project, in the system-config.js file, there was a need to specify the format of the package to 'esm'.

src/system-config.ts

const map: any = {             
  'angular2-fontawesome': 'vendor/angular2-fontawesome'
};

/** User packages configuration. */
const packages: any = {        
  'angular2-fontawesome': {    
    format: 'esm'
  }
};

Others changes were according to their specification:

angular-cli-build.js

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [          
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',  
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',  
      'reflect-metadata/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',   
      'angular2-fontawesome/**/*.+(js|js.map)'
    ]
  });
};

I am just a starting with systemjs so I would welcome any comments about this setup.

-- Edit I have spoke too soon. Now its falling on require not defined. Playing with the various format options does not help

travelist commented 8 years ago

@elpddev Thank you for letting me know and good information. I planed to update this week (change to use directives from component, support for webpack, .. etc), so will check with angular cli seed and this case as well. Thank you

travelist commented 8 years ago

@elpddev I've tried angular-cli with my spare time and found the way to use angular2-fontawesome on it. I updated the installation chapter of README doc. It might help us. Thanks for reporting this issue, and your information helped me during my trial.

I'll close this issue, but please feel free to re-open this issue or open new issues when there are anythings.

Thanks:)