jvandemo / jvandemo/generator-angular2-library
JiT compilation
- Dominant language
- JavaScript
- Stars
- 740
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
I just found an error trying to make tests with the a library created using angular2-library
So, I followed the next steps:
1. **CREATE LIBRARY ( name: library-angular )**
1.1. yo angular2-library
1.2. npm run build (nothing was modified)
1.3 cd src
1.4. npm link
2. **CREATE ANGULAR APP**
2.1 ng new myApp
2.2 npm link library-angular
2.3 modify src/app/app.module.ts, to make it looks like this:
```
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { SampleModule } from 'library-angular';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
SampleModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```
2.4 add the next line in src/app/app.component.html
` `
2.5 run app using
` ng serve -o`
The bug appears in the browser console and it says
`Uncaught Error: Unexpected value 'SampleModule' imported by the module 'AppModule'. Please add a @NgModule annotation.`
**SOLUTION**
run app using
` ng serve -aot`
It makes me guest that something is broken in the JiT compilation and for that reason the only way to make my library work well was running my app using Ahead of Time compilation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the linked library setup using src/app/app.module.ts, src/app/app.component.html, npm link, and ng serve, then compare it with ng serve -aot. Investigate how SampleModule is compiled and imported during JIT compilation. Done means the linked library and SampleModule work with ng serve without requiring AOT compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100