11

Do we need Babel in an Angular 5 application? What AOT or JIT is being used internally to compile?

Community
  • 1
  • 1
RK6
  • 424
  • 1
  • 5
  • 23

1 Answers1

12

You don't need to worry about babel in an angular 2+ application.

You configure the ECMAscript level in the tsconfig.app.json file in you project.

(be sure you initiated your project with angular's angular-cli)

example (angular 8):

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "types": []
  },
  "exclude": [
    "node_modules",
    "test.ts",
    "**/*.spec.ts"
  ]
}

example (angular 5) :

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015", //<-- can aslo be es5 es6 es7
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

typescript, angular's filesystem includes a very complete bundle of all the other goodies there exist in the JS biosphere :

  • ECMAscript (ergo babel)
  • coffeescript
  • ...
tatsu
  • 2,316
  • 7
  • 43
  • 87
  • `error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.` – Lucio Sep 16 '19 at 14:24
  • in latest version of angular (8) module is not even there. try updated version (or just use angular-cli to create that file, don't make it yourself) – tatsu Sep 16 '19 at 14:29
  • forgive me the ignorance tatsu, but where did you configure ECMAScript in Angular 8+??, in Angular 5 it is visible that it was in modules, but I didn't see in angular 8 explicitly – Edson Filho Jul 06 '21 at 18:26