Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

335
Visualizações
Angular 4, Unexpected token error during ng build --prod

I am working on an Angular 4 application that utilizes angular-cli and webpack2.

I can successfully build the project with ng build

However, when I run ng build --prod the following error is thrown:

ERROR in main.50d83f3f70f7e607ec7a.bundle.js from UglifyJs Unexpected token: name (FilterPipe) [main.50d83f3f70f7e607ec7a.bundle.js:7,6]

I don't understand what is wrong.

Here is my filter.pipe.ts file:

import {Pipe, PipeTransform } from '@angular/core';

@Pipe({ 
    name: 'filter'
})

export class FilterPipe implements PipeTransform {
    transform(items: any[], field : string, value : string): any[] { 
        if (!items) return [];  
        return items.filter(it => it[field] == value);
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This happens because Uglify doesnt support es6 syntax yet.

https://github.com/angular/angular-cli/issues/1663

Modify tsconfig.json to check fr sure that "target": "es5", is there Example :

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda