0

Is there an 'officcial' way in angular 7/8 to have a classic AOT app lazy load components BUT having those components not precompiled?

My scenario is an enterprise app where users can 'design' html+ts forms on the fly. These forms are stored as plain html and ts files, so angular should be able to discover them (based on a service), register their new routes, load the ts+html, compile in browser and run.

Why this question is not a duplicate: I dont see any info on having an AOT app consume new components that were just created as html+ts (not compiled).

ANY help is appreciated

user5328504
  • 734
  • 6
  • 21
  • 1
    Possible duplicate of [Angular, compile and create components at runtime](https://stackoverflow.com/questions/46576727/angular-compile-and-create-components-at-runtime) – talhature May 10 '19 at 20:12

1 Answers1

0

I don't think so. Have you read this blog post? https://blog.angularindepth.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e

One thing mentioned in that post is that non-AOT compilation is frowned upon:

Keep in mind that this approach makes use of a compiler which is not supported as a Public API. Here is what the docs say:

One intentional omission from this list is @angular/compiler, which is currently considered a low level api and is subject to internal changes. These changes will not affect any applications or libraries using the higher-level apis (the command line interface or JIT compilation via @angular/platform-browser-dynamic). Only very specific use-cases require direct access to the compiler API (mostly tooling integration for IDEs, linters, etc). If you are working on this kind of integration, please reach out to us first.

I suspect it would be easier to compile the component with a service as the user modifies the HTML / TS and then show a 'preview', kind of like Overleaf showing a preview of compiled latex.

Community
  • 1
  • 1