Skip to content

Commit 68e2bcd

Browse files
devoto13mlwilkerson
authored andcommitted
Fix module packaging (#24)
* Removed index.ts files from library It looks like Angular metadata resolver does not process them properly and resolves symbols to undefined if they are coming from re-export. I don't completely understand how it works, but after debugging this I also checked https://github.com/angular/angular/tree/master/packages and https://github.com/ng-bootstrap/ng-bootstrap/tree/master/src and none seem to have index.ts files besides the main one. * Replaced @component annotation with @Injectable() on the abstract class If @component is present compiler attempts to handle this class as a real component and fails because it was not added to the NgModule. What is really needed is to force metadata collection on this class and it can be achieved by putting some useless Angular decorator. angular/angular#16566 (comment)
1 parent c2a33b3 commit 68e2bcd

12 files changed

+25
-31
lines changed

src/fontawesome.module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

4-
import { FaIconComponent } from './icon';
5-
import { FaLayersComponent, FaLayersTextComponent, FaLayersCounterComponent } from './layers';
4+
import { FaIconComponent } from './icon/icon.component';
5+
import { FaLayersComponent } from './layers/layers.component';
6+
import { FaLayersTextComponent } from './layers/layers-text.component';
7+
import { FaLayersCounterComponent } from './layers/layers-counter.component';
68

79
@NgModule({
810
imports: [CommonModule],

src/icon/icon.component.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ import {
2222
} from '@fortawesome/fontawesome-svg-core';
2323
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
2424

25-
import { faNotFoundIconHtml, faWarnIfIconHtmlMissing, faWarnIfIconSpecMissing} from '../shared/errors';
26-
import { objectWithKey, faClassList, faNormalizeIconSpec } from '../shared/utils';
27-
import { FaProps } from '../shared/models';
25+
import { faNormalizeIconSpec } from '../shared/utils/normalize-icon-spec.util';
26+
import { FaProps } from '../shared/models/props.model';
27+
import { objectWithKey } from '../shared/utils/object-with-keys.util';
28+
import { faClassList } from '../shared/utils/classlist.util';
29+
import { faWarnIfIconHtmlMissing } from '../shared/errors/warn-if-icon-html-missing';
30+
import { faWarnIfIconSpecMissing } from '../shared/errors/warn-if-icon-spec-missing';
31+
import { faNotFoundIconHtml } from '../shared/errors/not-found-icon-html';
2832

2933
/**
3034
* Fontawesome icon.

src/icon/index.ts

-1
This file was deleted.

src/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export * from './fontawesome.module';
2-
export { FaProps } from './shared/models';
3-
export { FaIconComponent } from './icon';
4-
export { FaLayersComponent, FaLayersTextComponent } from './layers';
2+
export { FaProps } from './shared/models/props.model';
3+
export { FaIconComponent } from './icon/icon.component';
4+
export { FaLayersComponent } from './layers/layers.component';
5+
export { FaLayersTextComponent } from './layers/layers-text.component';
6+
export { FaLayersCounterComponent } from './layers/layers-counter.component';

src/layers/index.ts

-3
This file was deleted.

src/layers/layers-text-base.component.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
Input,
33
Inject,
4+
Injectable,
45
Optional,
56
OnChanges,
6-
Component,
77
forwardRef,
88
HostBinding,
99
SimpleChanges
@@ -14,13 +14,11 @@ import {
1414
TextParams
1515
} from '@fortawesome/fontawesome-svg-core';
1616
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
17-
import { faWarnIfParentNotExist } from '../shared/errors';
17+
1818
import { FaLayersComponent } from './layers.component';
19+
import { faWarnIfParentNotExist } from '../shared/errors/warn-if-parent-not-exist';
1920

20-
@Component({
21-
selector: 'fa-layers-text-base',
22-
template: ''
23-
})
21+
@Injectable()
2422
export abstract class FaLayersTextBaseComponent implements OnChanges {
2523

2624
constructor(@Inject(forwardRef(() => FaLayersComponent)) @Optional() private parent: FaLayersComponent,

src/layers/layers-text.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import {
1616
} from '@fortawesome/fontawesome-svg-core';
1717
import { FaLayersTextBaseComponent } from './layers-text-base.component';
1818

19-
import { objectWithKey, faClassList } from '../shared/utils';
20-
import { FaProps } from '../shared/models';
19+
import { FaProps } from '../shared/models/props.model';
20+
import { objectWithKey } from '../shared/utils/object-with-keys.util';
21+
import { faClassList } from '../shared/utils/classlist.util';
2122

2223
/**
2324
* Fontawesome layers text.

src/layers/layers.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Type } from '@angular/core';
22
import { ComponentFixture, TestBed } from '@angular/core/testing';
33
import { faUser, faMobile } from '@fortawesome/free-solid-svg-icons';
44

5-
import { FaIconComponent } from '../icon';
5+
import { FaIconComponent } from '../icon/icon.component';
66
import { FaLayersComponent } from './layers.component';
77
import { FaLayersTextComponent } from './layers-text.component';
88

src/shared/errors/index.ts

-4
This file was deleted.

src/shared/models/index.ts

-1
This file was deleted.

src/shared/utils/classlist.util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FaProps } from '../models';
1+
import { FaProps } from '../models/props.model';
22

33
/**
44
* Fontawesome class list.

src/shared/utils/index.ts

-4
This file was deleted.

0 commit comments

Comments
 (0)