You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
AOT plays an important role in optimizing Angular applications. It's therefore important that third party libraries be published in a format compatible with AOT compilation. Otherwise it will not be possible to include the library in an AOT compiled application.
348
+
AOT plays an important role in optimizing Angular applications.
349
+
It's therefore important that third party libraries be published in a format compatible with AOT
350
+
compilation.
351
+
Otherwise it will not be possible to include the library in an AOT compiled application.
349
352
350
353
Only code written in TypeScript can be AOT compiled.
351
354
352
355
Before publishing the library must first be compiled using the `ngc` compiler.
353
-
354
356
`ngc` extends the `tsc` compiler by adding extensions to support AOT compilation in addition to regular TypeScript compilation.
355
357
356
358
AOT compilation outputs three files that must be included in order to be compatible with AOT.
JavaScript has no way of representing typings. In order to preserve the original typings, `ngc` will generate `.d.ts` typings files.
366
+
JavaScript has no way of representing typings. In order to preserve the original typings, `ngc`
367
+
will generate `.d.ts` typings files.
365
368
366
369
*Meta Data JSON files*
367
370
368
-
`ngc` outputs a metadata.json file for every `Component` and `NgModule`. These meta data files represent the information in the original `NgModule` and `Component` decorators.
371
+
`ngc` outputs a metadata.json file for every `Component` and `NgModule`.
372
+
These meta data files represent the information in the original `NgModule` and `Component`
373
+
decorators.
369
374
370
-
The meta data may reference external templates or css files. These external files must be included with the library.
375
+
The meta data may reference external templates or css files.
376
+
These external files must be included with the library.
371
377
372
378
### NgFactories
373
379
374
-
`ngc` generates a series of files with an `.ngfactory` suffix as well. These files represent the AOT compiled source, but should not be included with the published library.
380
+
`ngc` generates a series of files with an `.ngfactory` suffix as well.
381
+
These files represent the AOT compiled source, but should not be included with the published library.
375
382
376
-
Instead the `ngc` compiler in the consuming application will generate `.ngfactory` files based on the JavaScript, Typings and meta data shipped with the library.
383
+
Instead the `ngc` compiler in the consuming application will generate `.ngfactory` files based
384
+
on the JavaScript, Typings and meta data shipped with the library.
377
385
378
386
### Why not publish TypeScript?
379
387
380
-
Why not ship TypeScript source instead? After all the library will be part of another TypeScript compilation step when the library is imported by the consuming application?
388
+
Why not ship TypeScript source instead?
389
+
After all the library will be part of another TypeScript compilation step when the library is
390
+
imported by the consuming application?
381
391
382
-
Generally it's discouraged to ship TypeScript with third party libraries. It would require the consumer to replicate the complete build environment of the library. Not only typings, but potentially a specific version of `ngc` as well.
392
+
Generally it's discouraged to ship TypeScript with third party libraries.
393
+
It would require the consumer to replicate the complete build environment of the library.
394
+
Not only typings, but potentially a specific version of `ngc` as well.
383
395
384
-
Publishing plain JavaScript with typings and meta data allows the consuming application to remain agnostic of the library's build environment.
396
+
Publishing plain JavaScript with typings and meta data allows the consuming application to
397
+
remain agnostic of the library's build environment.
0 commit comments