Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I keep @angular/compiler in dependencies or devDependencies?

Tags:

angular

Should I keep @angular/compiler in dependencies or devDependencies in package.json? Why do I need it in dependencies if my production code is already compiled?

like image 777
Gervasius Twinklewinkleson Avatar asked Feb 26 '19 10:02

Gervasius Twinklewinkleson


People also ask

What is difference between devDependencies and dependencies in Angular?

A dependency is a library that a project needs to function effectively. DevDependencies are the packages a developer needs during development.

Should webpack be a dependency or devDependency?

Packages required to build the webpack project are under dependencies, rather than devDependencies .

Is it a dependency or devDependency?

dependencies : Packages required by your application in production. devDependencies : Packages that are only needed for local development and testing.

Should Eslint be a dev dependency?

Packages like eslint are always a devDependency … unless, of course, you're building a CLI whose job is running eslint, in which case you'd add it as a dependency!


2 Answers

2021 UPDATE:

The AOT compiler has improved significantly, and can be used for development.

  • The "@angular/compiler" and "@angular/cli" references can be moved to devDependencies
  • You can use the "BrowserModule", instead of "PlatformBrowserDynamic" which was used for JIT compilation.
like image 171
John Spiteri Avatar answered Oct 23 '22 00:10

John Spiteri


package.json is organized into two groups of packages:

  • Dependencies are essential to running applications.
  • DevDependencies are only necessary to develop applications.

You should keep @angular/compiler in dependencies because as it mention in its official document as below

Angular's template compiler. It understands templates and can convert them to code that makes the application run and render. Typically you don’t interact with the compiler directly; rather, you use it indirectly via platform-browser-dynamic when JIT compiling in the browser. For more information, see the Ahead-of-time Compilation guide.

For more detail you can check its official document.

like image 30
ozhanli Avatar answered Oct 23 '22 02:10

ozhanli