I'm developing an Angular lib (GitHub repo link), there are
- lib module sources placed at
./src
- test App sources placed at
./app
- lib distributive at
./dist
The build process uses rollup.js and is based on angular-library-starter.
I also have a process that generates npm package from ./dist
and installs it to ./node_modules
. The issue is that the App works fine with the lib module imported from ./src
and does not work when I imported it from ./dist
or ./node_modules
:
// ./app/app/app.module.ts
import { AppComponent } from './app.component';
import { UiScrollModule } from '../../src/ngx-ui-scroll'; // works
//import { UiScrollModule } from 'ngx-ui-scroll'; // doesn't work
//import { UiScrollModule } from '../../dist/bundles/ngx-ui-scroll.umd.js'; // no...
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, UiScrollModule],
bootstrap: [AppComponent]
})
export class AppModule { }
There are no errors during build process, but the browser console says (for both of ./dist
and ./node_modules
importing cases):
GET http://localhost:4200/ui-scroll.component.html 404 (Not Found)
Failed to load ui-scroll.component.html
And it is true that my lib module has a component which has an external temlate:
// ./src/component/ui-scroll.component.ts
@Component({
selector: 'app-ui-scroll',
templateUrl: './ui-scroll.component.html'
})
export class UiScrollComponent implements OnInit, OnDestroy { /* ... */ }
If I would inline the template (using template
instead of templateUrl
in the @Component
settings), it will work, I tested it. But I want the template to be in separate file... I believe this is a build process responsibility. There are a bunch of configs related to my build process, I think it's not a good idea to list them all here. They could be found at the lib repository (or I can post any exact parts by request).
Has anyone encountered the problem of an external html template rollup-bundling?