angular2-aot

Dynamic module/service configuration and AOT

孤街醉人 提交于 2019-12-18 13:37:35
问题 I need to have some Angular services configured dynamically, depending on a runtime switch. In days before AOT, I got it to work using the following code: @NgModule({ imports: [HttpModule], providers: [] }) export class MyModule { static forRoot(config: MyConfiguration): ModuleWithProviders { return { ngModule: MyModule, providers: [ SomeService, { provide: SomeOtherService, useFactory: (some: SomeService, http: Http) => { switch (config.type) { case 'cloud': return new SomeOtherService(new

@ngtools\webpack AOT doesn't work OR freezes at 95% emitting

丶灬走出姿态 提交于 2019-12-18 13:30:57
问题 I've been stuck trying to get AOT working with my Webpack app. (@ngtools/webpack) Can anyone help me at all? It appears to work, however, compiler.js is still included in the bundle. Also it is still looking for all of my .html files and getting 404 on all of the component templates. So as far as I can tell it's not really doing the best parts of the AOT? Can any shine any light here, I'm stuck!! Thank you!! 回答1: (I won't tell you how long it took me to get this working.) First of all, are

Angular 2 Ahead-of-Time compiler: must I make all class properties public?

夙愿已清 提交于 2019-12-17 10:49:29
问题 Angular 2 rc 6 , typescript 2 , node 4.5.0 , npm 2.15.9 on Windows 7 I'm trying to move from Just-in-Time to Ahead-of-Time compilation and I'm relying on these resources: Angular 2 - Ahead-of-time compilation how to https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli#angular-template-compiler I understand that I need to run the compiler ngc to generate ngfactory.ts files, and that I need to change main.ts to use platformBrowser instead of platformBrowserDynamic to

Angular Aot : app folder is not generated

谁说我不能喝 提交于 2019-12-13 06:53:44
问题 I have implemented aot in my Angular 2 project, resolved all errors an finally my "node_modules/.bin/ngc" -p tsconfig-aot.json run successfully but I see only node_modules folder in aot folder and no app folder in it . So where can I get AppModuleNgFactory to bootstrap it? This is my tsconfig-aot.json file { "compilerOptions": { "target": "es5", "module": "es2015", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es2015",

ReferenceError: i0 is not defined Angular AOT error

不打扰是莪最后的温柔 提交于 2019-12-13 03:46:32
问题 I have a local Angular git repository that I build using Angular AOT (4.4.4) and everything works when I copy and paste the results to the server. However, when I clone the repo and do the same commands everything works (all of the build steps) until I bring up the site after pasting the changes to the server and I get the following error before the site loads. Error: Uncaught (in promise): ReferenceError: i0 is not defined ReferenceError: i0 is not defined at View_AppComponent_Host_0

Import single lodash functions for libraries with aot

亡梦爱人 提交于 2019-12-13 00:42:59
问题 I'm trying to use lodash with the syntax "import * as includes from 'lodash.includes';" so i don't need to install all lodash library and just the functions that I need. Everything works fine but aot. I build my library to use it in other project as a node_modules and when I do ng serve everything works fine but when doing ng serve --aot I got: "Module not found: Error: Can't resolve 'lodash.includes' in etc...". I could solve the problem by installing lodash in my library project and use it

window is not defined using Angular4 + AoT + Webpack2

流过昼夜 提交于 2019-12-12 11:03:03
问题 I have an angular4 app that uses webpack and has been working great with JiT but now I'm trying to get it working with AoT and I'm having issues. Specifically I'm getting the following error: ERROR in window is not defined ERROR in ./src/app/main/main.ts Module not found: Error: Can't resolve './../../../aot-main/src/app/main/app.module.ngfactory' in 'W:\<Full Path to App>\src\app\main' resolve './../../../aot-main/src/app/main/app.module.ngfactory' in 'W:\<Full Path to App>\src\app\main'

Deploying angular 2 app Aot with Rollup and external dependencies

白昼怎懂夜的黑 提交于 2019-12-12 09:56:36
问题 I've implemented an angular 2 app which utilize Kendo UI Grid: I am stuck when deploying app with AoT + Rollup: Error: 'GridModule' is not exported by node_modules\@progress\kendo-angular-grid\dist\npm\js\main.js (imported by app\app.module.js). Tried this from Rollup documentation but I don't understand how to configure namedExports : commonjs({ namedExports: { 'node_modules/@progress/kendo-angular-grid/dist/npm/js/main.js': [ 'GridModule' ] } }); Using above configuration doesn't solve the

Error: Can't resolve all parameters for Directive

天涯浪子 提交于 2019-12-12 02:34:01
问题 I'm facing a problem trying to create a directive npm package. I had already created packages for @Component but this is the first I create for @Directive. The problem I'm facing is that when I run ng serve the build completes ok but when I load the page I get the Error: Can't resolve all parameters for HighlightDirective . The curious thing is that if a run ng serve --aot the problem does not appear. So, the package works only with --AOT and throw error with JIT. May be that --AOT is

AOT NgModule provider with dependencies, NullInjectorError

心已入冬 提交于 2019-12-12 00:51:32
问题 I've tried the implementation in https://stackoverflow.com/a/43293449/513570: @NgModule() export class SampleModule { static forRoot(config: CustomConfig): ModuleWithProviders { // User config get logged here console.log(config); return { ngModule: SampleModule, providers: [SampleService, {provide: 'config', useValue: config}] }; } } @Injectable() export class SampleService { constructor(@Inject('config') private config:CustomConfig) { const sConfig = { key: 'value' }; @NgModule({