[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
ํ์ฌ ํ๋
๋ด ์์
๊ณต๊ฐ์์ ์ฌ์ฉ๋์ง ์๋ ๊ตฌ์ฑ ์์/ํ์ดํ/์ง์์ด๊ฐ ์ปดํ์ผ๋ฌ์์ ๊ฐ์ง๋์ด ๊ฐ ํ์ผ์ ๋ํด Cannot determine the module for class (...)
์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ปดํ์ผ์ ์ค์งํ๊ณ ๊ตฌ์ฑํ ์ ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ด ์์
๊ณต๊ฐ์ ํด๋น ํ์ผ์ด ์์ด์ผ ํ์ง๋ง ๊ฒฐ๊ณผ ์ฑ(๊ณต์ ๊ตฌ์ฑ ์์์ ๋ค๋ฅธ ์ฝค๋ณด๊ฐ ํ์ํ ํํธ๋ ๊ตฌํ)์๋ ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฌธ์ ์
๋๋ค. ์ด๊ฒ์ ์์
๊ณต๊ฐ์ ๊ด๊ณ์์ด ํฌํจ๋ ํ์ผ ๋ชฉ๋ก์ ์ ๊ณตํ ์ ์์ด์ผ ํ๋ ์นํฉ ๋ก๋์์ ์ปดํ์ผํ๋ ๊ฒ๊ณผ ๊ด๋ จํ์ฌ ํนํ ์ค๋ง์ค๋ฝ์ต๋๋ค.
์์๋๋ ํ๋
์ด๋ฌํ ์ค๋ฅ๋ ๊ฒฝ๊ณ ๋ฐ/๋๋ ์ปดํ์ผ๋ฌ ์ต์
์ ์ํด ์นจ๋ฌต๋ ์ ์์ ๊ฒ์ผ๋ก ์์ํฉ๋๋ค. ๋๋ ์นํฉ๊ณผ ๊ด๋ จํ์ฌ ํ์ผ ๋ชฉ๋ก์ ์ฝ์
ํ๋๋ก ํ์ฉํ์ฌ ์นํฉ์ด ์์
๊ณต๊ฐ์ ๋ชจ๋ ํ์ผ ๋์ ์๊ตฌ ์ฒด์ธ์ ๋ชจ๋ ํ์ผ์ ์ ๊ณตํ ์ ์๋๋ก ํ ์ ์์ต๋๋ค.
์ง์นจ์ผ๋ก ๋ฌธ์ ๋ฅผ ์ต์ํ์ผ๋ก ์ฌํ
JIT๋ฅผ ์ฌ์ฉํ๋ฏ๋ก plunkr์์ ๋ฐ๋ชจํ ์ ์์ต๋๋ค.
Cannot determine the module for class
๊ฒฝ๊ณ ๋ฅผ ๋ฐ๊ฒ ๋ฉ๋๋ค.ํ๋์ ๋ฐ๊พธ๋ ๋๊ธฐ/์ฌ์ฉ ์ฌ๋ก๋ ๋ฌด์์
๋๊น?
์ฐ๋ฆฌ ํ์ฌ์๋ ์์ฒด ๊ธฐ๋ณธ ์ฑ์ด ์์ผ๋ฉฐ ํํธ๋๋ ํด๋น ์ฑ์ ์์ ๋ ๋ฒ์ ์ ์์ฒด์ ์ผ๋ก ์ฌ์ฉํฉ๋๋ค. ๋ชจ๋ ํํธ๋๋ฅผ ๋ณ๋๋ก ์ ์ง ๊ด๋ฆฌํ๋ ๋์ ํ์์ ๋ฐ๋ผ ๊ฐ์ ธ์จ ๊ณตํต ์ผ๋ฐ ๊ตฌ์ฑ ์์์ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๊ธฐ๋ณธ ์ฑ์ ๊ฒฝ์ฐ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ๋ชจ๋ ๊ฒ์ด ์ ์์
๋๋ค. ํํธ๋์ ๊ฒฝ์ฐ ๊ณต์ npm ํจํค์ง์ ์ผ๋ถ ๊ตฌ์ฑ ์์์ ์ ์ธ๋ ๋ชจ๋์ด ์๊ธฐ ๋๋ฌธ์ AOT๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๊ทํ์ ํ๊ฒฝ์ ๋ํด ์๋ ค์ฃผ์ญ์์ค.
๋ชจ๋ ์ฅ์น์์ ๋ฐ์ํ์ง๋ง ํ์ฌ ํ
์คํธ ์ค์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
์๋์ฐ 10
VS ์ฝ๋
Cmder(bash ํฐ๋ฏธ๋)
๊ฐ๋ ๋ฒ์ :
v2.1.0(2.3.1์์๋ ํ
์คํธํ์ง๋ง
๋ธ๋ผ์ฐ์ : ๋ชจ๋ - ๋ธ๋ผ์ฐ์ ๋ณ ๋ฌธ์ ๊ฐ ์๋๋ผ ์ปดํ์ผ๋ฌ ๋ฌธ์ ์ ๋๋ค.
์ธ์ด: ํ์ดํ์คํฌ๋ฆฝํธ
ํด๋์ค์ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค.
๊ตฌ์ฑ ์์๋ ๋ชจ๋์ ์ผ๋ถ์ฌ์ผ ํฉ๋๋ค. ์๋๋ ๊ฒ์
๋๋ค.
๊ธฐ๋ฅ ์์ฒญ์ด๋ผ๊ณ ํ ์ ์์ต๋๋ค.
@DzmitryShylovich ์ฌ์ฉ ์ค์ธ ๊ตฌ์ฑ ์์๊ฐ ๋ชจ๋์ ์ผ๋ถ๊ฐ ๋์ด์ผ ํ๋ค๋ ๊ฒ์ ์๋ฏธ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ปดํ์ผ๋ฌ์ ๊ดํ ํ ์ด๋ฌํ ํ์ผ์ ์ค์ํ์ง ์์ต๋๋ค. ๊ตฌ์ฑ ์์๋ฅผ ํฌํจํ๋ ์ฌ์ฉ๋์ง ์๊ณ ์ฐธ์กฐ๋์ง ์์ .ts ํ์ผ์ ๋๋ค.
@swimmadude66 tsconfig์์ ์ฌ์ฉํ์ง ์๋ ํ์ผ์ ์ ์ธํ ์ ์์ต๋๋ค.
@DzmitryShylovich ํ ์ ์์ง๋ง ๋ฐฐ๋ด ํ์ผ์ ๊ทธ๊ฒ์ ๋ณต์กํ๊ฒ ๋ง๋ญ๋๋ค. ํด๋์ค๋ฅผ ๋ฐฐ๋ด ํ์ผ๋ก ๋ค์ ๋ด๋ณด๋ด๋ ๊ฒฝ์ฐ ๋ฐฐ๋ด ํ์ผ๋ ๋ฌด์ํด์ผ ํ๋ฏ๋ก ํด๋น ๋ฐฐ๋ด์์ ํ์ํ ํด๋์ค์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
์ปดํ์ผ๋ฌ๊ฐ ์ ๋์ ์ผ๋ก ํ์ํ ๊ฒ๋ณด๋ค ๋ ๋ง์ ์ปดํ์ผ์ ์๋ํด์ผ ํ๋ ๊ฒ์ ์ด์ํด ๋ณด์ ๋๋ค. Tree-shaking์ ์ ์ณ๋๊ณ ์ปดํ์ผ๋ฌ๊ฐ ์ฃผ์ด์ง ํ์ผ๋ง ์ฒ๋ฆฌํ๊ฑฐ๋ ์ฃผ์ด์ง ํ์ผ์ ๋ช ์์ ์ผ๋ก ๋งํฌ๋๊ธฐ๋ฅผ ์ํ ๊ฒ์ผ๋ก ์์ํฉ๋๋ค.
์ปดํ์ผ๋ฌ๊ฐ ์ ๋์ ์ผ๋ก ํ์ํ ๊ฒ๋ณด๋ค ๋ ๋ง์ ์ปดํ์ผ์ ์๋ํด์ผ ํ๋ ๊ฒ์ ์ด์ํด ๋ณด์ ๋๋ค.
์ด๊ฒ์ด ์ปดํ์ผ๋ฌ๊ฐ ์๋ํ๋ ๋ฐฉ์์ ๋๋ค ...
JIT ์ปดํ์ผ์ด ์๋ํ๋ค๋ ์ฌ์ค์ ์ปดํ์ผ๋ฌ๊ฐ ์ด๋ฌํ ํ์ผ์ ํ์๋ก ํ์ง ์๋๋ค๋ ๊ฝค ์ข์ ์ฆ๊ฑฐ์ฌ์ผ ํฉ๋๋ค. ํด๋ฅผ ๋ผ์น ์ง ์๊ณ ์ ์ธ ๋ ์์๋ ํ์ผ์ ๋ํ ๊ฒฝ๊ณ ๋์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ปดํ์ผ๋ฌ๊ฐ ํ๋ฃจ ์ข ์ผ ์๋ํ๋ ๋ฐฉ์์ ๋ํด ๋์๊ฒ ์ด์ผ๊ธฐํ ์ ์์ง๋ง ์ด๊ฒ์ ๋ค์ ๊ธฐ๋ณธ์ ์ธ ์ฌ์ฉ ์ฌ๋ก์์ ์ค์ ๋ฌธ์ ์ ๋๋ค. ๋๋ ์ ์ด๋ ์ค๋ฅ๋ฅผ ์ต์ ํ๊ณ ๋ด ์์ ์ ์ํ์ ๊ฐ์ํ ์ ์๋ ๋ฐฉ๋ฒ์ ์๊ตฌํ ๋ฟ์ ๋๋ค.
๋ด ๋๋ฃ๊ฐ ์ผ๊ด ์ ์ธ ์ฌ์ฉ์ ์ฐจ๋จํ ์ ์๋ ๋ชจ๋ ๋ฐฐ๋ด ํ์ผ์ ์ ๊ฑฐํ๋ ค๊ณ ์๋ํ๊ณ ์์ต๋๋ค. ํ์ง๋ง ๋ค๋ฅธ ์ฌ์ฉ์๊ฐ ๋ค์์์ ๋์ผํ ์ค๋ฅ๋ฅผ ๊ฒช์๋ @ngtools/webpack์ ๋ํด ๋ด๊ฐ ์๋ ์ฐ ๋ฌธ์ ๋ฅผ ์ดํด๋ณด์๊ธฐ ๋ฐ๋๋๋ค. ํ ์คํธ์์๋ง ์ฐธ์กฐ๋๋ ๊ตฌ์ฑ ์์์ ๋๋ค. https://github.com/angular/angular-cli/issues/3636
์ปดํ์ผ๋ฌ๋ ๋ด๊ฐ ์ปดํ์ผํ๋๋ก ์์ฒญํ์ง ์์ ํ์ผ์ ์ธ์ํ๊ณ ์์ผ๋ฉฐ ๋ณต๊ตฌ ๊ฐ๋ฅํ ์ํฉ์ ๋ํด ๋ณต๊ตฌํ ์ ์๋ ์ค๋ฅ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ๋๋ก.
๊ฐ์ ๋๋ ํ ๋ฆฌ์ ํ๋ก์ ํธ์ ํฌํจ๋์ง ์์ ๊ตฌ์ฑ ์์๊ฐ ์๋ ์ด์ ๋ฅผ ์ดํดํ ์ ์์ต๋๋ค.
๋๋ ์ด๊ฒ์ด ๊ธฐ๋ฅ ์์ฒญ์ผ ์ ์๋ค๊ณ ์๊ฐํ์ง๋ง ํ์ฌ ์ด๊ฒ์ด ์ปดํ์ผ๋ฌ๊ฐ ์๋ํ๋ ๋ฐฉ์์ด๋ฉฐ "JIT์์ ์๋ํ๋ค"๊ณ ๋งํ๋ ๊ฒ์ AOT์์ ์๋ํด์ผ ํ๋ค๊ณ ์๊ฐํ ์ถฉ๋ถํ ์ด์ ๊ฐ ๋์ง ์์ต๋๋ค.
๋ด ์๊ฐ์ ๋น์ ์ด ํด์ผ ํ ์ผ์ ๊ธฐ๋ณธ ์ฑ์์ ์ด๋ฌํ ํ์ผ์ ๋ชจ๋๋ก ๋ถ๋ฆฌํ ๋ค์ ์ผ์ข
์ ํจํค์ง ๊ด๋ฆฌ์๋ฅผ ํตํด ๊ฐ์ ธ์ค๋ ๊ฒ์
๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ๋๋ ํฐ๋ฆฌ๋ฅผ ์ ๋ฆฌํ๊ณ ๋ชจ๋ ์ธก๋ฉด์์ ์ ์ง ๊ด๋ฆฌ๊ฐ ๋ ์ฌ์์ง๋๋ค.
@Toxicable ์ฌ์ฉํ์ง ์๋ ํ์ผ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์คํ์ผ์ npm ๋ชจ๋์ ์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ์ด์์ ์ธ ์ฌ์ฉ ์ฌ๋ก๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
@project/angular(๊ณต์ ์ฝ๋ npm ๋ชจ๋)์๋ ๊ธฐ๋ณธ ์ฑ์ ๋ง๋ค๊ณ ๋ฐฑ์๋ ํ๋ซํผ๊ณผ ํต์ ํ๋ ๋ฐ ํ์ํ ๋ชจ๋ ๊ตฌ์ฑ ์์, ํ์ดํ, ์ง์๋ฌธ ๋ฐ ์๋น์ค๊ฐ ์์ต๋๋ค. ์ฐ๋ฆฌ ํํธ๋๋ ๋น์ทํด ๋ณด์ด์ง๋ง ๋ค๋ฅธ ํ ํ์ด์ง๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์ผ๋ถ ์๋ก์ด ๊ตฌ์ฑ ์์๊ฐ ์ถ๊ฐ๋ ์ฑ์ ์ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋๋ถ๋ถ์ ๋ค๋ฅธ ํ์ด์ง๋ ๋์ผํ ๊ฒ์ด๋ฉฐ ๋น์ฌ ํ๋ซํผ์ ์ฐ๊ฒฐํ๋ ๋ฐ ํ์ํ ๋ชจ๋ ์๋น์ค๋ ๋์ผํ ์ ์์ต๋๋ค.
์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ฝ๋๋ฅผ ์ต๋ํํ๊ธฐ ์ํ ์ฐ๋ฆฌ์ ์ ๊ทผ ๋ฐฉ์์ ๊ฐ ํํธ๋๊ฐ ๋ชจ๋์ ๋ง๋ค๊ณ npm ๋ชจ๋์์ ์๋ก์ด ๋ถ๋ถ๊ณผ ๊ณต์ ๋ถ๋ถ์ ์กฐํฉ์ ๊ฐ์ ธ์ค๋๋ก ํ๋ ๊ฒ์ด์์ต๋๋ค. ๋ด ์ HomeModule
์๋ ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ธ์ค๊ธฐ๊ฐ ์์ ์ ์์ต๋๋ค.
import {
OverviewComponent,
ProfileComponent
} from './components/home';
import {
AuthComponent
} from '@project/angular';
๊ทธ๋ฌ๋ฉด @project/angular์์ OverviewComponent๋ฅผ ์ฌ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์ Cannot determine the module for class OverviewComponent
๋ผ๊ณ AOT์์ ํญ๋ฐํฉ๋๋ค.
๋ง ๊ทธ๋๋ก @project/angular/components/home/overview/component.ts
๋ฅผ ๊ฐ๋ฆฌํค๋ ํ์ผ์ด ์๊ธฐ ๋๋ฌธ์ ์ปดํ์ผ๋ฌ๊ฐ ์ฌ์ฉ๋์ง ์๋๋ค๋ ์ฌ์ค์ ์ ํ ์ ๊ฒฝ ์ฐ์ง ์์ ๊ฒ์
๋๋ค. ๊ทธ๋ฌ๋ ํ์ผ์ด ์ฐ๋ฆฌ ํ๋ก์ ํธ์ node_modules ๋๋ ํ ๋ฆฌ ์์ ์๊ธฐ ๋๋ฌธ์ ์ปดํ์ผ๋ฌ๋ ๊ทธ๊ฒ์ ์ฐพ๊ณ ๋ถํํ๊ณ ์ฃฝ์ต๋๋ค.
JIT๋ !== AOT๊ฐ ์๋ํ๊ณ ๊ธฐ๋ณธ ์ฑ์ AOT์ ์๋ํ๋ฉฐ ๊ฐ๋ ์ฆ๋ช ํํธ๋์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ฏฟ์ ์ ์์ ์ ๋๋ก ์์ต๋๋ค. JIT์์ ์๋ํ๋ ๋ชจ๋ ๊ฒ์ด AOT์์ ์๋ํด์ผ ํ๋ค๋ ์๋ฏธ๋ ์๋์ง๋ง, ๊ทธ๋ ๊ฒ ํด์ผ ํ๋ค๊ณ ๋ฏฟ์ ๋งํ ์ถฉ๋ถํ ์ด์ ๊ฐ ์์ต๋๋ค.
์ด ํ์ฌ ๋์์ด ์๋ฏธ๊ฐ ์๋ ๋ ๋ค๋ฅธ ์๊ฐ ์์ต๋๋ค. ๋ฐ๋ก ํ
์คํธ์
๋๋ค.
์๋ฅผ ๋ค์ด some-feature.component.ts
๋ฐ some-feature.component.spec.ts
๊ฐ ์๋ ๊ธฐ๋ฅ ๋๋ ํ ๋ฆฌ some-feature
$ ๊ฐ ์์ต๋๋ค.
์ด ๊ตฌ์ฑ ์์๋ ์ฝํ
์ธ ํ๋ก์ ์
์ ์ฌ์ฉํ๋ฏ๋ก ๋ค์๊ณผ ๊ฐ์ด ๋ณด๊ธฐ์์ some-feature
๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๋ ๋ด some-feature.component.spec.ts
ํ์ผ ๋ด๋ถ ์ ํ
์คํธ ๊ตฌ์ฑ ์์๋ฅผ ๋ง๋ค์ด ํด๋น ๊ธฐ๋ฅ์ ํ
์คํธํ๊ณ ์ถ์ต๋๋ค.
@Component({
selector: 'test-app',
template: `<some-feature><p>projected content</p></some-feature>`
})
export class TestAppComponent {}
๊ทธ๋ฐ ๋ค์ ํ ์คํธ ๋ชจ๋์์ ์ด ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํฉ๋๋ค .
...
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestAppComponent, SomeFeatureComponent]
})
})
...
angular-cli๋ฅผ ์ฌ์ฉํ์ฌ ng build --prod --aot
๋ฅผ ์คํํ ๋๊น์ง ๋ชจ๋ ๊ฒ์ด ์ ํจํ๊ณ ํ๋ฅญํฉ๋๋ค.
Cannot determine the module for class TestAppComponent
.
AOT๊ฐ .spec
ํ์ผ์ ๋ํด ๊ฑฑ์ ํ ํ์๋ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์ผ๋ฐ์ ์ธ ๊ท์น์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ngc๋ tsc๊ฐ ์ปดํ์ผํ๋ ๋ชจ๋ ๊ฒ์ ์ปดํ์ผํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ฐพ์ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ์ปดํ์ผํ๋ ค๊ณ ์๋ํฉ๋๋ค. ๊ทธ๋ฌ๋ Angular๋ ๊ด๋ จ ๋ชจ๋ ์์ด ๊ตฌ์ฑ ์์๋ฅผ ์ปดํ์ผํ ์ ์์ต๋๋ค.
ํ์ง๋ง ์ด ์ค๋ฅ๋ฅผ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
๋ํ ํ ์คํธ์ฉ์ผ๋ก๋ง ์ฌ์ฉ๋๋ ํ ์คํธ ๋ํผ ๊ตฌ์ฑ ์์๊ฐ ์์ผ๋ฉฐ ์ฌ๊ธฐ์ ์ค๋ช ๋ ๋๋ก AOT๊ฐ ํญ๋ฐํ๊ฒ ๋ฉ๋๋ค. AOT๊ฐ TestComponent* ๋ฑ๊ณผ ๊ฐ์ ์์ผ๋์นด๋ ํํ์์ ์ถฉ์กฑํ๋ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ฌด์ํ ์ ์๋ค๋ฉด ์ข์ ๊ฒ์ ๋๋ค.
์๊ฒ ์ต๋๋ค. ์ฌ๊ธฐ์ ๋ ๋ง์ ์ ๋ณด๊ฐ ์์ต๋๋ค. ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฐพ์ ๊ฒ ๊ฐ์ต๋๋ค(testWrapper ์ฌ๋ก๋ฅผ ์์ ํ์ง ์์). ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ ์ง์ง ๋ฌธ์ ๋ ๋ฐฐ๋ด ํ์ผ์ด์๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ฐฐ๋ด ํ์ผ์์ ANYTHING์ ๊ฐ์ ธ์ฌ ๋ ๋ฐฐ๋ด์์ ๋ค์ ๋ฐฉ์ถ๋๋ ๋ชจ๋ ๊ฒ์ ์ฌ์ฌ์ ๋ฐ๋ฆ
๋๋ค. ์ต์์ ์์ค PROJECT/components
์์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ ธ์๊ธฐ ๋๋ฌธ์ ์ํ๋ ๊ตฌ์ฑ ์์๊ฐ ์๋ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ถ์ํ๊ณ ์์์ต๋๋ค. ์ด๊ฒ์ ์ฌ์ ํ โโ๊ฒฝ๊ณ ๋ก ๋ ๋์ ๊ฒ์ด์ง๋ง ์ปดํ์ผ๋ฌ๊ฐ ์ด๋ฌํ ๊ตฌ์ฑ ์์์ ๊ด์ฌ์ ๊ฐ๋ ์ด์ ๋ฅผ ์กฐ๊ธ ๋ ์ ์ดํดํ ์ ์์ต๋๋ค.
๋์ผํ ์ค๋ฅ๊ฐ ํ์๋จ:
$ ./node_modules/.bin/ng-xi18n
Error: Cannot determine the module for class DividerPanel in C:/msweb/studiotouch/src/comps/dividerpanel/DividerPanel.ts!
Cannot determine the module for class EntryPanel in C:/msweb/studiotouch/src/comps/entry/EntryPanel.ts!
Cannot determine the module for class ForgotPass in C:/msweb/studiotouch/src/comps/entry/ForgotPass.ts!
Cannot determine the module for class Footer in C:/msweb/studiotouch/src/comps/footer/Footer.ts!
Cannot determine the module for class Infobox in C:/msweb/studiotouch/src/comps/infobox/Infobox.ts!
Cannot determine the module for class InputNumeric in C:/msweb/studiotouch/src/comps/inputnumeric/InputNumeric.ts!
Cannot determine the module for class InputString in C:/msweb/studiotouch/src/comps/inputstring/InputString.ts!
Cannot determine the module for class Loading in C:/msweb/studiotouch/src/comps/loading/Loading.ts!
Cannot determine the module for class MapAddress in C:/msweb/studiotouch/src/comps/mapaddress/MapAddress.ts!
Cannot determine the module for class Minitab in C:/msweb/studiotouch/src/comps/minitabs/MiniTab.ts!
Cannot determine the module for class Minitabs in C:/msweb/studiotouch/src/comps/minitabs/MiniTabs.ts!
Cannot determine the module for class ModalDialog in C:/msweb/studiotouch/src/comps/modaldialog/ModalDialog.ts!
Cannot determine the module for class Ng2Highcharts in C:/msweb/studiotouch/src/comps/ng2-highcharts/src/directives/ng2-highcharts.ts!
Cannot determine the module for class Ng2Highstocks in C:/msweb/studiotouch/src/comps/ng2-highcharts/src/directives/ng2-highstocks.ts!
Cannot determine the module for class Ng2Highmaps in C:/msweb/studiotouch/src/comps/ng2-highcharts/src/directives/ng2-highmaps.ts!
Cannot determine the module for class simplelistEditable in C:/msweb/studiotouch/src/comps/simplelist/simplelistEditable.ts!
Cannot determine the module for class simplelist in C:/msweb/studiotouch/src/comps/simplelist/simplelist.ts!
Cannot determine the module for class FilterPipe in C:/msweb/studiotouch/src/pipes/FilterPipe.ts!
Cannot determine the module for class FilterPipeEqual in C:/msweb/studiotouch/src/pipes/FilterPipeNot.ts!
Cannot determine the module for class OrderBy in C:/msweb/studiotouch/src/pipes/OrderBy.ts!
Cannot determine the module for class ReplacePipe in C:/msweb/studiotouch/src/pipes/ReplacePipe.ts!
Cannot determine the module for class SortBy in C:/msweb/studiotouch/src/pipes/SortBy.ts!
at analyzeAndValidateNgModules (C:\msweb\studiotouch\node_modules\@angular\compiler\bundles\compiler.umd.js:24878:17)
at Extractor.extract (C:\msweb\studiotouch\node_modules\@angular\compiler\bundles\compiler.umd.js:27727:20)
at Extractor.extractBundle (C:\msweb\studiotouch\node_modules\@angular\compiler-cli\src\extractor.js:40:33)
at Extractor.extract (C:\msweb\studiotouch\node_modules\@angular\compiler-cli\src\extractor.js:30:34)
at extract (C:\msweb\studiotouch\node_modules\@angular\compiler-cli\src\extract_i18n.js:7:67)
at Object.main (C:\msweb\studiotouch\node_modules\@angular\tsc-wrapped\src\main.js:47:16)
at Object.<anonymous> (C:\msweb\studiotouch\node_modules\@angular\compiler-cli\src\extract_i18n.js:14:9)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
Extraction failed
root@DESKTOP-VEUHFOL /cygdrive/c/msweb/studiotouch
Angular 2 ์ฃผ๋ฐฉ ์ฑํฌ๋: http://ng2.javascriptninja.io
๋ฐ ์์ค@ https://github.com/born2net/Angular-kitchen-sink
๋ฌธ์ ์ธ์ฌ,
์
i18์ ์ ์ฒด ํ๋ก์ ํธ ๊ตฌ์กฐ๋ฅผ ํ์ํ์ง ์๊ณ ๋์ ์ฌ์ฉ๋ ์ ์ธ์ ์ดํด๋ด ๋๋ค.
์ฌ์ฉ๋์ง ์๋ ์ง์๋ฌธ์ ์ ๋ฆฌํ๋ ค๊ณ ํ๋๋ ํ ๋ผ ๊ตฌ๋ฉ์ด ๋ ๊น์ด์ก์ต๋๋ค.
$ ./node_modules/.bin/ng-xi18n
Error: Error at C:/msweb/ng-skeleton/node_modules/typescript/lib/lib.d.ts:18770:11: Duplicate identifier 'ActiveXObject'.
Error at C:/msweb/ng-skeleton/node_modules/typescript/lib/lib.d.ts:18773:13: Duplicate identifier 'ActiveXObject'.
Error at C:/msweb/ng-skeleton/e2e/app.po.ts:1:38: Cannot find module 'protractor'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/facade/lang.d.ts:12:17: Cannot find name 'Map'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/facade/lang.d.ts:13:17: Cannot find name 'Set'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/application_init.d.ts:16:18: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/rxjs/Observable.d.ts:68:60: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/rxjs/Observable.d.ts:68:70: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/linker/compiler.d.ts:53:49: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/linker/compiler.d.ts:61:65: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/application_ref.d.ts:116:67: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/application_ref.d.ts:132:101: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/application_ref.d.ts:158:67: Cannot find name 'Promise'.
Error at C:/msweb/ng-skeleton/node_modules/@angular/core/src/application_ref.d.ts:160:101: Cannot find name 'Promise'.
๋ชจ๋ ๊ฒ์ด angular-cli ๋ฐ angular-compiler์์ ์ ์๋ํ๋ฏ๋ก ๋ด ํ๋ก์ ํธ๊ฐ ๋ง์์ ๋ค์ง ์๋ i18์ผ ๋ฟ์ด๋ผ๊ณ ๋ง๋ถ์ด๊ฒ ์ต๋๋ค.
์ฐธ๊ณ ์๋ฃ(๋ฉ์ง๊ณ ๊น๋ํ ์ค์ ): https://github.com/born2net/ng-skeleton
๋ฌธ์ ์ธ์ฌ,
์
์ฃผ์ ์ฒ๋ฆฌ ๋ ๊ตฌ์ฑ ์์์ ๋ํ ๋์ผํ ์ค๋ฅ .. ๊ฐ๋ฐ ๋จ๊ณ์์ ์ฌ์ฉ๋์ง ์๊ณ ์ฃผ์ ์ฒ๋ฆฌ ๋ ๊ตฌ์ฑ ์์๋ ์ฒ๋ฆฌํ์ง ์๋ ์ ์ฉํ ๋จ๊ณ์ ๋๋ค.
// two comments aot read:
// {path: 'about', component: AboutComponent
// import { AboutComponent } from './about';
@kirjai ngc ๋ ์์ค ๋๋ ํ ๋ฆฌ ๋ด์ ๋ชจ๋ ํ์ผ์ ์ปดํ์ผํฉ๋๋ค. ์์ ์ฌ๋ถ๋ ์ค์ํ์ง ์์ต๋๋ค.
@DzmitryShylovich ๋ด๊ฐ ์ดํดํ๋ ๊ฒ์ AOT๊ฐ ์ด ๊ฒฝ์ฐ์ ์ด ํ์ผ์ ๋ํด ์ ํ ์ ๊ฒฝ ์ฐ์ง ์์์ผ ํ๋ค๊ณ ์๊ฐํ์ง ์๋๋ค๋ ๊ฒ์ ๋๋ค. ์ ์๊ฐ์๋ AOT ์ปดํ์ผ ์ค์ .spec ํ์ผ์ ๊ฑด๋๋ฐ๋ ๊ฒ์ด ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์ ๋๋ค. ํ์ง๋ง ๋ถ๋ช ํ ํ์ด ๊ทธ๋ ๊ฒ ํ๋ ๊ฒ์ ๋ง๋ ๋ฌด์ธ๊ฐ๊ฐ ์๋ค๋ ๊ฒ์ ์ดํดํฉ๋๋ค.
๋์์ผ๋ก, ํ ์คํธ๊ฐ ์์ฑ๋ ์ํฐํฐ์ ๋์ผํ ๋๋ ํ ๋ฆฌ์ .spec ํ์ผ์ ๋ฃ๋ ๊ฒ์ ์คํ์ผ ๊ฐ์ด๋์์ ์ ์ํด์๋ ์ ๋ ๊น์?
๋ํ ํ ์คํธ ์ฝ๋์ AOT์ ์กฐํฉ์ผ๋ก ์ธํด ์ด ์ค๋ฅ ๋ฉ์์ง(๋ฐ ์ผ๋ถ ๋ค๋ฅธ ๋ฉ์์ง)๊ฐ ๋ํ๋ฉ๋๋ค.
๋๋ ์ด ๊ธ ์ ์ถ์ฒํ ์ ์๋ค. ํน์ ์ค๋ฅ ๋ฉ์์ง๊ฐ ์ ๋ฐ๋๋ ๋ฐฉ๋ฒ๊ณผ ํด๋น ์ค๋ฅ๋ฅผ ์์ /ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์ค๋ช ํฉ๋๋ค.
์ฌ๋๋ค์ด ๊ณต์ ํ ์คํธ ๊ฐ์ด๋ ๋ฅผ ๋ฐ๋ฅด๊ณ AOT๋ก ์ฑ์ ๋น๋ํ๋ฉด ์ด ์ ํํ ๋ฌธ์ ์ ๊ฑธ๋ ค ๋์ด์ง ๊ฒ์ด๋ผ๋ ์ ์ ๊ณ ๋ คํ๋ฉด ๊ฐ์ด๋๋ฅผ ์ ๋ฐ์ดํธํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
(๋๊ตฐ๊ฐ RouterLinkStubDirective
์ ๋ํ ๋ต๋ณ์ ์ฐพ๋ ๊ฒฝ์ฐ)
_"๋๋ฏธ" ๋ชจ๋์ ์ถ๊ฐํ์ฌ ์์ ํ ์ ์์ต๋๋ค._
/**
* Needed so that `aot` build is working. But it isn't used throughout our tests and/or app.
*/
@NgModule({
imports: [
AppModule
],
declarations: [
RouterLinkStubDirective,
RouterOutletStubComponent
]
})
export class FakeRouterModule {
}
๊ทธ๊ฑด ๊ทธ๋ ๊ณ , ๊ทธ๊ฒ์ ๋ํ ์ถ์ ํด๋์ค์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ๋ ค๊ณ ์๋ํฉ๋๋ค:
export abstract class AsyncTransform extends AsyncPipe implements PipeTransform {
...
}
"์ค๋ฅ: AsyncTransform ํด๋์ค์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค"
๋ชจ๋์ ์ถ๊ฐํด๋ ์๋ํ์ง ์์ต๋๋ค ๐.
"๋น์ถ์ ์์ฑ์ ์ ํ์ ์ถ์ ์์ฑ์ ์ ํ์ ํ ๋นํ ์ ์์ต๋๋ค."
์ด๊ฒ์ ์ผ๋ถ ํด๋์ค์์๋ ๋ฐ์ํฉ๋๋ค.
์ค๋ฅ: AppGlobalModalComponent ํด๋์ค์ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค.
export class CustomGlobalModalComponent extends AppGlobalModalComponent {}
@gestj @Phmager ๊ฐ ์ง์ ํ๋ฏ์ด ๋๋ฏธ ๋ชจ๋์ด ๋ชจ๋ ๊ฒฝ์ฐ์ ๋ํ ์์ ์ฌํญ์ ์๋๋๋ค. ๋ํ ์ํ์ง ์๊ฑฐ๋ ํ์ํ์ง ์์ ์ฝ๋๋ฅผ ์ปดํ์ผํ๊ฒ ๋๋ฏ๋ก ๊ฝค ๋ฒ๋ฒ ๊ฑฐ๋ฆฌ๋ ์์ ์ ๋๋ค.
์ฐ๋ฆฌ์ ๊ฒฝ์ฐ ๋ฌธ์ ๋ฅผ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ํจ์นํ์ต๋๋ค. ๊ณต์ ๊ตฌ์ฑ ์์๋ฅผ npm lib๋ก ์ด๋ํ๊ณ tsConfig์์ node_modules๋ฅผ ๋ฌด์ํ์ต๋๋ค. ์์์ ์ธ๊ธํ์ง๋ง ์ฌ์ ํ ์๋ํ์ง ์์ง๋ง ๋ฐฐ๋ด ํ์ผ์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ๋๋ค. node_modules ๋ด๋ถ์์ ํ์ํ ๊ฐ ํด๋์ค๋ฅผ ์ง์ ๊ฐ๋ฆฌํค๋ฉด ๋ค๋ฅธ ํด๋์ค๋ ๋ฌด์๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ๋ฐฐ๋ด์ ๊ฐ๋ฆฌํค์ ๋ง์ ๋์ผํ ๋ฐฐ๋ด์ ์๋ ์ฌ์ฉํ์ง ์๋ ํ์ผ์ ๋ํด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ด๊ฒ์ ์ฐ๋ฆฌ์ ๋ชจ๋ ๋ฉ์ง ๋ฐฐ๋ด ํ์ผ์ ์ฃฝ์ด๊ธฐ ๋๋ฌธ์ ์ด์์ ์ด์ง๋ ์์ง๋ง ์ ์ด๋ ์์ธก ๊ฐ๋ฅํฉ๋๋ค.
์ฌ์ ํ ์ด ์ค๋ฅ๊ฐ ๊ฒฝ๊ณ ๋ก ๊ฐ๋ฑ๋๊ธฐ๋ฅผ ๋ฐ๋ผ๊ณ ์์ต๋๋ค.
์ง๊ธ๊น์ง Angular ํ์์ ํ๋ฅญํ ์์
์ ์ํํ์ต๋๋ค.
์ฐ๋ฆฌ๋ ํ๋ก์ ํธ์์ Angular๋ฅผ ๋ง์ด ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ 1๋
๋์ ์ด๋ฌํ ๋ชจ๋ Angular2+ ํญ๋ชฉ์ ๋ํด ๋จธ๋ฆฌ๋ฅผ ์ฐ๋ ค๊ณ ๋
ธ๋ ฅํ ํ ๋ฐ๊ฒฌํ ์ฌํญ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1- Angular๋ ๋ฐฉ๋ํ๊ณ ๋๋ฆฝ๋๋ค. ๋น ๋ฅด๊ฒ ๋ง๋ค๊ณ ์ถ์ต๋๊น? AOT ๋ฐ LazyLoading์ ์ฌ์ฉํ๊ณ ๋ฌผ๊ฑด์ gzip์ผ๋ก ์์ถํ์ญ์์ค.
2- ๊ตฌ์ฑ ์์๋ฅผ lazyLoad ํ์๊ฒ ์ต๋๊น? ์๋์, ๊ฒฝ๋ก๋ฅผ ์ง์ฐ ๋ก๋ํ ์ ์์ผ๋ฏ๋ก ์ฑ์ด ๋ฐฉ๋ํ์ง๋ง ํ์ด์ง๊ฐ ํ๋๋ฟ์ธ ๊ฒฝ์ฐ 8mg ๋ฒ๋ค ํฌ๊ธฐ๋ฅผ ์ฆ๊ธฐ์ญ์์ค.
3- AOT๋ฅผ ์ฌ์ฉํ์๊ฒ ์ต๋๊น ?? AOT๋ ๋ฒ๊ทธ๊ฐ ์๊ณ ์ค์ํ๊ธฐ ์ด๋ ต๊ณ ๋ง์ javascript/es6 ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ง ์์ผ๋ฉฐ ์๋ง๋ ๋ง์ ์ฝ๋๋ฅผ ๋ค์ ์์ฑํ ๊ฒ์
๋๋ค.
4- AOT๋ฅผ ์ ์ฌ์ฉํ๊ณ ์์ต๋๊น? ์, ์ด์ ์ต์ข
๋ฒ๋ค์ ์ดํด๋ณด์ญ์์ค. ์ด์ @angular/compiler์ AOTed๊ฐ ์๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ํ ๊ฒ๋ณด๋ค ํจ์ฌ ํฝ๋๋ค.
5-Angular2+ ํํ์ ์ผ๋ถ๋ก ์ด์ gzip์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด์ ์ ์ฌ์ฉ ๋ฐฉ๋ฒ์ ๋ชฐ๋๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ Angular๊ฐ ๋ฐฉ๋ํ๋ฏ๋ก ๋ ์ ๋ฐฐ์ธ ์ ์์ต๋๋ค. Angular2 ์ฝ๋๋ฅผ ์ต์ ํํ๊ธฐ ์ํ ์ต์ ์ผ๋ก gziping์ ํ๋งคํ๊ณ ์์ต๋๋ค. :)
@xe4me ํ๋ ์์ํฌ์ ๋ํ ์ผ๋ฐ์ ์ธ ๋น๋๋ณด๋ค๋ ๋น๋ฉดํ ๋ฌธ์ ์ ๊ด๋ จ๋ ์ด ์ค๋ ๋์์ ๊ณ์ ๋ ผ์ํ์ญ์์ค.
https://github.com/AngularClass/angular2-webpack-starter ์ build:dev ๋ ํจ์ ์ ์์ ์ผ์นํ๋๋ก ๋ฌธ์์ด์ ๋ฌธ์์ด ๋ฐฐ์ด๋ก ์๋ ๋ณํํ๊ณ build:aot ๋ ์ค๋ฅ๋ฅผ ํ์ํฉ๋๋ค. ๊ฐ๋ฐํ๋ ๋์ ๋น๋ฒํ AOT ๋น๋๊ฐ ํ์ํ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค.
๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์๊ณ ํด๊ฒฐ์ฑ ์ ์ฐพ์์ต๋๋ค. ์๋ง๋ ๋น์ ๋ ์๋ ํ ๊ฒ์ ๋๋ค.
๋ด ์๋๋ฆฌ์ค๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๋ ๊ฐ์ ํ์ดํ๊ฐ ํฌํจ๋ MapPipes.ts๊ฐ ์์ต๋๋ค.
ํ์ดํ ์ค ํ๋๋ ๋ด ๋ชจ๋์์ ์ฌ์ฉ๋์๊ณ ๋ค๋ฅธ ํ๋๋ ์ฌ์ฉ๋์ง ์์์ต๋๋ค. ๋ฐ๋ผ์ ๋ด @NgModule ๋ฐ์ฝ๋ ์ดํฐ์ "์ ์ธ:" ๋ถ๋ถ์ ๋ ๋ฒ์งธ ํญ๋ชฉ์ ๋ฑ๋กํ์ง ์์์ต๋๋ค. ๋ฌธ์ ๋ ์ด ์ด์ ๋ฐ์ํ์ต๋๋ค.
๋๋ ๋ํ ์ด๊ฒ์ ๋ฑ๋กํ๊ณ (์ฌ์ฉ๋์ง๋ ์์์ง๋ง) ์ด์ ์๋ํฉ๋๋ค.
๋ด ์ ์์ ์ค์ ๋ก ์ฌ์ฉ๋๋ ๊ฐ๋ ์ํฐํฐ์ ๋ํด์๋ง ๋ชจ๋์ ์ฐพ์ผ๋ ค๊ณ ์๋ํ๋ ๋ฐฉ์์ผ๋ก ๊ฐ๋ ์ปดํ์ผ๋ฌ๋ฅผ ๋ณ๊ฒฝํ๋ ๊ฒ์ ๋๋ค.
extends NgClass
์ถ์ ํด๋์ค์์ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์์์ ์ ๊ฑฐํ๋ฉด ์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋ ๊ฒ์ฒ๋ผ ๋ณด์ด์ง๋ง ๋ถ๋ช
ํ ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
@DzmitryShylovich @kirjai ์ด๊ฒ์ spec ํ์ผ์ ๋ด๋ณด๋ผ ๋ TestComponents
์๋ง ์๋ ๋ฌธ์ ์
๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ผ๋ฐ์ ์ผ๋ก ๋์ผํ ํ์ผ ๋ด์์๋ง ์ฌ์ฉํด์ผ ํ๋ฏ๋ก ๋ด๋ณด๋ผ ํ์๊ฐ ์์ต๋๋ค. ๋๋ฅผ ์ํด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค.
์์งํ ๋งํด์, ์ด๊ฒ์ ์ฐ์ค๊ฝ์ค๋ฝ์ต๋๋ค. ๋๋ ๋ง์ ์๊ฐ์ ๋ณด๋ด๊ณ ์์ง๋ง ์ฌ์ ํ AOT์ ํจ๊ป ์์ ํ๋ JIT์์ ์๋ํ๋ ๊ฒ์ ์ป์ ์ ์๋ค๋ ์ฌ์ค ์ธ์ ์ด๊ฒ์ ๋ํด ํ ๋ง์ด ์์ต๋๋ค. ์ง๊ธ๊น์ง ์ฝ 6๊ฐ์ ๋ฌธ์ ).
@cwmrowe ๊ด์ฐฎ์ต๋๋ค. ํ์ง๋ง ์ฌ๋ฌ ์ฌ์ ํ์ผ์์ ์ฌ์ฌ์ฉ๋๋ ํ์ผ์ด ์๋ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น์? ์ด๊ฒ์ ์์งํ ๊นจ์ง ๊ฒ ๊ฐ์ต๋๋ค.
์ ๊ฒฝ์ฐ์๋ ๋์ผํ ํต์ฌ Angular 2 ์ฑ์์ 2๊ฐ์ ๋ค๋ฅธ ํ๋ก์ ํธ๋ฅผ ์งํํ๊ณ ์์์ต๋๋ค. ์ฐ๋ฆฌ ํด๋ผ์ด์ธํธ์ ์ด๋ฆ์ ๋ด 2๊ฐ์ ํด๋๊ฐ ์์ต๋๋ค. some-domain.com ๋ฐ some-other-domain.com ์ ๋๋ค. ์ฑ์ 2๊ฐ์ ํ๋ก์ ํธ์ ๋ํด ์์ ํ ๋์ผํ๋ฉฐ ์ฝ๊ฐ์ ์คํ์ผ๊ณผ ์ผ๋ถ ์ฌ์ํ ์ฌ์ฉ์ ์ ์ ๊ตฌ์ฑ ์์๋ง ๋ค๋ฆ ๋๋ค. ์ค๋์ ํด๋ผ์ด์ธํธ A์ฉ์ผ๋ก ์ฑ์ ์ปดํ์ผํด์ผ ํ๊ณ ๋์ค์ ํด๋ผ์ด์ธํธ B์ฉ์ผ๋ก ์ปดํ์ผํ๊ณ ์ถ์ต๋๋ค. ์ฝ๋์์ ์ฝ๋ ํ ์ค์ ๋ณ๊ฒฝํ๋ ๊ฒ๋งํผ ์ฝ์ต๋๋ค.
import {CustomModules} from './some-domain.com';
// import {CustomModules} from './some-other-domain.com';
๋๋ ์ปดํ์ผํ๊ณ ์ถ์ ๋๋ฉ์ธ์ ์ฃผ์์ ์ ๊ฑฐํ๋ฉด ์๋ํฉ๋๋ค.
์ฐ๋ฆฌ๋ ์์ ๋ฐ ์ถ์ ํด๋์ค์ ๋ํด ๋์ผํ ๋ฌธ์ ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ ์ด๋ค ํด๊ฒฐ์ฑ ๋ ์ฐพ์ง ๋ชปํ์ต๋๋ค. ์ถ์ ๊ตฌ์ฑ ์์๋ฅผ ํ์ฅํ๋ ์ผ๋ถ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๋ค. JIT์์๋ ๋ชจ๋ ๊ฒ์ด ํ๋ฅญํ๊ฒ ์๋ํ์ง๋ง AOT์์๋ ์ถ์ ๊ตฌ์ฑ ์์์ ๋ํ ๋ชจ๋์ ์ฐพ์ ์ ์์ผ๋ฉฐ ๋ชจ๋์์ ์ถ์ ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธํ ์ ์์ต๋๋ค.
ํ์ฌ ์ฐ๋ฆฌ๋ oop ๋์์ธ ํจํด์ ํผํ๊ณ ์ค๋ณต ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ ๊ฒ ์ธ์ ๋ค๋ฅธ ํด๊ฒฐ์ฑ ์ด ์์ต๋๋ค.
@jabaa ์ถ์ ํด๋์ค์์ @Component
์ฃผ์ ์ ๊ฑฐ
@DzmitryShylovich @Component
๋ฅผ ์ ๊ฑฐํ๋ฉด ์์ฑ์๊ฐ ์์๋์ง ์์ต๋๋ค. ์ถ์ ๊ตฌ์ฑ ์์ ๋์ ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ชจ๋ ์ฃผ์
๊ฐ๋ฅ ์์๋ฅผ ์ฃผ์
ํด์ผ ํฉ๋๋ค. ์ค๋ณต ์ฝ๋์
๋๋ค. ์ถ์ ํด๋์ค์ ์์ฑ์์ ์๋น์ค๋ฅผ ๋ณ๊ฒฝํ ๋ ๋ชจ๋ ์์ ๊ตฌ์ฑ ์์๋ฅผ ๋ฅ์ํ๊ฒ ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.
ํ์ฌ ์ฐ๋ฆฌ๋ ๋๋ฏธ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ๋ชจ๋ ์ถ์ ๋ฉ์๋๋ฅผ ๊ตฌํํ๊ณ ๋ชจ๋ ์ถ์ ๊ตฌ์ฑ ์์์ ๋ํ ๋๋ฏธ ๋ชจ๋์ ์์ฑํ์ฌ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋๊ตฐ๊ฐ ๋๋ฏธ ๋ฉ์๋๋ฅผ ์ฌ์ ์ํ๋ ๊ฒ์ ์์ ์ ์์ต๋๋ค. ๊ทธ๊ฒ์ ๋ชจ๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋๋ค.
@jabaa ์ด๋ค ๋ฒ์ ์ ์ฌ์ฉํ์ญ๋๊น? ์์ฑ์๋ @Component
์ ๊ด๊ณ์์ด ์์๋์ด์ผ ํฉ๋๋ค.
@bigjetplane ์ด๋์ ๋ฌธ์ ๊ฐ ์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ง๋ง @Component
๋ฅผ ์ ๊ฑฐํ๋ฉด ๊ตฌ์ฑ ์์์ ๋ํ ์ข
์์ฑ์ ์ฐพ์ ์ ์๋ค๋ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋ด๊ฐ ์๋ ํ DI๋ Angular ๋ฐ์ฝ๋ ์ดํฐ๊ฐ ์๋ ํด๋์ค์์๋ง ์๋ํฉ๋๋ค. ๋ฐ๋ผ์ ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ ๊ฑฐํ๋ฉด ์ข
์์ฑ์ด ์ฃผ์
๋์ง ์์ต๋๋ค. ์ฐ๋ฆฌ๋ Angular 4๋ฅผ ์ฌ์ฉํฉ๋๋ค.
@jabaa jit ๋๋ aot ๋๋ ๋ ๋ค๋ก ๊ณ ์ฅ ๋ฌ์ต๋๊น?
@bigjetplane ์ฌ๊ธฐ์ ๋ฌธ์ ๊ฐ ์๋ ํ๋ฐ์ปค๊ฐ ์์ต๋๋ค. ๋ฐ์ฝ๋ ์ดํฐ๊ฐ ์๋ ์ถ์ ํด๋์ค๊ฐ ์์ผ๋ฉฐ ๋ชจ๋ ๊ฒ์ด jit์์ ์๋ํฉ๋๋ค. ์ถ์ ํด๋์ค์์ ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ ๊ฑฐํ๋ฉด ๋ชจ๋ ์ข
์์ฑ์ ๋ก๋ํ ์ ์๊ธฐ ๋๋ฌธ์ ์ฑ์ ๋ ๋๋งํ ์ ์์ต๋๋ค. Can't resolve all parameters for App: (?).
๊ทธ๊ฒ์ด ์ฐ๋ฆฌ์ ์ฌ์ฉ ์ฌ๋ก์ ๋๋ค. ์์ฑ์์ ์ฃผ์ ์ด ์๋ ์ถ์ ํด๋์ค๊ฐ ์์ต๋๋ค. ์ฐ๋ฆฌ๋ ์์ ๊ตฌ์ฑ ์์์ ์ผ๋ถ ์ถ์ ๋ฉ์๋๋ฅผ ์ฌ์ ์ํ๋ ค๊ณ ํฉ๋๋ค.
์ฃผ์ด์ง ์์ ๋ ot์์ ์๋ํ์ง ์์ต๋๋ค. att์ jit์ ์ฐจ์ด๋ ์ฐ๋ฆฌ์๊ฒ ํฐ ๋ฌธ์ ์ ๋๋ค. ์ฐ๋ฆฌ๋ jit์ ํจ๊ป ๊ฐ๋ฐํ๊ณ ์์ต๋๋ค. ํ๋ก๋์ ๋น๋๋ ot์ ํจ๊ป ํฉ๋๋ค. ๊ทธ๋์ ์ฐ๋ฆฌ๋ ์ค๋ฅ์ ๊ฒฝ๊ณ ๊ฐ ์๋ jit์ผ๋ก ํ ์ฃผ๋ฅผ ๊ฐ๋ฐํ๊ณ ์์ผ๋ฉฐ ๊ทธ ์ฃผ ์ดํ์๋ ํ๋ก๋์ ๋น๋๋ฅผ ์ํ๊ณ ์๋ฌด๋ฐ์๋ ๋ง์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋๋ ot ์ค๋ฅ๋ฅผ ํ์ฑํํ ์ ์๋ jit์ฉ ์ค์์น๋ฅผ ์ ํธํฉ๋๋ค. jit ๋น๋๋ 10-20์ด๊ฐ ํ์ํฉ๋๋ค. aot ๋น๋์๋ 25๋ถ์ด ํ์ํฉ๋๋ค.
@tbosch ์ด๊ฒ์ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ ๋ํด ๋ง์ํด ์ฃผ์๊ฒ ์ต๋๊น? ์ง๋๋ฒ ๋ฐฉ๋ฌธ ์ดํ๋ก ๊ฝค ๋ง์ ์ฌ๋๋ค์ด ์์ ์ ์ผํ๋ฅผ ๋ค๋ ค์ค ๊ฒ ๊ฐ์ต๋๋ค. ํน์ ์ ํฌ์๊ฒ ์ต์ ์ ๋ณด๋ฅผ ์ ๊ณตํด ์ฃผ์ค ์ ์๋์ง ๊ถ๊ธํฉ๋๋ค.
๊ฐ์ฌ ํด์!
๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ ๊ฒฝ์ฐ์๋ 2๊ฐ์ ๋ค๋ฅธ ํ๋ก์ ํธ์์ ์์ ํ์ง๋ง package.json์ ์ข ์์ฑ์ผ๋ก ์ถ๊ฐ๋ ๋ด๋ถ ๊ฐ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๋ก์ ํธ๋ฅผ ํตํด ๊ณตํต ๊ตฌ์ฑ ์์๋ฅผ ํฌํจํ์ต๋๋ค.
๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๋ก์ ํธ์ด๋ฏ๋ก ๊ตฌ์ฑ ์์ ์ ์ฅ์์์ ์ฌ์ฉํ์ง ์๋ ๊ตฌ์ฑ ์์๋ AOT ์ ํ ๋น๋๋ฅผ ์ปดํ์ผํ ๋ ์๋ ์ค๋ฅ๋ฅผ ๋ฐ์์ํต๋๋ค.
ERROR in Cannot determine the module for class FullPageErrorComponent in C:/users/amra6003/projects/git/refadmintoolui/n
ode_modules/refcommonui/src/app/component-library/error/error.component.ts!
Cannot determine the module for class SelectCountryComponent in C:/users/amra6003/projects/git/refadmintoolui/node_modul
es/refcommonui/src/app/component-library/select-country/select-country.component.ts!
Cannot determine the module for class DateRangeSelectorComponent in C:/users/amra6003/projects/git/refadmintoolui/node_m
odules/refcommonui/src/app/component-library/date-range-selector/date-range-selector.component.ts!
๊ฐ ๊ตฌ์ฑ ์์์ ๋ํ ๋ชจ๋์ ๋ง๋ค๊ณ ์ฌ์ฉํด์ผ ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ฉด ๋ง์ ๋์์ด ๋ ๊ฒ์ ๋๋ค.
์ ๋ ์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. ๋ถ๋ช ํ ํ ์คํธ๋ฅผ ์ํด ์คํ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ Angular ๊ฐ๋ฐ์๊ฐ ์๋ํ ๊ฒ์ด๋ฏ๋ก ๋น๋์์ ๊นจ๋ํ ๋ฐฉ๋ฒ์ผ๋ก ์ ์ธํ๋ ๊ฒ๋ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค. ์ง๊ธ์ gestj(์คํ ๊ตฌ์ฑ ์์๊ฐ ์ ์ธ๋ ๊ฐ์ง ๋ชจ๋ ์ ์)์์ ์ ์ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
๋ฐ๋ผ์ ํ
์คํธ๋ฅผ ์ํด ์คํ
๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ ๋ whatever.component.spec.ts
spec.ts
์ ๋ฏธ์ฌ๋ก ๊ตฌ์ฑ ์์์ ์ด๋ฆ์ ์ง์ ํ๋ ค๊ณ ํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ผ๋ก tsc๋ ์ด ํ์ผ์ ๋ฌด์ํ๋ฏ๋ก(tsconfig์์ ์ ์ธ๋ ๊ฒฝ์ฐ) ngc์์๋ ๋ฌด์๋ฉ๋๋ค.
ํธ์ง: ์ด๊ฒ์ ngtools/webpack์ ๋ฒ๊ทธ๋ก ์ธํด ๋ค๋ฅธ ์ค๋ฅ๋ก ํ๋ช ๋์์ต๋๋ค. ํด๋น ํฐ์ผ์ https://github.com/angular/angular-cli/issues/6228 ์์ ์ด๋ ธ์ต๋๋ค.
์ฐ๋ฆฌ ํ์ฌ๋ฅผ ์ํ ์๋ก์ด ์ฌ๋ฏธ. ์ต๊ทผ ์์คํ ์ v2.4.10์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ๋ ค๋ ์๋์์ ๋ค์๊ณผ ๊ฐ์ ๋ค์ํ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
ModuleNotFoundError: Module not found: Error: Can't resolve '../../../../../../../../$_gendir/src/components/spinner/component.ngfactory'
ํ์ฌ ์์ฉ ํ๋ก๊ทธ๋จ์์ ์ฌ์ฉํ์ง ์๋ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ํด ๋ก๊น ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด๊ฒ์ ๋ด๊ฐ ์๋ ํฐ์ผ์ ์ด์๋ ์ค๋ฅ์ ์ฌ๋ฉํ ์ ๋๋ก ๋น์ทํฉ๋๋ค.
์ฐ๋ฆฌ๊ฐ ์ด๊ฒ์ ๋ํด ๋ฌด์์ ๋ ํ ์ ์๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ์ฐ๋ฆฌ๋ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ง์ ํ์ํ ๊ฐ ๊ตฌ์ฑ ์์์ ์ฃผ์๋ฅผ ์ง์ ํ๊ณ (์ธ๋ฑ์ค์์ ์ฐธ์กฐํ๋ ๋ชจ๋ ํ์ผ์ ๊ฐ์ ธ์ค๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๋ฏ๋ก index.ts
ํ์ผ์ ์ฌ์ฉํ์ง ์์) ๋ชจ๋ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ node_modules๋ก ์ด๋ํ๋ ค๊ณ ํ์ต๋๋ค.
์ปดํ์ผ๋ฌ๊ฐ ๋ด node_modules
ํด๋์ ๋ชจ๋ ๊ฐ๋ ๊ตฌ์ฑ ์์์ ๋ํด ์์์ผ ํ๋ ์ด์ ๋ ๋ฌด์์
๋๊น? ์ง๋๋ฅผ ์์ฑํ๊ธฐ ์ํด ์ฝ์ด์ผ ํ๋ ๊ฒฝ์ฐ์๋ ๋ชจ๋์ด ์๋์ง ์ฌ๋ถ๋ ์ ๊ฒฝ์ฐ์ง ์์๋ ๋ฉ๋๋ค!
@swimadude66 , ์, ์ฐ๋ฆฌ๋ https://github.com/WealthBar/a2d3 ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ด ๋ฌธ์ ์ ์ง๋ฉดํ์ต๋๋ค. ํ ํ๋ฆฟ ๊ตฌ์ฑ ์์(์ง์๋ฌธ๋ง)๋ฅผ ์ ๊ณตํ์ง ์๋๋ผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ฌ์ ํ AoT ์ปดํ์ผ๋ฌ๋ก ๋น๋ํด์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ์ฌ์ฉ ์ AoT ๋น๋์ ํจ๊ป ์๋ํ์ง ์์ต๋๋ค.
@chrisnicola ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฒ์ํ๊ธฐ ์ ์ AoT๋ก ๋ฏธ๋ฆฌ ์ปดํ์ผํด์ผ ํ๋ค๋ ๋ง์์ด์ ๊ฐ์? ์ด๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์์ฒด ๋ชจ๋์ด ์์์ ์๋ฏธํ๊ธฐ ๋๋ฌธ์ ์ค์ ๋ก๋ ์ง๊ด์ ์ด์ง ์์ต๋๋ค. ๊ทธ๋๋ก ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ปดํ์ผ๋์ง ์์ ts ํ์ผ์ด๋ฉฐ ํ๋ก์ ํธ์ ๋ค๋ฅธ ํ์ผ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก ๊ฐ์ ธ์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ชจ๋ ๊ฒ์ด @ngtools/webpack ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ์ฌ webpack์ ์ปดํ์ผ๋ฉ๋๋ค.
์ด ํฐ์ผ์ ์๋ ์ค๋ฅ๋ index.ts ํ์ผ์ ๋ํ ๋ชจ๋ ์ฐธ์กฐ๋ฅผ ์ ๊ฑฐํ์ฌ v2.1.1๊น์ง "์์ "๋์๋ค๋ ์ ์ ์ฃผ๋ชฉํ ๊ฐ์น๊ฐ ์์ต๋๋ค. ํด๋น ์์ ์ฌํญ์ ๋ ์ด์ v2.4.10์์ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
์, ๋ค, ๋ฌธ์ ๋ฅผ ์๋ชป ์ฝ์์ต๋๋ค. ์ฌ๊ธฐ์ NPM์ ํตํด ๋ฏธ๋ฆฌ ์ปดํ์ผ๋ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ์ด ์๋๋ผ ํ๋ก์ ํธ์ ๋ก์ปฌ TS ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์์ต๋๋ค. ๋ด๊ฐ ์ง๊ธ ์ ๋๋ก ์ดํดํ๊ณ ์๋ ๊ฑธ๊น?
๋๋ ๊ทธ๊ฒ์ด "๊ทธ๋ฅ ์๋"ํด์ผํ๋ค๋ ๋ฐ ๋์ํ๊ณ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ชจ๋์ด์๋ ๊ตฌ์ฑ ์์๋ฅผ ์ฐพ๋ ๊ฒ๊ณผ ๋์ผํ ๋ฌธ์ ์ฒ๋ผ ๋ค๋ฆฝ๋๋ค. ๊ฐ๋ฅํ ์๋ฃจ์
์ AoT ๋น๋์ ํ์ํ์ง ์์ ํ์ผ๊ณผ ํด๋๋ฅผ ์ ์ธํ๋ AoT ๋น๋ ํน์ tsconfig.json
์ ์ฌ์ฉํ๋ ๊ฒ์
๋๋ค.
์ด ์ค๋ฅ์ ๊ด๋ จ๋ ๋ชจ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
๋ด๋ณด๋ผ ๋ ๋ฌธ์ (๋ฐ ์๋ฃจ์
)๊ฐ ๋ํ๋ฉ๋๋ค.
ํ ์คํธ์ฉ์ผ๋ก๋ง ์ฌ์ฉ๋ ๊ตฌ์ฑ ์์๊ฐ ์์์ต๋๋ค. ์ฌ์ฌ์ฉํ ์ ์๋๋ก ๋ค๋ฅธ ํ์ผ์์ ๋ด๋ณด๋์ต๋๋ค. ์ด๋ก ์ธํด i18n ๋์์ ์คํํ ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
๊ทธ๊ฒ์ ํด๊ฒฐํ๊ธฐ ์ํด ์ฐ๋ฆฌ๋ ๋ฐฉ๊ธ ๋ชจ๋์ ์ ์ธํ์ต๋๋ค(๋ฐ๋์ ๋ด๋ณด๋ด๊ธฐ๋ ํ์ธ์):
@NgModule({ declarations: [MyUnusedComponent] })
export class IgnoreModule {}
์ค๋ฅ๋ฅผ ์ผ์ผํจ ๋ค๋ฅธ ๊ตฌ์ฑ ์์๋ i18n์ ํดํนํ ๋ฏธ์ฌ์ฉ ๊ตฌ์ฑ ์์์์ต๋๋ค.
i18n ๋๊ตฌ์์ ์ ํํ๊ธฐ ์ํด ๋ด๋ณด๋ด๊ณ ์์์ง๋ง ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
@Component({
template: `
<div i18n="some context@<strong i="13">@some</strong> key">some text to be translated</div>
`
})
export class LocalisationComponent {}
๋ค์ IgnoreModule ๊ธฐ์ ์ ์ฌ์ฉํ๋ฉด ์ฝ๊ฒ ์ฐํํ ์ ์์ต๋๋ค.
@NgModule({ declarations: [LocalisationComponent] })
export class IgnoreModule {}
@UtopianStorm ์ ์๋ฃจ์ ์ด ์๋๋๋ค. "UnusedModule"์ ๊ฐ๋ ๊ฒ์ ํ์ฅํ๊ธฐ ์ด๋ ค์ธ ๋ฟ๋ง ์๋๋ผ ๋ฐฐํฌ ๋ฒ๋ค์ ํฌํจ๋์ด์๋ ์ ๋๋ ์์ค ํ์ผ์ ์ ์ฒด ๋ชจ๋์ ์์ฑํ๋ค๊ณ ์์์ ์ธ๊ธํ์ต๋๋ค.
@Phmager ์ถ์ ๊ตฌ์ฑ ์์ ๋ฌธ์ ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฐพ์ ์ ์ด ์์ต๋๊น? ๋จธ๋ฆฌ์นด๋ฝ์ ๋ฝ๊ณ ์์ต๋๋ค.
@swimmadude66 ํ์คํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด๋ผ๋ ์ ์์ ์๋ฃจ์
์ ์๋์ง๋ง ์ค๋ฅ๋ฅผ ๊ทน๋ณตํฉ๋๋ค.
๋ฌธ์ ๊ฐ ๋ฐ์ํ ๋๋ง๋ค ๊ธฐ์ ์ ์ ์ฉํ ์ ์์ผ๋ฏ๋ก ํ์ฅ์ด ์ผ๋ง๋ ์ด๋ ค์ธ์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
๋ฐฐํฌ ๋ฒ๋ค์ ๋ณต์กํ๊ฒ ๋ง๋ค์ง๋ง ๊ทธ๊ฒ ๋ฌธ์ ๊ฐ ๋ ๊น์? Angular์ ์ํ์์ ๋๋ ๊ทธ๊ฒ์ด ์ด๋ฏธ ์ฌ์ ํ์ผ๋ก ๊ฐ๋ ์ฐจ ์์ ๊ฒ์ด๋ผ๊ณ ๊ฐ์ ํ์ต๋๋ค.
์ด์จ๋ node_modules ํด๋์ ๋ด์ฅ์ ์ง์ ๋๋ฌํ๋ ๊ฒ๋ณด๋ค ํจ์ฌ ๋ ๊น๋ํ ์ ๊ทผ ๋ฐฉ์์
๋๋ค. ๋์ํ์ง ์์ต๋๊น?
์ ์ด๋ ๋ด๊ฐ ์ฒ์์ ํฐ์ผ์ ์ด์๋ ์ฌ์ฉ ์ฌ๋ก์์๋ ์คํ ๊ฐ๋ฅํ ํด๊ฒฐ ๋ฐฉ๋ฒ๋ ์๋๋๋ค. ๋ชจ๋ ํํธ๋ ํ์ด ๊ณ์ ์งํํ๋ฉด์ ์ฌ์ฉํ์ง ์๋ ๊ณต์ ๊ตฌ์ฑ ์์ ๋ชฉ๋ก์ ์ ์ง ๊ด๋ฆฌํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค.
๋ํ ์ปดํ์ผ๋ฌ๊ฐ ์ง๋์น๊ฒ ์๊ฒฉํ๊ธฐ ๋๋ฌธ์ ๊ธฐ๋ณธ์ ์ผ๋ก 2๊ฐ์ ์ ์ฒด ์ฑ์ ์ ๊ณตํ๋ ๊ฒ์ ํํํ๊ณ ์ถ์ง ์์ต๋๋ค. Angular๋ ์ด๋ฏธ ๊ฝค ํฌ๋ฉฐ, ์์ ์ ๋ ๋จ์ ์ธ ์ปดํ์ผ๋ฌ๋ฅผ ๋ง์กฑ์ํค๊ธฐ ์ํด ์ฌ์ฉํ์ง ์๋ ๊ตฌ์ฑ ์์์ ์ ์ฒด ๋ชจ๋์ ๋ฐฐ์กํ๋ ๊ฒ์ ์ ๋นํํ ์ ์์ต๋๋ค.
@swimmadude66 ์๊ฒ ์ต๋๋ค . ๋ค๋ฅธ ๋ชจ๋์ ์ถ๊ฐํ๋ ๊ฒ์ด ๊ทธ๋ ๊ฒ ํฐ ์ฐจ์ด๋ฅผ ๋ง๋ ๋ค๊ณ ์๊ฐํ๋ค๋ฉด ์ง์ ๋ค์ ํ ๋ฒ ์ดํด๋ณด๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ ์ฒด ํ๋ก์ ํธ์์ ๊ณต์ ํ ์ฌ์ฉํ์ง ์๋ ๋ชจ๋์ ํ๋๋ง ๋ง๋๋ ๊ฒ์ด ์๋๋ผ ํด์ ํด์ผ ํ๋ ๋ชจ๋ ๋จ์ผ ๊ตฌ์ฑ ์์์ ๋ํด ํ๋์ ๋ชจ๋์ ๋ง๋๋ ๊ฒ์ ์นํธํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ์ง๋์น๊ฒ ์๊ฒฉํ ์ปดํ์ผ๋ฌ์์ - ์ ์ฌ์ ์ผ๋ก dusins.
๊ณต์ ์ฝ๋๋ฒ ์ด์ค๊ฐ ์๋นํ ํฌ๊ธฐ ๋๋ฌธ์ ์ฌ์ฉํ์ง ์์ ๋ชจ๋์ด ์ฑ์์ ๊ฐ์ฅ ํฐ ๋ชจ๋์ด ๋ ๊ฒ์ด๋ผ๋ ์ ์ ์ฃผ๋ชฉํ ๊ฐ์น๊ฐ ์์ต๋๋ค. ์ฐ๋ฆฌ์ ์ํฉ์ด 100% ์ผ๋ฐ์ ์ธ ๊ฒ์ ์๋์ง๋ง ์ฌ์ ํ ์ง์ง๋ฐ์ ์ด์ ๊ฐ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์์งํ ์ด ํฐ์ผ์ด ์๋ฌด๋ฐ๋ ๊ฐ์ง ์๋ ๊ฒ์ ์ง์ผ๋ณธ 5๊ฐ์ ํ, ์ฐ๋ฆฌ๋ ๊ณต์ ์ฝ๋ ์ ์ฅ์๋ฅผ ์ข ๋ฃํ๋ ๊ฒ์ ํฌํจํ์ฌ ๋ค๋ฅธ ์ต์ ์ ์ฐพ๊ณ ์์ต๋๋ค.
@swimmadude66 ๋ ๊ณผ ๋๊ฐ์ ๋ฌธ์ ์ ์ง๋ฉดํ๊ณ ์์ต๋๋ค. ์ด๊ฒ์ด ์ต์ ํ ์ ์๋ ๊ฒฝ๊ณ ๊ฐ ์๋๋ผ๋ ์ฌ์ค์ ์ฐ์ค๊ฝ์ค๋ฝ์ต๋๋ค.
์น์ ํ๋ Angular ํ, ์ด์ ๋ํด ํ ์ ์๋ ์ผ์ด ์์ต๋๊น?
@DzmitryShylovich ์ฌ์ฉํ์ง ์๋ mock.ts
ํ์ผ์ ์ด๋ป๊ฒ ์ ์ธํฉ๋๊น? tsconfig.app.json
, tsconfig.json
๋ฐ tsconfig.ng-cli.json
์ ๋ฃ์ด ๋ณด์์ง๋ง ์๋ฌด ๊ฒ๋ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋๊ฐ์ ์ฌ์ฉ ์ฌ๋ก๋ก ๋์ผํ ๋ฌธ์ ์ ์ง๋ฉด - ์ฐ๋ฆฌ๋ ๋กค์ ์ ์ฌ์ฉํ๋ฏ๋ก ์ฌ์ฉํ์ง ์๋ ๊ตฌ์ฑ ์์๋ ๊ถ๊ทน์ ์ธ ๋ฒ๋ค์ ํฌํจ๋์ง ์์ต๋๋ค.
์ด๊ฒ์ ์ต์ ํด์ฃผ์ธ์! ๊ทธ๊ฒ์ ํฐ ๊ณจ์นซ๊ฑฐ๋ฆฌ์ด๋ฉฐ ์์ ์ ์ค๋จํ๊ณ ์์ต๋๋ค.
๋๋ ๋ฐฉ๊ธ ์ด๊ฒ์ ๋ถ๋ช์ณค๋๋ฐ, ๋๋ฌด ๋ต๋ตํ๋ค.
@mlakmal ๋ฐ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๊ธฐํ ์ฌ์ฉ์
export class CustomGlobalModalComponent extends AppGlobalModalComponent {}
$ AppGlobalModalComponent
@Component
์ฃผ์์ ์ ๊ฑฐํ๊ฑฐ๋ $ NgModule
AppGlobalModalComponent
(์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒฝ์ฐ)๋ฅผ ์ ์ธํฉ๋๋ค.
๋ด ํ ์คํธ์์ ์ฌ์ฉํ๊ธฐ ์ํด ๋ชจ์ ์ง์๋ฌธ์ ๋ง๋ค์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ AOT ์ปดํ์ผ๋ก ์ด ๋ฌธ์ ๋ฅผ ์ป์ผ์ญ์์ค. ์ด ๋ชจ์ ์ง์๋ฌธ์ ์ผ๋ฐ ๋ชจ๋๋ก ๊ฐ์ ธ์ค๊ณ ์ถ์ง ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ธ์.
์ด ๋ฌธ์ ์ ๋ํ "freq1: low" ํ๊ทธ๊ฐ AoT๊ฐ ์๋ํ๋ ๋ฐ ๋๋ฌด ๊ณ ํต์ค๋ฌ์ ์ฌ๋๋ค์ด ์ ๊ฒฝ ์ฐ์ง ์๋๋ค๋ ์ฌ์ค ๋๋ฌธ์ธ์ง ๊ถ๊ธํฉ๋๋ค. ์ด๋ ๊ฒ ๊ฐ๋จํ์ง๋ง ๊ณ ํต์ค๋ฌ์ด ๋ฌธ์ ๊ฐ ํต์ฌ Angular ๊ธฐ์ฌ์๋ก๋ถํฐ ๊ธฐ๋ณธ์ ์ผ๋ก ์ ํ ํผ๋๋ฐฑ์ ๋ฐ์ง ๋ชปํ๋ค๋ ์ฌ์ค์ด ์กฐ๊ธ ๋ฏฟ๊ธฐ์ง ์์ต๋๋ค.
์ด์จ๋ ๊ตฌ์ฒด์ ์ผ๋ก ์ธ๊ธ๋์ง ์์ ํ์ผ์ ์ ์ธํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ์ด๋ฆ ์ง์ ํจํด(์: .spec.ts
, .abstract.ts
, .stfu-aot.ts
)์ด ์๋ ๊ฒฝ์ฐ AoT์ ๋ํด ๋ณ๋์ tsconfig.json
ํ์ผ์ ๋ง๋ค๊ณ ๋์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ngc -p tsconfig-aot.json
. ์ด ํ์ผ์์ "exclude": ["./app/**/*.stfu-aot.ts"]
๋ฅผ ์ฌ์ฉํ์ฌ ํ์ผ์ ์ ์ธํ ์ ์์ต๋๋ค. ์ฑ๊ฐ์ ์ผ์ด์ง๋ง ์๋ํด์ผ ํฉ๋๋ค.
ํธ์ง: ์์ ๋ด์ฉ์ ๊ตฌ์ฑ ์์์์ ์์๋๋ abstract
ํด๋์ค์์ ์๋ํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ผ :(
๋ฐฉ๊ธ ์ด๊ฒ์ ๋ถ๋ช์ณค์ต๋๋ค. ๋๋ฌด ์ค๋ง ์ค๋ฝ์ต๋๋ค. aot๋ฅผ ๋น๋ํ๋ฉด ๋ค๋ฅธ ์ฑ์์ ๊ณตํต ๊ตฌ์ฑ ์์๋ฅผ ๊ณต์ ํ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ์ผ๋ฐ์ ์ธ ๊ฒฝ์ฐ ์ค ์ผ๋ถ๋ ์๋น์ค ํด๋์ค์ @Component ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ํผํ์ญ์์ค.
// just remove this
@Component({
providers: []
});
@Injectable()
export class serviceClass {}
์๋น์ค์ ์๋น์ค๋ฅผ ์ฃผ์
ํ๋ ์๋๋ฆฌ์ค๊ฐ ์์ต๋๋ค. ์ธ๋ป ๋ณด๊ธฐ์๋ ๊ตฌํํ๊ธฐ ์ฌ์ด ๊ฒ์ฒ๋ผ ๋ณด์ด์ง๋ง @Component๋ฅผ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ณต์กํ ์๋น์ค์ ๋ํ ์ด ์๋ฃจ์
์ ํ์ํ๋๋ก Angular ๋ฌธ์๋ฅผ ์
๋ฐ์ดํธํด์ผ ํฉ๋๋ค. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด @Component๋ฅผ ์ ๊ฑฐํ์ต๋๋ค. ์๋น์ค ์์ฑ์์์ ๋ค์์ ์ถ๊ฐํ์ต๋๋ค.
constructor(@Inject(ExampleService) private exampleService: ExampleService)
์ด๋ค ์๋น์ค์๋ @Component()
๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ถ๊ฐํ ํ์๊ฐ ์์ต๋๋ค. @Injectable()
FWIW์๋ XYZComponent
์ฑ ๊ตฌ์ฑ ์์๋ฅผ ํ์ฅํ์ง๋ง ์ฌ์์์๋ง ์ฌ์ฉ๋๋ MockXYZComponent
๊ฐ ์์ต๋๋ค(๊ฐ์ ์ ํ๊ธฐ๊ฐ ์์ผ๋ฏ๋ก AppModule
๋ก ๊ฐ์ ธ์ฌ ์ ์์).
์ด๊ฒ์ ์ ํจํ ์ฌ์ฉ ์ฌ๋ก๊ฐ ์๋๋๊น?
@alastair-todd ๋ฌด์จ ๋ง์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๊ตฌ์ฑ ์์๋ฅผ ๊ตฌ์ฑ ์์๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ @Component()
๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ถ๊ฐํฉ๋๋ค. ๊ตฌ์ฑ ์์๋ฅผ ๊ธฐ๋ณธ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๊ตฌ์ฑ ์์์์ ์์ํ๊ธฐ ์ํด์๋ง ์ฌ์ฉํ์ง๋ง ๊ตฌ์ฑ ์์๋ก ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ฌ์ฉํ ํ์๊ฐ ์์ต๋๋ค. ํ์ง๋ง "ํ์์"์์ ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์์ํ๊ณ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.
๋จ์ ํ
์คํธ์ ๋ํด - ์๋ตํ ์ ์์ต๋๋ค. ์๋ง๋ ํน๋ณํ TestModule์ ๋ง๋ค์ด์ผ ํฉ๋๊น? ๋๋ ํ์ฌ ๋จ์ ํ
์คํธ๋ฅผ ํ์ง ์๋๋ค.
@tytskyi ๋ฐ์ฝ๋ ์ดํฐ ์์์ด ์ง์๋์ง ์๋๋ค๋ ๊ฒ์ ์ดํดํ์ต๋๋ค. ์ต๊ทผ์ ๋ณ๊ฒฝ๋์๋์?
์ ์ค ์ผ์ด์ค๋ ์๋์ ๊ฐ์ด ํ์ ๊ตฌ์ฑ ์์๋ฅผ ์กฐ๋กฑํ๋ ๊ฒ์ ๋๋ค. ๋ ๋ค ์ ํ๊ธฐ๋ฅผ ์ ํํ๋ ค๋ฉด @Component ์ง์๋ฌธ์ด ํ์ํฉ๋๋ค.
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
AppModule
]
}).overrideModule(AppModule, {
remove: {
declarations: [SelectionToolComponent]
},
add: {
declarations: [MockSelectionToolComponent]
}
}).compileComponents();
๊ทธ๋ฌ๋ OP AOT ์ปดํ์ผ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ์์ ์ AOT ์ปดํ์ผ์ด ํ๋ก์ ํธ์ ์ผ๋ถ๋ก ์ง๋์น๊ฒ ์ด์ฑ์ ์ด๊ฑฐ๋ ์ฌ์์ ๋ฌด์ํ๋ ์ ํจํ ์ฌ์ฉ ์ฌ๋ก์ ๋๋ค.
๋ด ์๋ฃจ์ ์ด ๋๊ตฐ๊ฐ์๊ฒ ๋์์ด ๋ ์๋ ์์ต๋๋ค. ๋ฐฉ๊ธ ๋ชจ๋ ๋ชจ์ ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธํ๋ ๋๋ฏธ ๋ชจ๋์ ๋ง๋ค์์ต๋๋ค. ์ด ๋ชจ๋์ ์๋ฌด ๊ฒ๋ ๊ฐ์ ธ์ค์ง ์์ต๋๋ค. ๋จ์ง AoT ์ปดํ์ผ๋ฌ๋ฅผ ๋ง์กฑ์ค๋ฝ๊ฒ ์ ์งํฉ๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ๋ชจ์ ๊ตฌ์ฑ ์์๋ ์ปดํ์ผ๋ ์ฝ๋์ ์ผ๋ถ๊ฐ ์๋๋๋ค. ์ด์์ ์ด์ง๋ ์์ง๋ง ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค.
๋ ๋์ ์๋ฃจ์ ์ ๋ํด ๋ฃ๊ณ ์ถ์ต๋๋ค.
์ด ๋ฌธ์ ๊ฐ 2016๋ 12์์ ์ด๋ ธ๊ณ ์ฌ์ ํ ์ด ๋ฌธ์ ๊ฐ ์๋ค๋ ๊ฒ์ด ๋๋ฌด ์ด์ํ๊ณ ๋ถ๋๋ฝ์ต๋๋ค. ๋๋ ์ปดํ์ผ์ ์ฌ์ฉํ๋๋ก ์ ์ฒด ์ฑ์ ๊ตฌ์กฐ๋ฅผ ๋ณํํ์ต๋๋ค. ์ง์ฐ ๋ก๋๋ 4๊ฐ์ ๋ชจ๋๊ณผ 60๊ฐ ์ด์์ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๋ค. ์ปดํ์ผ๋ฌ๋ ๋์๊ฒ ์ด์ํ ์ข ๋ฅ์ ์ง์ฐ ๋ก๋ ๋ชจ๋ ์ค ํ๋์ ์ ์ธ์ ์ด๋ฏธ ํฌํจ๋์ด ์๋ค๊ณ ํ์ ํ๋ ๋ช ๊ฐ์ง ๊ตฌ์ฑ ์์(์ค๋ฅ๊ฐ ์์ฌํ๋ ๋ฐ์ ๋ฐ๋ผ)์ ๋ํด์๋ง ๋ถํํฉ๋๋ค.
์ด๋ฏธ ์ผ๋ถ ๋ชจ๋์ ์ผ๋ถ์ธ ๊ตฌ์ฑ ์์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ธฐ๋ ํฉ๋๋ค.
๊ฐ์ ๋ฌธ์
Angular์ ์ปดํ์ผ๋ฌ๋ tsconfig์ ์ ๋ฌํ ํ์ผ ์ธํธ๋ฅผ ์ฐพ์ต๋๋ค. ๋ฐ๋ผ์ ๊ฑฐ๊ธฐ์์ ํ์ผ์ ์ ์ธํ๋ฉด ์ด ๊ฒ์ฌ์์ ์ ์ธํด์ผ ํฉ๋๋ค.
์ด๊ฑด ์ ๋ง ์ง์ฆ๋๋ค์ :(
@alastair-todd ์ฃ์กํฉ๋๋ค. ๋ค๋ฅธ ์๋ฆผ์์ ์ง๋ฌธ์ ๋ํ ์๋ฆผ์ ์์ด๋ฒ๋ ธ์ต๋๋ค. ๋น์ ์ด ์ฌ๋ฐ๋ฅธ์ง -
๋ฐ์ฝ๋ ์ดํฐ ์์์ ์ง์๋์ง ์์ต๋๋ค.
@robwormald ์ ๋ต๋ณ ๋ณด๊ธฐ
Angular์ ์ปดํ์ผ๋ฌ๋ tsconfig์ ์ ๋ฌํ ํ์ผ ์ธํธ๋ฅผ ์ฐพ์ต๋๋ค. ๋ฐ๋ผ์ ๊ฑฐ๊ธฐ์์ ํ์ผ์ ์ ์ธํ๋ฉด ์ด ๊ฒ์ฌ์์ ์ ์ธํด์ผ ํฉ๋๋ค.
๋ฐ๋ผ์ selection-tool.component.mock.ts
์ ๊ฐ์ด ๋ชจ์ ํ์ผ ์ด๋ฆ์ ๋ํ ๊ท์น์ ๋ง๋ค ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ค์์ ํตํด ์ ์ธ
"exclude": [
//... other excludes
"**/*.component.mock.ts"
]
์ค์๋ก ์๋ชป๋ ๋ฒํผ์ ํด๋ฆญํ์ต๋๋ค. ์ฃ์กํฉ๋๋ค!
+8๊ฐ์์ด ์ง๋ฌ์ง๋ง ์ฌ์ ํ ๋ฌธ์ ์
๋๋ค. ๊ฐ์ ๋ฌธ์ ERROR in Cannot determine the module for class PasoFooterComponent
Angular ๊ฐ๋ฐ์๊ฐ ์ด๋ฌํ ํ์ผ์ ๋ฌด์ํ๋ ๊ฒ์ด ์ค์ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
๋๊ตฐ๊ฐ ์ด ์ฝ๋๋ฅผ ์ฐพ์ ์ ์๋ ์์น์ ๋ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์๋ค๋ฉด ๊ธฐ์ ๊ฒ์
๋๋ค.
์ค์ค๋ก ํด๊ฒฐํ๊ธฐ ์ํด. ์ด๊ฒ์ ๋งค์ฐ ์ฑ๊ฐ์ ์ฑ๊ฐ์ฌ์
๋๋ค. ๊ทธ๊ฒ์ ๋ฐ์ด
๋ ์ด์ .
๋๊ตฐ๊ฐ ์ด๊ฒ์ด ๋ฒ๊ทธ๊ฐ ์๋๋ผ ๊ธฐ๋ฅ์ด๋ผ๊ณ ์๊ฐํ๋ค๋ฉด ํ๋๊ทธ๊ฐ ์๋ ๊ฒ์ ์ด๋ป์ต๋๊น?
์ด๊ฒ์ ์ํด?
2017๋
8์ 9์ผ ์์์ผ ์ค์ 2:40 Leonardo Vidal [email protected]
์ผ๋ค:
+8๊ฐ์์ด ์ง๋ฌ์ง๋ง ์ฌ์ ํ ๋ฌธ์ ์ ๋๋ค. ๋์ผํ ๋ฌธ์ ๊ฐ ์ฌ๊ธฐ์ ์ค๋ฅ๊ฐ ์์ต๋๋ค.
PasoFooterComponent ํด๋์ค์ ๋ชจ๋ ๊ฒฐ์ โ
๋น์ ์ด ๋๊ธ์ ๋ฌ์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๋ ๊ฒ์ ๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/angular/angular/issues/13590#issuecomment-321082545 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/AEM6r7FOTLcicWJN3Oijw2pwKTLGL6cFks5sWM61gaJpZM4LSAwS
.
@samirotiv ๋ณต์ ํ์ด ์์ต๋๊น?
@robwormald ๊ฐ ๋งํ๋ฏ์ด
Angular์ ์ปดํ์ผ๋ฌ๋ tsconfig์ ์ ๋ฌํ ํ์ผ ์ธํธ๋ฅผ ์ฐพ์ต๋๋ค. ๋ฐ๋ผ์ ๊ฑฐ๊ธฐ์์ ํ์ผ์ ์ ์ธํ๋ฉด ์ด ๊ฒ์ฌ์์ ์ ์ธํด์ผ ํฉ๋๋ค.
๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์์ง๋ง ํด๊ฒฐํ์ต๋๋ค. ์๋ฅผ ๋ค์ด ts๊ฐ ๋ด ์ฑ์ ์ด๋ป๊ฒ ํธ๋์คํ์ผํ๋์ง ์ดํด๋ณด์์ต๋๋ค.
"tsc": "rimraf out-tsc/app && tsc -p ./src/tsconfig.app.json",
๊ทธ๋ฆฌ๊ณ "files" tsconfig ์ต์ ์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ typescript๊ฐ ์ง์ฐ ๋ก๋๋ ๋ชจ๋์ ์ปดํ์ผํ์ง ์๋๋ค๋ ๊ฒ์ ์์์ต๋๋ค.
์ถ์ ํด๋์ค(๋ฐ์ฝ๋ ์ดํฐ ์์)์์ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ต๊ทผ์ ๊ฐ์ ๋ฌธ์ ์ ์ง๋ฉดํ๊ธฐ ์์ํ์ต๋๋ค.
์ค๋ฅ๋ฅผ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ๋ ค๋ฉด +1์ ๋๋ค.
์ฝ๊ฒ ๊ณ ์น ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. ์ ์ง์ฐ?
์ด๊ฒ์ ๊ธฐ๋ณธ ์๊ตฌ ์ฌํญ์
๋๋ค. ์ฐธ์กฐ๋์ง ์์ ํ์ผ์ ๊ทธ๋๋ก ๋์ญ์์ค.
์ด ์ ํ์ ๋ ํฐ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ๋ฌธ์ ์
๋๋ค. ์ด๊ฒ์ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ์ญ์์ค.
๋ค๋ฅธ ๋ฒ์ ์ Angular๋ฅผ ์ง์ํ๋ ํจํค์ง๋ฅผ ๊ฒ์ํ๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. ์ฌ์ฉ์๋ ๊ทธ ์ค ํ๋๋ฅผ ์ ํํด์ผ ํฉ๋๋ค.
์๋ฅผ ๋ค์ด HttpClient
(Angular >= 4.3 ์ฌ์ฉ์) ๋ฐ Http
(Angular < 4.3 ์ฌ์ฉ์)์ ๋ํ ํ์ผ์ ์ ๊ณตํ๋ ํจํค์ง
ํ์ฌ ngc ๋ ์ฌ์ฉ ์ฌ๋ถ์ ๊ด๊ณ์์ด ์์ค ๋๋ ํ ๋ฆฌ ๋ด์ ๋ชจ๋ ํ์ผ์ ์ปดํ์ผํฉ๋๋ค! ๋๋ ๋น๋๊ฐ ์คํจํฉ๋๋ค.
๋ด๊ฐ ํ ์ผ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๋ด ๋ชจ๋ ์คํ /๋ชจ์ ๊ตฌ์ฑ ์์๋ฅผ .mock.ts ํ์ฅ์๋ก ์ ์ฅํ๊ณ ๋ค์๊ณผ ๊ฐ์ด tsconfig.app.json "exclude" ๋ฐฐ์ด์ ์ ๋ฐ์ดํธํ์ต๋๋ค.
...
"exclude": [
"test.ts",
"**/*.spec.ts",
"**/*.mock.ts"
]
...
AOT๋ ์ด์ ์ด๋ฌํ ํ์ผ์ ์ปดํ์ผ์ ๊ฑด๋๋๋๋ค.
์ฐ๋ฆฌ๋ ํ ๋ฒ์ ๋ชจ๋ ์ฌ์ฉ๋์ง ์์์ผ ํ๊ณ AoT ์ปดํ์ผ ์ค์ ํด๋น ๋ฌธ์ ๋ก ์ธํด ํ๋ ๊ณตํต ๊ตฌ์ฑ ์์๋ก npm ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ํํ๊ณ ์์ต๋๋ค. ์ ์ฅ... ์ ์ผํ ์๋ฃจ์
atm์ ํธ์คํธ ํ๋ก์ ํธ์์ ์ผ์ข
์ UnusedComponentsModule์ ๋ง๋๋ ๊ฒ์
๋๋ค. ๋ํ NO_ERRORS_SCHEMA
๊ฐ ํ์ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ์ฌ์ฉํ์ง ์๋ ๊ตฌ์ฑ ์์ ๋ด๋ถ์์ ์ฌ์ฉํ ์ ์๋ ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ๋ํด ๋งน์ธํ๊ณ ์ด๋ฅผ ์ ์ธํ๋ฉด ๋ ๋ชจ๋์์ ๋์ผํ ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธํ ์ ์๋ ๋ ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค(# ๊ด๋ จ 10646).
๋ด ํ์ฌ ๋ชจ๋:
import {NgModule, NO_ERRORS_SCHEMA} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ReceiverPageComponent} from 'cb-web-platform';
@NgModule({
imports: [
CommonModule,
],
declarations: [
ReceiverPageComponent
],
schemas: [
NO_ERRORS_SCHEMA // IMPORTANT: need that for AoT compilation
]
})
export class UnusedComponentsModule {
}
์ด๊ฒ์ ์ ๋ง๋ก ๊ฒฝ๊ณ ํด์ผํฉ๋๋ค. ์ ๋ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ๊ณต์ ํ๋ ค๊ณ ํ๊ณ ์์ผ๋ฉฐ ngmodule์ ์ผ๋ถ๊ฐ ์๋ ๊ตฌ์ฑ ์์์ ๋ํ ์ด ๋ฌธ์ ๋ฅผ ๊ฒช๊ณ ์์ต๋๋ค.
์ฌ๊ธฐ์ ๋ฌธ์ ๋ ์ค๋ฅ๊ฐ ์๋ ์ฌ์ฉํ์ง ์์ ๋ณ์์ ์ ํํ ๋์ผํฉ๋๋ค. ๊ธฐ๊ปํด์ผ ๊ฒฝ๊ณ ์
๋๋ค.
๋น์ ์ ์ฝ๋๋ผ๋ฉด ์ฝ์ต๋๋ค. ์ผ๋ถ NPM ๊ฐ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ(์ผ๋ถ ๋ฐ๋ ์ฝ๋)์ ๋ฌธ์ ์ธ ๊ฒฝ์ฐ ์ ๋ง ๊ณจ์น ์ํ ์ผ์ ๋๋ค. :)
์ค๋ฅ ๋์ ๊ฒฝ๊ณ ๊ฐ ํ์๋์ง ์๋ ์ด์ ๋ฅผ ์ค๋ช ํ ์ ์๋ ์ฌ๋์ด ์์ต๋๊น?
์ ๊ฒฝ์ฐ์๋ ngModule์ ์ฐ๊ฒฐ๋ ๊ตฌ์ฑ ์์์์ lang์ ์ถ์ถํ๊ณ ๊ทธ๋ ์ง ์์ ๊ตฌ์ฑ ์์๋ ๋ฌด์ํ๊ณ ์ถ์ต๋๋ค. ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์์ ์์ฉ ํ๋ก๊ทธ๋จ๋ณ ํด๋๊ฐ ์๋ ํ๋์ ๊ธฐ๋ณธ ์์ฉ ํ๋ก๊ทธ๋จ ํด๋๊ฐ ์๋๋ฐ xi18n์ผ๋ก ์ฌ์ ์๋ ๊ตฌ์ฑ ์์๋ฅผ ์ถ์ถํ๋ ค๊ณ ํ ๋ ๊ธฐ๋ณธ ์์ฉ ํ๋ก๊ทธ๋จ์ ๊ตฌ์ฑ ์์๋ฅผ ๋ฌด์ํ๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค Cannot determine the module for class...
์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ฌ์ฉํ์ง ์์ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๊ณ์ํ ์ ์์ต๋๋ค.
๋ฌธ์ ๊ฐ ๋ ์ ์๋ค๊ณ ์๊ฐํ ์ ์๋ ํ ๊ฐ์ง๋ ์ค๋ฅ๊ฐ ์๋ ๊ตฌ์ฑ ์์ ํ์ผ์ ์ ์๋ ํด๋น ํด๋์ค๋ฅผ ์ฌ์ ์๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ง๋ค๊ธฐ ์ํ ๊ธฐ๋ฐ์ผ๋ก ์ฌ์ฉํ๋ฏ๋ก ์ปดํ์ผํด์ผ ํ์ง๋ง ํด๋น ๊ตฌ์ฑ ์์๊ฐ ํ์ํ์ง ์๋ค๋ ๊ฒ์ ๋๋ค. ์ค๋ฒ๋ก๋ ๊ตฌ์ฑ ์์์์ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก ์ฃผ์ ์์ธ. ์ ์ด๋ ํ์ ๊ตฌ์ฑ ์์์์ ์ฃผ์์ ๋ค์ ๋ง๋ค์ด์ผ ์๋ํ๊ธฐ ๋๋ฌธ์ ๊ทธ๋ ๊ฒ ํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
@Xesenix ๋ ์ต์ํ ์ต์ ์ด์ด์ผ ํฉ๋๋ค. ๊ฒฐ์ ๋ชจ๋ = false / true์ ๊ฐ์ต๋๋ค. ์ด์ ๋ฐ๋๋์ ๋๋ค.
๋๋ 2017๋ 11์ 1์ผ์ ๋์์ฌ ๊ฒ์ด๋ค.
๋๋ ๋์ ๋ฐํ ํ์ ๋น์ ์ ๋ฉ์์ง์ ๋๋ตํ ๊ฒ์
๋๋ค.
๊ธด๊ธํ ๊ฒฝ์ฐ ์ด๋ฉ์ผ ์ฌ๋ณธ์ ๋ณด๋ด์ฃผ์ญ์์ค.
๊ธฐ์ ์ ์ธ ๋ฌธ์ ๋ [email protected] ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด
[email protected]. ๊ทธ๋ฌ๋ฉด ๋ค๋ฅธ ์ง์์ด ๊ทํ์ ์ด๋ฉ์ผ์ ๋ณผ ๊ฒ์
๋๋ค.
๋์ํ๊ธฐ.
์ฐธ๊ณ : ์ด๊ฒ์ "Re:
[๊ฐ๋/๊ฐ๋] Angular2 AOT ์ปดํ์ผ - "๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค.
for class (... ์ฌ์ฉ๋์ง ์๋ ๋ง์ ๊ตฌ์ฑ ์์)" (#13590)" ์ ์ก๋จ
2017๋
10์ 23์ผ 08:13:17
์ด๊ฒ์ ๊ทํ๊ฐ ์์ ํ๋ ์ ์ผํ ์๋ฆผ์
๋๋ค.
๊ทธ ์ฌ๋์ ๋ถ์ฌ์ค์ด๋ค.
๊ฑฐ์ 1๋ ์ด ์ง๋ ์ง๊ธ๋ ์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์ง ์๋ ์ด์ ๋ ๋ฌด์์ ๋๊น? AOT๊ฐ ์๋ํ๋๋ก ๋จธ๋ฆฌ๋ฅผ ์ก์๋น๊ฒผ์ง๋ง ์ด ๋ฌธ์ ๋ก ์ธํด ๋ฒฝ๋ ๋ฒฝ์ ๋ถ๋ชํ์ต๋๋ค.
์๋ฃจ์
์ ๋ํด @rahul-sivalenka-wtc์๊ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
์ค๋ช
ํ์ ๋๋ก tsconfig.app.json
"**/*.mock.ts"
๋ฅผ ์ ์ธํ์ฌ ๋ฌธ์ ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ํด๊ฒฐํ ์ ์์์ต๋๋ค. โค๏ธ
๋์์ด ๋ ์ ์์ด์ ๊ธฐ์ฉ๋๋ค ๐
๋๋ ๋ํ ๋ฌธ์ ๋ฅผ ๋ง๋ฌ๋ค. ํ์ง๋ง ๋์๊ฒ๋ dodule์ ๊ฐ์ ธ ์ค๋ ๊ฒฝ๋ก๋ฅผ ์๋ชป ์ ๋ ฅ ํ ๊ฒ ๊ฐ์ต๋๋ค.
์ด๋ค ์๋ฃจ์ ? (๊ตฌ์ฑ์์ angular 5์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์)
https://stackoverflow.com/questions/47119135/cannot-determine-the-module-for-component-angular-5
severity3: broken
์ฌ์ผ ํฉ๋๋ค. ์ฌ๋ฌ ๋น๋ ๋์๊ณผ ๋คํ์ฑ ์ข
์์ฑ์ด ์๋ ๊ฒฝ์ฐ(๋ง์ ์ฌ์ฉ ์ฌ๋ก๊ฐ ์์ ๋์ ์์) ์ด ๋ฌธ์ ๋ก ์ธํด ๋ณต์กํ ๋น๋ ์ค์ ์์ด ๋น๋๊ฐ ์๋ํ์ง ์์ต๋๋ค.
์์ง ์ด ๋ฌธ์ ์ ๋ํ ์ข์ ํด๊ฒฐ์ฑ ์ด ์์ต๋๊น? IgnoreModule์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ ๋ฟ์ด์ง ์ด ๋ฌธ์ ์ ๋ํ ์ข์ ํด๊ฒฐ์ฑ ์ ์๋๋๋ค. ์ค๋ฅ๋ฅผ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ด ์ข์ต๋๋ค!
์ฐ๋ฆฌ์ ํด๊ฒฐ์ฑ
์ transform
ํจ์๋ฅผ @ngtools/webpack
์ ์ถ๊ฐํ๋ ๊ฒ์ด์์ต๋๋ค. @ngtools/webpack๋ ์ ์ฒ๋ฆฌ ๋ฅผ ํตํด ํ์ผ์ ์ ๋ฌํ๊ณ ifdef
๋ ๋ค์ํ ์ปดํ์ผ ์๊ฐ ์ค์ ์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌ์ฑ ์์๋ฅผ ์ฒ๋ฆฌํฉ๋๋ค. ๋งค์ฐ, ๋งค์ฐ ๋ชป์๊ฒผ์ง๋ง ๊ธฐ๋ฅ์ ์
๋๋ค.
๋จผ์ app.module.ts์์ ๋ชจ๋ ๊ฐ๋ ์ข ์์ฑ์ ๊ฐ์ ธ์จ ๋ค์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ ธ์ค์ญ์์ค.
` ---------------- ์ฒซ ๋ฒ์งธ ์ข
์์ฑ ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ -----------------------
'@angular/platform-browser'์์ { BrowserModule } ๊ฐ์ ธ์ค๊ธฐ;
"@angular/common"์์ { CommonModule } ๊ฐ์ ธ์ค๊ธฐ;
'@angular/core'์์ { NgModule } ๊ฐ์ ธ์ค๊ธฐ;
import { RouterModule, Routes } from '@angular/router';
'@angular/http'์์ { HttpModule } ๊ฐ์ ธ์ค๊ธฐ;
'@angular/forms'์์ { ReactiveFormsModule } ๊ฐ์ ธ์ค๊ธฐ;
'@angular/platform-browser/animations'์์ { BrowserAnimationsModule } ๊ฐ์ ธ์ค๊ธฐ;
---------- ๊ทธ๋ฐ ๋ค์ ์๋น์ค ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ ------------------------
'./Services/apply-form-post.service'์์ { ApplyFormPostService } ๊ฐ์ ธ์ค๊ธฐ;
'./Services/nav-bar-color.service'์์ { NavBarColorService } ๊ฐ์ ธ์ค๊ธฐ;
----------------------- ๋ง์ง๋ง์ผ๋ก ๊ตฌ์ฑ ์์ ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ ----------------------- -
'./app.component'์์ { AppComponent } ๊ฐ์ ธ์ค๊ธฐ;
'./components/header/header.component'์์ { HeaderComponent } ๊ฐ์ ธ์ค๊ธฐ;
'./components/career/career.component'์์ { CareerComponent } ๊ฐ์ ธ์ค๊ธฐ;
import { HomeComponent } from './Components/home/home.component';`
์ด๋ป๊ฒ ๋ ์ด๊ฒ์ ์์ฐ ๋ชจ๋์์ ํด๋์ค์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์๋ค๋ AOT ์ปดํ์ผ ์ค๋ฅ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
@KarthikSamyak ์ด ๋ฌธ์ ๋ ๋ชจ๋์ ์์ด์ผ ํ๋ ํด๋์ค๊ฐ ์๋ ์ฌ๋๋ค์ ๊ดํ ๊ฒ์ด ์๋๋๋ค. ์ด๊ฒ์ ์๋์ ์ผ๋ก ๋ชจ๋ ๋ชจ๋์์ ์ ์ธ๋ ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ์ฌ๋๋ค์ ๊ดํ ๊ฒ์ ๋๋ค. ์ปดํ์ผ๋ฌ์์ ๋ฌด์ํด์ผ ํ๋ ์ฌ์ฉ๋์ง ์๋ ์ฝ๋์ ๋๋ค. ๋์ ์ปดํ์ผ๋ฌ๋ ์ค๋ฅ๋ฅผ ๋ฐ๊ฒฌํ ๋ ๋ณต๊ตฌํ ์ ์๋ ์ค๋ฅ๋ฅผ ๋ฐ์์ํต๋๋ค.
์ด ์ค๋ฅ๋ฅผ ๊ฒฝ๊ณ ๋ก ๋ง๋๋ ๊ฒ์ ์ ๋ง ๊ฐ๋จํ ๋ณ๊ฒฝ์ด์ด์ผ ํ์ง๋ง ์ด๋ค ์ด์ ๋ก ์ธํด 1๋ ์ด ๋๊ฒ ๊ฑธ๋ ธ๊ณ ์ต๊ทผ ๋ก๋๋งต์์ pri_col1์์ pri_col2๋ก ์ด๋๋์์ต๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ์๋ต์ด ์ ํ ์๋ Angular ํ์ ์ ์ ๋ ์ข์ ๊ฐ์ ๋๋ผ๊ณ ์์ต๋๋ค. ์ฐ๋ฆฌ ํ์ฌ๋ ๊ฒฐ๊ตญ ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉ์ ์์ ํ ํฌ๊ธฐํ๊ณ ๋์ ์๋์ผ๋ก ํ์ผ์ ๋ณต์ฌํ๊ธฐ๋ก ๊ฒฐ์ ํ์ต๋๋ค. ๊ฑฐ์ ๋์ผํ์ง๋ง ๊ณต์ ๋์ง ์๋ ๊ตฌ์ฑ ์์์ ๋ฌธ์ ๊ฐ ์์ผ๋ฏ๋ก ์ด๋ ์ด์์ ์ด์ง ์์ต๋๋ค.
Angular ํ, ์ด ๋ฌธ์ ๋ฅผ ๋ ์ด์ ์ฝ์ผ์ ๋ค๋ฉด "ignoreUnusedComponents"์ ๋ํ ์ปดํ์ผ๋ฌ ์ค์ ์ ์ถ๊ฐํ๊ณ ์ด ํ๋ ์์ํฌ๋ฅผ ๊ณ์ ์ฌ์ฉํ๋๋ก ํ์ญ์์ค.
์ข์, ๋๋ https://github.com/angular/angular/blob/master/packages/compiler/src/aot/compiler.ts#L605 @tbosch ์ด๋ด, ์ฌ๊ธฐ๋ฅผ ๋์์ฃผ๊ณ ๊ทธ๊ฒ์ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋งํด ์ค ์ ์์ต๋๊น? ์ ๋๋ก ๊ฒฝ๊ณ ๊ฐ ๋ ๊ฒ์ธ๊ฐ? ํด๋น AoT ์ปดํ์ผ๋ฌ์์ ๋ฐ์ํ ๊ฒฝ๊ณ ๋ ๋ณผ ์ ์์ผ๋ฉฐ ์ค๋ฅ๋ง ํ์๋ฉ๋๋ค. ์์์ ์ ์ํ ๋๋ก ์ปดํ์ผ๋ฌ ์ต์ ์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
๊ทธ ๋ฌธ์ ๋ ๋ณต์กํ ํ๋ก์ ํธ์ ๊ณจ์นซ๊ฑฐ๋ฆฌ์ ๋๋ค. ๋ด ํน๋ณํ ๊ฒฝ์ฐ๋ https://github.com/angular/angular/issues/13590#issuecomment -331820496์ ๋๋ค.
์ฐ๋ฆฌ์ ์ฌ์ฉ ์ฌ๋ก๋ ๋์ผํฉ๋๋ค. ์ฐ๋ฆฌ๋ ์ฑ์ ์ ๋ง ์ฝ๊ฒ ๋ง๋ค๊ณ ํ์ํ ๋ ์ด์ํ ๊ฒ์ ๊ต์ฒด/ํ์ฅํ ์ ์๋ ๋ชจ๋/์ปดํฌ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ํฉ๋๋ค.
๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ชจ๋ ๋ด๋ถ์ 1x ๊ตฌ์ฑ ์์๋ฅผ ๊ต์ฒดํ๋ ค๋ฉด ์ ๋ชจ๋์ ๋ง๋ค๊ณ ์ฌ์ ํ ์ํ๋ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
import { HeaderComponent, SidebarComponent } from '@mylibs/layout';
import { FooterComponent } from './footer.component';
@NgModule({ declarations: [ HeaderComponent, SidebarComponent, FooterComponent ] })
export class MyLayoutModule { }
@NgModule({ imports: [ MyLayoutModule ] })
export class AppModule { }
์ค๋ฅ: `HeaderComponent๊ฐ lib/module.ts ๋ฐ app/module.ts ์ 2๊ฐ ๋ชจ๋์์ ์ ์ธ๋์์ต๋๋ค.
๋์ ๊ฒฝ๊ณ ๊ฐ ๋๋ ๊ฒ์ ์ ์ด๋ ์ฐ๋ฆฌ๊ฐ ์์ผ๋ก ๋์๊ฐ ์ ์๊ฒ ํด ์ค ๊ฒ์
๋๋ค :(
๋ฐฉ๊ธ ๊นจ๋ฌ์์ต๋๋ค - ์ด ๋ฌธ์ ์ ์์ผ์ ์ถํํฉ๋๋ค :)
1๋ ํ, ์ฐ๋ฆฌ๋ ์ฌ์ ํ ์ด๊ฒ์ ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. ๋ง๋ ์๋๋.
๋ง ๊ทธ๋๋ก์ด ๋ฌธ์ ๋ ๋ฐ์ํ์ต๋๋ค. ์ปดํ์ผ๋ฌ๋ ํ ์คํธ์์๋ง ์ฌ์ฉ๋๋ ๋ชจ์ ๊ฐ์ฒด๋ฅผ ๊ฐ์ ธ์ค๋ ค๊ณ ์๋ํ์ง๋ง ๋ฉ์ธ ๋ชจ๋์ ์ผ๋ถ๊ฐ ์๋๊ธฐ ๋๋ฌธ์ ์คํจํฉ๋๋ค. ํ์ผ์ด ํ์ํ์ง ์๋ค๋ ๊ฒ์ ์๊ณ ์๋ค๋ฉด ๊ธฐ๊ปํด์ผ ๊ฒฝ๊ณ ์ผ ๊ฒ์ ๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ธ์. ๊ฒฝ๊ณ ๋ก ๋ง๋์ญ์์ค!
Angular 5ot ๋น๋์ ๋ํ ๋์ ์ผ๋ฐ์ ์ธ ๊ฒฝํ์ ํ๋ฅญํ์ง ์์ต๋๋ค.
๋ช ๊ฐ์ง ํ ๋ก ํ https://gitter.im/angular/angular?at=5a551f565a9ebe4f756843b2 ์ฐ๋ฆฌ๋ ๋ชจ๋์ด ์ปดํ์ผ ์ปจํ ์คํธ์ผ ๋ฟ์ด๊ณ ๋ฌผ๊ฑด์ ๋ชจ์ผ๋ ๋ฐฉ๋ฒ์ด ์๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๊ธฐ ๋๋ฌธ์ ๋ชจ๋๋น ํ๋์ Component๋ฅผ ์์ฑํด์ผ ํ๋ค๋ ๊ฒฐ๋ก ์ ๋๋ฌํ์ต๋๋ค. .
์ด๊ฒ์ ์ญ์ฌ์ฑ ์ ํฌ๊ธฐ๋ฅผ ์ทจํ๊ณ ์์ต๋๋ค.
@Xesenix ... ์ปจํ ์คํธ์ ์กฐ์ง์ ์ ์ฒด์ ๋ ๋ถ๋ถ์ ๋๋ค.
๋๊ตฐ๊ฐ๊ฐ ์ฌ์ ํ ์ด๊ฒ์ ๊ฐํ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ ์ด ์คํฌ๋ฆฝํธ๋ฅผ ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก ์ค์น ํ ์คํฌ๋ฆฝํธ๋ก ์คํํ ์ ์์ต๋๋ค.
const replace = require('replace-in-file');
const filesToFix = [
{
files: 'node_modules/@angular/compiler/esm2015/compiler.js',
from: ['throw syntaxError(messages.join(\'\\n\'));'],
// Actually this does nothing , just leave it blank should do
to: [`console.warn(\'Angular compiler warning\');\n\t\tconsole.warn(messages.join(\'\\n\'));`]
}
]
filesToFix.forEach((i) => {
try {
const changes = replace.sync(i);
if (changes.length > 0) {
console.log('Modified files:', changes.join(', '));
}
}
catch (error) {
console.error('Error occurred:', error);
}
});
๊ฐ๋ ์ปดํ์ผ๋ฌ๋ tsconfig์ ์ถ๋ ฅ์ ์ฌ์ฉํ๋ฏ๋ก _tsconfig.app.json_ ์ ๋ณ๊ฒฝํ์ฌ ํฌํจํ์ง ์์ผ๋ ค๋ ํ์ผ์ ์ ์ธํฉ๋๋ค.
์
"exclude": [
"test.ts",
"**/*.spec.ts",
"**/*.mock.component.ts",
]
@andela-andrewmakenzi ์ด๊ฒ์ ์ด ๊ฑฐ๋ํ ์ฑํ ์์ ๋ ๋์๊ฐ ์ด์ ์ ์ ์๋์์ต๋๋ค(์ ์ฒด ๋ด์ฉ์ ์ฝ์ง ์๋ ๊ฒ์ ์ ๋ ๋ถ๋๋ฌ์ด ์ผ์ด ์๋๋๋ค). ๊ทธ๋ฌ๋ ๋ฐฐ๋ด ํ์ผ(index.ts)์ ์ฌ์ฉํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ํ ๊ตฌ์ฑ ์์์ ์์กดํ๋ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ๋ฐฐ๋ด ํ์ผ์์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ ธ์ค๋ฉด ์ปดํ์ผ๋ฌ๋ ํด๋น ๋ฐฐ๋ด ํ์ผ์์ ์ฐธ์กฐํ๋ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ก๋ํ๋ ค๊ณ ์๋ํ๊ณ ํด๋น ๊ตฌ์ฑ ์์๊ฐ ๋ชจ๋์ ์๋ค๊ณ ๋ถํํฉ๋๋ค. ์ด๊ฒ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ปดํฌ๋ํธ ์ํคํ ์ฒ์ ์์ ์ธ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํจํค์งํ๊ธฐ ์ด๋ ต๊ฒ ๋ง๋ญ๋๋ค.
๊ทํ์ ์๋ฃจ์ ์ ๋ชจ์ ๊ตฌ์ฑ ์์๊ฐ ์๊ณ ํ ์คํธ๋ฅผ ์คํํ์ง ์์ ๋ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ์ฌ๋๋ค์๊ฒ ํจ๊ณผ์ ์ ๋๋ค. ๊ทธ๋ฌ๋ ๊ทํ์ ์กฐ์ง(์ ์ ๊ฐ์)์ด ๊ณตํต ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง๋ค๊ณ ์ฃผ์ด์ง ํ๋ก์ ํธ์ ํ์ํ ๊ฒ๋ง ๊ฐ์ ธ์ค๋ ค๊ณ ํ๋ฉด ์ฌํ๊ฒ๋ TSC์ ์ ์ธ๊ฐ ๋์์ด ๋์ง ์์ต๋๋ค.
@andela-andrewmakenzi: ๊ทํ์ ์ ์์ด ์ง๊ธ์ ๋์์ด ๋๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด์ ์ ๋ฌธ์ ๋ ๋จ์ ํ ์คํธ๋ฅผ ์ํ ๊ตฌ์ฑ ์์๊ฐ ( .spec)์ด๊ณ AOT ๋น๋์ ํฌํจ๋๋ ๊ฒ์ ์ํ์ง ์๋๋ค๋ ๊ฒ์ ๋๋ค. ๋ด ํ๋ก์ ์ ์ ๊ทธ๊ฒ์ ๊ฐ๊ณ ์ถ์ง๋ ์์ต๋๋ค.) ์๋ง๋ ์ด๊ฒ์ Angular์ ์ดํ ๋ฒ์ ์์ ์ด๋ป๊ฒ ๋ ํด๊ฒฐ๋์์ ๊ฒ์ ๋๋ค :)
ํ์ง๋ง ์ ๊ฒฝ์ฐ์๋ NgModule์์๋ ์ฐธ์กฐ๋์ง ์์ ์ ๊ตฌ์ฑ ์์๊ฐ ๋ง์ด ์์ผ๋ฏ๋ก ํ์ฌ๋ก์๋ ํด๋น ๊ตฌ์ฑ ์์์ ๋ํ ์ด๋ฆ ๊ท์น์ด ์์ด์ผ ํ๊ณ tsconfig.json์์ ์ ์ธํด์ผ ํฉ๋๋ค. ์ด๋ ๋น๋ถ๊ฐ ๊ทธ๋ค์ง ์ ์พํ์ง ์์ต๋๋ค.
์ด๊ฑด ์ ๋ง ์๊ธฐ๋ค. ๋ช ๊ฐ์ ํ์ดํ/์ง์๋ฌธ์ ๋ด๋ณด๋ด๋ ๊ณต์ NPM ๋ชจ๋์ด ์์ผ๋ฉฐ ๋ชจ๋ ๊ฐ์ ธ์ค์ง ์์ผ๋ฉด ์ด ๋ฉ์ฒญํ ์ค๋ฅ๋ก ์คํจํฉ๋๋ค. ์ค์ ๋ก ๊ฒฝ๊ณ ๋ก ๋ณ๊ฒฝ๋์ด์ผ ํ๋ฉฐ ์ปดํ์ผ์ ์ค๋จํด์๋ ์ ๋ฉ๋๋ค.
์ ์๊ฐ์๋ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ ์์ฒด NgModule
์ ์์ด์ผ ํฉ๋๋ค. ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ํด ๋ค๋ฅธ NgModule
๋ฅผ ๋ง๋๋ ๊ฒ์ ๊ทธ๋ฆฌ ๋ฌด์ญ์ง ์์ต๋๋ค. ( @angular/material
๊ฐ ํ๋ ๊ฒ์ฒ๋ผ)
๋๋ ๊ทธ๊ฒ์ด ์ ๋ง๋ก ๊ฐ์์ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ๋ค. ์ฐ๋ฆฌ๋ ์ค๊ฐ์ ๋ฌด์ธ๊ฐ๋ฅผ ๊ฐ์ง ์ด์ ๋ ์์ต๋๋ค. NgModule
๋ ์๋๊ณ ํจํค์ง๋ ์๋๊ณ ์ฑ ํธ๋ฆฌ ์ธ๋ถ๋ ์๋ ... ์ฃฝ์ ์ฝ๋๋ก ๋ณด์ด๋ ๊ฒ.
๋ฐ๋ผ์ ์๋ก์ด @angular/cli(1.7.0+)๋ฅผ ์ฌ์ฉํ๋ฉด IgnoreModule๋ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ๋ชปํฉ๋๋ค.
์ ์๊ฐ์๋ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ ์์ฒด NgModule์ ์์ด์ผ ํฉ๋๋ค.
๋จ์ ํ ์คํธ๋ฅผ ์์ฑํ๋ ค๊ณ ์๋ํฉ๋๊น? ์ด ๋ฒ๊ทธ๋ก ์ธํด ํ ์คํธ ๋์ฐ๋ฏธ๋ฅผ ๋ง๋๋ ๋ฐ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
@sarunint ๋ด๊ฐ ์ฒ์์ ์ด ํฐ์ผ์ ์ด์๋ ๊ฒ๊ณผ ๊ฐ์ ์ํฐํ๋ผ์ด์ฆ ํฌ๊ธฐ์ ์์ฉ ํ๋ก๊ทธ๋จ์์๋ ์ข ์ ์ง์๋ฌธ ๋ฐ ๊ตฌ์ฑ ์์๋ฅผ ์ฒ๋ฆฌํ๊ธฐ ์ํด ๋งค์ฐ ๋ณต์กํ ๊ฐ์ ธ์ค๊ธฐ๊ฐ ํฌํจ๋ ์๋ฐฑ ๊ฐ์ ๋ชจ๋์ด ๋ ๊ฒ์ ๋๋ค. ์ด๊ฒ์ ๋งค์ฐ ๊ฐ๋จํ ์์ ์ฌํญ์ด ์์ต๋๋ค. ์ปดํ์ผ๋ฌ๊ฐ ๊ตฌ์ฑ ์์์ ๋ํ ๋ชจ๋์ ์ฐพ์ ์ ์์ผ๋ฉด ๊ฒฝ๊ณ ๋ฅผ ํ์ํ๊ณ ํธ๋ฆฌ ์์ดํน์์ ์ ๊ฑฐํ์ญ์์ค.
์ด๊ฒ์ด ๋งค์ฐ ์ฑ๊ฐ์ ์ง์ง ์ด์ ๋ ๋ฐฐ๋ด ํ์ผ์ด ํํ๋ณด๋ค ๋ ์ํํ๋ค๋ ์ฌ์ค์ ๋๋ค. ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์ค์ ์ง์คํํ๋ ๊ฒ์ด ํธ๋ฆฌํ์ง๋ง ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๋ชจ๋ ์ฑ์ ๋ด๋ณด๋ธ ๋ชจ๋ ๋จ์ผ ๊ตฌ์ฑ ์์๋ฅผ ํฌํจํ๋ ๊ฒฝ์ฐ์๋ ๊ทธ๋ ์ง ์์ต๋๋ค.
@dborisenkowork ๋๋ ๋น์ ์ด ๊ทธ๊ฒ์ ๋ณด์ง ์์๋์ง(๋๋ ๊ทธ๊ฒ์ด ๋น์ ์ ์ฌ์ฉ ์ฌ๋ก์ ๋ํด ์๋ํ์ง ์๋์ง) ํ์คํ์ง ์์ง๋ง @rahul-sivalenka-wtc๊ฐ ์ ๊ณตํ ์๋ฃจ์ ์ ์๋ฒฝํ๊ฒ ์๋ํฉ๋๋ค.
์ต๊ทผ์ ๊ฐ๋ 4์์ ๊ฐ๋ 5๋ก ์ด๋ํ๊ณ ๋ชจ๋์์ ์ค์ ๋ก ์ ์ธ๋๋ ๊ตฌ์ฑ ์์ ์ค ์ผ๋ถ์์ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ๊ฒ์ ๋ณธ ์ฌ๋์ด ์์ต๋๊น?
@novologic-clay ๋ฌด์จ ์ค๋ฅ? ์ค๋ ๋๊ฐ ๊น๋๋ค. ์๋ ์ค๋ฅ๋ฅผ ๋ง์ํ์๋ ๊ฑด๊ฐ์?
Angular2 AOT ์ปดํ์ผ - "ํด๋์ค์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค(... ์ฌ์ฉ๋์ง ์๋ ๋ง์ ๊ตฌ์ฑ ์์)" ?
@andela-andrewmakenzi ์ ๋ฐ ์๋์ค. ์ปดํ์ผ์ ์๋ํ ๋ ์ถ๋ ฅ๋๋ ๊ฒ๊ณผ ๋์ผํ ์ค๋ฅ์ด์ง๋ง, ๋ถํํ๋ ๊ตฌ์ฑ ์์๊ฐ ๋ชจ๋์ ํฌํจ๋์ด ์๋ ๊ฒ์ด ๊ฐ์ฅ ํ์คํฉ๋๋ค. 4.3.6์์ 5.2.4๋ก ๋ง์ด๊ทธ๋ ์ด์ ์ค์ด๋ฉฐ angular ๋ฒ์ ์ ์ ๋ฐ์ดํธํ๊ธฐ ๋๋ฌธ์ ์ด ํน์ ๊ตฌ์ฑ ์์์ ๋ํด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์๊ณ ์ฐ๊ธฐ ํ ์คํธ๋ก ๋ง์ด๊ทธ๋ ์ด์ ์ ์์ํ๊ธฐ ์ง์ ์ 4.3.6์์ AOT ์ปดํ์ผ์ ์ํํ์ต๋๋ค. .
@novologic-clay ์ฝ์ ์ค๋ฅ๋ฅผ ๊ณต์ ํ ์ ์์ต๋๊น?
... ์ต์ข
๋ชฉํ๋ tsconfig.json
์ต์
"noUnusedLocals": true
์ ์ฌ์ฉํ์ฌ ์ฌ์ฉํ์ง ์๋ ๋ชจ๋ ๊ฒ์ ์ ๊ฑฐํ๋ ๊ฒ์
๋๋ค.
@andela-andrewmakenzi
ERROR in : Cannot determine the module for class InlineAddComponent in /Users/claygarland/CatalsytConnect/frontend/Talon/src/app/core/component/input/inline-add/inline-add.component.ts! Add InlineAddComponent to the NgModule to fix it.
์ด๊ฒ์ ์ํฐํ๋ผ์ด์ฆ ์ ํ๋ฆฌ์ผ์ด์ ์ด๊ณ ์์ญ ๊ฐ์ ๋ชจ๋ ๋ฐ ๊ฐ์ ธ์ค๊ธฐ ๋ ์ด์ด๊ฐ ์์ง๋ง ์ค์ ๋ก ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธํ๋ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
**COMPONENT:**
import {Component, Inject, Input} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
import {ActivatedRoute} from '@angular/router';
import {BaseForm} from '../../form/form/BaseForm';
import {FormDataService, FormDataServiceProvider} from '../../form/form/FormDataService';
import {BaseApi} from '../../../api/BaseApi';
@Component({
selector: 'inline-add',
templateUrl: './inline-add.component.html',
styleUrls: ['./inline-add.component.scss'],
providers: [
FormDataServiceProvider
]
})
export class InlineAddComponent extends BaseForm {
@Input() title = 'Entity';
@Input() formName;
protected service: BaseApi;
constructor(
protected route: ActivatedRoute,
protected formDataService: FormDataService,
public dialogRef: MatDialogRef<InlineAddComponent>,
@Inject(MAT_DIALOG_DATA) public data: {
form: string,
title: string,
service: BaseApi,
},
) {
super();
this.title = data.title;
this.formName = data.form;
this.service = data.service;
}
submit() {
super.onSubmit(res => {
this.dialogRef.close(res.data[0]);
});
}
onCancel() {
this.dialogRef.close(false);
}
}
**MODULE:**
import { NgModule } from '@angular/core';
import {SharedModule} from '../../../shared/shared.module';
import {InlineAddComponent} from './inline-add/inline-add.component';
@NgModule({
imports: [
SharedModule,
],
declarations: [
InlineAddComponent,
],
exports: [
InlineAddComponent,
],
entryComponents: [
InlineAddComponent,
]
})
export class FormInputsModule { }
๋ํ ng serve์์ ์ด ์์ฉ ํ๋ก๊ทธ๋จ์ ์คํํ ๋ ๊ตฌ์ฑ ์์๊ฐ ์ ๋๋ก ์๋ํฉ๋๋ค.
๋ง์ ์ค์ ๊ตฌ์ฑ ์์์ ํ
์คํธ์ ์ฌ์ฉ๋๋ ๊ฐ์ง ๊ตฌ์ฑ ์์๋ ๋ชจ๋์ ์์ด์๋ ์ ๋ฉ๋๋ค. ํ
์คํธ๋ ๊ตฌ์ฑ ์์์ TestBed์ ํฌํจ๋ฉ๋๋ค.
์ด ์ค๋ฅ๋ ์ด๋ฆฌ์์ ๊ฒ์
๋๋ค. 1๋
๋ถํฐ ๊ทธ๋๋ก ํด๊ฒฐํด ์ฃผ์ธ์.
"๋ด๋ณด๋ด๊ธฐ"๋ฅผ ์ ๊ฑฐํ์ฌ ts๊ฐ ๋น๋๋ก ๊ฐ์ ธ์ค์ง ์๋๋ก ํฉ๋๋ค.
@tony-kaplan tsconfig์ noUnusedLocals๊ฐ ์๊ฑฐ๋ ํ ์คํธ ์ผ์ด์ค ๋๋ ์ด์ ์ ์ฌํ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ ค๋ ๊ฒฝ์ฐ์๋ ๊ทธ๋ ๊ฒ ํ ์ ์์ต๋๋ค.
๋ง์์ฌ.... ํต์ฌ ํ์ ๋๊ตฌ๋ ์ด์ ๋ํ ์ ์ ํ ์๋ฃจ์
์ ์ฐพ์ง ๋ชปํ๋ค๋ ๊ฑด๊ฐ์?
์ง๊ธ์ exclude
์ต์
์ ์ฌ์ฉํ๊ณ ์์ง๋ง ์ฌ์ ํ ์์ ์๋ฃจ์
์
๋๋ค. ๋ชจ๋ ์ํฉ์ ํจ๊ณผ๊ฐ ์๋ ๊ฒ์ ์๊ฐํ ์๋ ์์ง๋ง... ์ ๋ง ํ์ํฉ๋๋ค...
@gabrielalan ์ฌ์ด ํด๊ฒฐ์ฑ ์ ์ด ์ค๋ฅ๋ฅผ ๊ฒฝ๊ณ ๋ก ๋ฐ๊พธ๋ ๊ฒ์ ๋๋ค. ๋ ๋์ ์๋ฃจ์ ์ ์ด๋ฅผ ๊ฒฝ๊ณ ๋๋ ์ค๋ฅ๋ก ์ฒ๋ฆฌํ ์ ์๋ ํ๋๊ทธ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ๋๋ค. ์๋ฃจ์ ์ด ๋ถ์กฑํ ๊ฒ์ด ์๋๋ผ ์ค์ ๋ก ๊ตฌํํ์ง ๋ชปํ๋ ๊ฒ์ ๋๋ค.
์ค ์๋ ! ์ํฐํ๋ผ์ด์ฆ ํ๋ ์์ํฌ์ ๋๋ฌด...
@atom-morgan ์ด๋ค ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋ํด ์ด์ผ๊ธฐํ๊ณ ์์ต๋๊น?
@netlander ์ด๊ฑฐ
์ ๋ง, "ํด๋์ค DaterangepickerDirective์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค" ์ค๋ฅ์ ๋ํด ์๋ฌด ๊ฒ๋ ํ ์ ์์ต๋๊น?
๋๋ ๋์์ค ์ฌ๋? ์ด ๋ฉ๊ฐ์กฐ๋ ํฌ์คํธ ์ดํ!
์ด ์ง์นจ์ tsconfig.app.json ์ ์ ์ธ ํญ๋ชฉ์ ์ถ๊ฐํ๋ ๋ฐ ๋์ํ์ง ์์ต๋๋ค! ์ด ๋ฌธ์ ์์ด --aot param์ผ๋ก ์ด๋ป๊ฒ ์ปดํ์ผํ ์ ์์ต๋๊น?
๋ด ์ฌ์ฉ ์ฌ๋ก https://github.com/angular/angular/issues/23475
๋๋ ์ ํจ์ฑ ๊ฒ์ฌ๊ธฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง๋ค๊ณ ์์ผ๋ฉฐ ๊ฐ ์ ํจ์ฑ ๊ฒ์ฌ๊ธฐ ์ง์๋ฌธ์ ๋ํ ๋ชจ๋์ ๋ง๋ค๊ณ ์ถ์ง ์์ต๋๋ค. ๋ด๊ฐ ์ํ๋ ๊ฒ์ ๋จ์ง ๊ฒ์ฌ๊ธฐ ์ง์๋ฌธ์ npm ํจํค์ง์ ๋ฌถ์ ์ ์์ด ์ฌ์ฉ์๊ฐ NgModule์ ํ์ํ ๊ฒ์ฌ๊ธฐ๋ง ์ค์นํ๊ณ ๊ฐ์ ธ์ฌ ์ ์๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ๋ํ ๋ชจ๋ ์ ํจ์ฑ ๊ฒ์ฌ๊ธฐ์ ๋ํด ํ๋์ ๋ชจ๋์ ๋ง๋ค๊ณ ์ถ์ง ์์ต๋๋ค. ๋ชจ๋ ์ ํจ์ฑ ๊ฒ์ฌ๊ธฐ๊ฐ ์ต์ข
๋ฒ๋ค์ ๋ฒ๋ค๋ก ํฌํจ๋์ด ํฌ๊ธฐ๋ฅผ ํฌ๊ฒ ๋ญ๋นํ๊ธฐ ๋๋ฌธ์
๋๋ค.
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด PR์ ์์ฑํ๊ฒ ๋์ด ๊ธฐ์ฉ๋๋ค.
@anjmao ๋ด๊ฐ ์ฒ์์ ์ด๊ฒ์ ์ด์๋ ์ด์ ์ ์์ฒญ๋๊ฒ ๋น์ทํฉ๋๋ค. ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก ๋ฐฐ๋ด(index.ts) ํ์ผ์ ์ฌ์ฉํ์ง ์์ผ๋ฉด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์๋๋ค๋ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค. ์ธ๋ฑ์ค์์ 1๊ฐ์ ์ปดํฌ๋ํธ/๋๋ ํฐ๋ธ๋ฅผ ๊ฐ์ ธ์ค๋ฉด ์ธ๋ฑ์ค ํ์ผ์ ๋ค๋ฅธ ๋ชจ๋ ๋ด๋ณด๋ด๊ธฐ์ ๋ํ ๋ชจ๋์ ์ฐพ์ผ๋ ค๊ณ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋ถ๋ช ํ ๋ฐฐ๋ด ํ์ผ์ด ๋งค์ฐ ํธ๋ฆฌํ๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ด ๊ฒฝ๊ณ ์ฌ์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ฌ์ฉ ์ฌ๋ก๊ฐ ์ด ์์ ์ฌํญ์ ์ํด 1๋ ๋ ๊ธฐ๋ค๋ฆด ์ ์๋ค๋ฉด ๊ทธ๋ ๊ฒ ํด๊ฒฐํ ์ ์์ต๋๋ค.
๊ตฌ์ฑ ์์/์ง์๋ฌธ/ํ์ดํ์ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ฌ์ฉ ์ค์ธ ํด๊ฒฐ ๋ฐฉ๋ฒ: ๋ชจ๋ ํด๋์ค ์ ์ธ์ ์ฐธ์กฐํ๋ ๊ฐ๋จํ ๋๋ฏธ ๋ชจ๋์ ๋ง๋ญ๋๋ค. ์ค์ ์ฑ์์ ์ด ๋ชจ๋์ ์ฌ์ฉํ ํ์๋ ์์ผ๋ฉฐ ๋์คํฌ์ ์กด์ฌํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ์ :
import { NgModule } from '@angular/core';
@NgModule({
imports: [],
declarations: [
MyComponent,
MyPipe,
MyDirective,
...
],
})
export class DummyModule {
}
์ด ๋ฌธ์ ๋ฅผ ์์ง ํด๊ฒฐํ์ง ๋ชปํ ์ด์ ๊ฐ ์์ต๋๊น?
"๊ฒฝ๊ณ ๋ก ๋ง๋ค๊ธฐ" ์๋ฃจ์ ์ด ์ ์ ํ์ง ์์ต๋๊น? ํต์ฌ ํ์ ๊ตฌ์ฑ์์ด ์ด์ ๋ํด ๋ ผํํ ์ ์์ต๋๊น?
์ ๊ฒฝ์ฐ์๋ NG 5, CLI ๋ฐ AOT์์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ NG 6์ผ๋ก ์ ๊ทธ๋ ์ด๋ํ ํ ์ฌ์ฉํ์ง ์๋ ๊ตฌ์ฑ ์์์ ๋ํด ์ ์ฌํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ค์ ๋ก ์ปดํฌ๋ํธ๋ ๋ค๋ฅธ ์ปดํฌ๋ํธ์ ์ฃผ์ ๋ ์๋น์ค๋ฅผ ํตํด ์ฌ์ฉ๋ฉ๋๋ค. ๋๋ ๋ง์ ์ ์ฌํ ๊ตฌ์ฑ ์์๋ฅผ ๋์ผํ ๋ฐฉ์์ผ๋ก ๊ตฌ์ฑํ๊ณ ์ฌ์ฉํ์ต๋๋ค. ๊ทธ๋ฌ๋ ์ต์ NG CLI 6.0 ๋ฐ 6.0.1๋ก ์ ๊ทธ๋ ์ด๋ํ๋ ๋ฐ ๋ฌธ์ ๊ฐ ํ๋ ์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ฐธ์กฐ ์ค ํ๋์์ ํ์ผ ์ฐธ์กฐ์ ๋์๋ฌธ์๊ฐ ์๋ชป๋ ๊ฒ์ผ๋ก ๋ํ๋ฌ์ต๋๋ค. ๋์ผํ ๋๋ ํ ๋ฆฌ์ ๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ด๋ณด๋ด๋ index.ts๊ฐ ์์ต๋๋ค. ๋๋ ๊ฐ์ง๊ณ ์์๋ค
export * from './dateTimePicker.component'
๋์:
'./datetimePicker.component'์์ * ๋ด๋ณด๋ด๊ธฐ;
๋ถ๋ช
ํ NG CLI 6์ Windows์์๋ ๋์๋ฌธ์์ ๋ํด ๋ ์ ํ์ ์ธ ๋ฐ๋ฉด NG CLI 1.x๋ ์ฝ๊ฐ ํธ์ํฉ๋๋ค.
๋ถ๋ช
ํ ๊ทธ๋ฌํ ์ ํ์ ํ๋ฅญํ๊ณ ์ ํํ๋ฏ๋ก ๊ธฐ๋ณธ์ ์ผ๋ก ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ Linux์์ ๋์ผํ ์ฝ๋๋ฒ ์ด์ค๊ฐ ์ ์๋ํ ์ ์์ต๋๋ค.
์ด์ ๋ํ ๋ ๋ค๋ฅธ ์ฌ์ฉ ์ฌ๋ก:
Typescript๋ฅผ ์ฌ์ฉํ๋ฉด tsconfig.json
์ paths
๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ํด์๋ ๊ฒฝ๋ก๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค. ์ :
{
...
"paths": {
"~src/*": ["src/*", "src-gen/*"]
}
}
๋ค์๊ณผ ๊ฐ์ ๊ฒ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
import { NgModule } from "@angular/core";
import { ExampleComponent } from "~src/example.component";
@NgModule({
declarations: [
ExampleComponent
],
})
export class ExampleModule {}
src
ํด๋ ์์ ๋ค๋ฅธ ๊ตฌ์ฑ ์์๋ฅผ ๋ง๋ค์ด ๊ฐ๋ฐ์๊ฐ "์ฌ์ ์"ํ ์ ์๋ src-gen
๋ด๋ถ์ ๊ตฌ์ฑ ์์๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ src-gen
์์ ์๋ (ํ์ฌ ์ฌ์ฉ๋์ง ์๋) ๊ตฌ์ฑ ์์์ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ธฐ ์์ํฉ๋๋ค.
๋ ๋ค๋ฅธ ์ ์ฌ์ ์ธ ์ฌ์ฉ ์ฌ๋ก:
ํ๊ฒฝ๋ณ ๊ตฌ์ฑ ์์. ๋๋ ์์ฐ์ ์ํด ๊ทธ๊ฒ๋ค์ ๋ฒ๊ฒจ๋ธ๋ค.
const environmentComponents = production ? [] : [
DevOnlyComponent,
];
@NgModule({
declarations: [
...environmentComponents,
],
})
export class ExampleModule {
}
ํ๊ฒฝ๋ณ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ๋ชจ๋ ์์ ์ ์ํํ ์ ์์๊ณ ์ด๊ฒ์ด ์ ๋ฅผ ๋ฉ์ถ๊ฒ ํ๋ ๊ฒ์ ๋๋ค. ๐ช
@tiagodws (์๋ ๊ตฌ์ฑ ์์์ ํ์ฅ ํฌํจ)์์ ์ค๋ช ํ ์๋๋ฆฌ์ค์ ๊ฑฐ์ ์ ์ฌํ ๋น๋ ์ฌ์ฉ์ ์ง์ ๋ฉ์ปค๋์ฆ(๊ตฌ์ฑ ์์๊ฐ ๋ค๋ฅธ Angular CLI ํ๋ก์ ํธ๋ก ๊ตํ๋จ)์ ๊ตฌํํ ๋ ์ด ๋ฌธ์ ์ ์ง๋ฉดํ๊ณ ์์ต๋๋ค.
์ด ๋ฌธ์ ์ ๋ํ ํต์ฌ ํ์ ์ ๋ฐ์ดํธ/์๊ฒฌ์ด ์์ต๋๊น?
์ด ๋ฌธ์ ๋ฅผ ์ฐ ์ง 1๋
์ด ๋๋๋ก ๋ด ์๋ก์ด ์ ๊ทผ ๋ฐฉ์์ ๋ฐฐ๋ด ํ์ผ ์ฌ์ฉ์ ์ต์ํํ๋ ๊ฒ์
๋๋ค. ๋ชจ๋ ๊ณณ์์ ๊ฐ์ ธ์ค๊ธฐ์์ ~components/button/component
์ ๊ฐ์ TS ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฌ์ฉํ์ง ์๋ ๊ฐ์ ธ์ค๊ธฐ๋ ๋ฌด์๋ฉ๋๋ค. ์ฌ์ฉ๋์ง ์์ ๊ตฌ์ฑ ์์๊ฐ ๋ฐฐ๋ด ํ์ผ์์ ์ฐธ์กฐ๋๋ฉด throw๋ฉ๋๋ค.
์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์๋ ์ฌ์ ํ ์ข์ง ์์ต๋๋ค. ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ต์์ ๋ ๋ฒจ์์ ๊ฐ์ ธ์ค๋ ๋์ ๋ ๊ธด ๊ฒฝ๋ก๋ก ๋ชจ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ตฌ์ฑ ์์์ ์ก์ธ์คํด์ผ ํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ์, ์ค ์ ์ด๊ฒ์ ๋จ์ง ๊ฒฝ๊ณ ๊ฐ ๋ ์ ์์ต๋๊น?
์ด๊ฒ์ ๋ํ ๋ชจ๋์ ํน๋ณํ ํฌํจ๋์ง ์์ ์ฝ๋๊ฐ ์ต์ข ๋ฒ๋ค์์ ์ ์ธ๋๋ ํธ๋ฆฌ ์์ดํน์ ์ํด(๋๋ ์ ์ด๋ ๊ด๋ จํ์ฌ) ๋์์ด ๋ ์ ์๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค.
์ ์ธ ์ต์ ์ ๋ชจ์ ํ์ดํ์ ์ ์ฉ๋์ง ์์ต๋๋ค.
@Pipe({ name: 'translate' })
export class MockTranslatePipe implements PipeTransform {
transform(value: string): string {
//Do stuff here, if you want
return value;
}
}
๋ด tsconfig.app.json์ด ์ด ํ์ผ์ ์ ์ธํ์ต๋๋ค.
"exclude": [
"test.ts",
"**/*.mock.ts",
"**/*.spec.ts"
]
๊ทธ๋ฌ๋ ng-xi18n --i18nFormat=xlf2 --outFile=./assets/i18n/messages.xlf๋ฅผ ์คํํ๋ฉด ์ฌ์ ํ ๋ค์๊ณผ ๊ฐ์ด ๋ถํํฉ๋๋ค.
src/test/translate.service.mock.ts์์ MockTranslatePipe ํด๋์ค์ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค! NgModule์ MockTranslatePipe๋ฅผ ์ถ๊ฐํ์ฌ ์์ ํ์ญ์์ค.
๋ด ๋ฌธ์ ๋ lol์ ๋ณต์ฌํ์ฌ ๋ถ์ฌ ๋ฃ์ด 2 ๊ฐ์ ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ํด๋์ค ์ด๋ฆ์ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ ๋๋ค! ๋์ค์๋ ๋ฌด๊ด์ฌ์ผ๋ก ๊ฐ์ ์ค์๋ฅผ ํ๋ฉด ์ข์ ์ฐ์ต์ด ์๋ฒฝํ ๋จ์๋ฅผ ๋ง๋ ๋ค! ํํธ...
์๋ช : ๋์นด๋ชจํ ์ฌํ ์: v
@yuezhizizhang ๊ณผ ์ ์ฌํ๊ฒ tsconfig.app.json exclude
๊ฒฝ๋ก์ mock์ฉ glob์ ์ถ๊ฐํ ํ์๋ ์ฌ์ ํ ์ด ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ด ๋ฌธ์ ๊ฐ ์ด๊ธฐ ํฐ์ผ ์ดํ ๊ฑฐ์ 2๋ ๋์ ํด๊ฒฐ๋์ง ์์๋ค๋ ์ฌ์ค์ ๋ถ๋ ธํ๊ธฐ ์ง์ ์ ๋๋ค. ์ด๊ฒ์ BREAKING ๋น๋์ธ ์ผ๋ฐ์ ์ธ ์ฌ์ฉ ์ฌ๋ก์ ๋๋ค. ํ ์คํธ๋ฅผ ์์ฑํ ๋ ๊ฐ๋ฐ์๋ ํ์ดํ, ์๋น์ค ๋ฑ์ ๋ํ ๋ชจ์ ๊ฐ์ฒด๋ฅผ ์ด์์ ์ผ๋ก ์์ฑํด์ผ ํฉ๋๋ค. ์ด ์์ ์ ์ ํํ๋ฉด ๋น๋๊ฐ ์ค๋จ๋ฉ๋๋ค. ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ์ฌ์ ํ์ผ์ ์ค์ ๊ตฌ์ฑ ์์/ํ์ดํ/๋ฑ์ ์ฐธ์กฐํ์ฌ ๋งค์ฐ ๋ฐ์ ํ๊ฒ ๊ฒฐํฉ๋ ํ ์คํธ๋ก ์ด์ด์ง๋๋ค.
Angular ํ์ ๋๊ตฐ๊ฐ๊ฐ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ์ ์ํด ์ฃผ์๊ฒ ์ต๋๊น? ๋ชจ์์ ๋ํ ํฌ๊ด์ ์ธ ๋๋ฏธ ๋ชจ๋์ ๋ง๋๋ ๊ฒ์ด ์ ๋ง ์ ์ผํ ์ต์ ์ ๋๊น? ๊ทธ๊ฒ์ ์ฐ๋ฆฌ๊ฐ ๋ชจ๋ฒ ์ฌ๋ก๋ก ๋ฐ์๋ค์ฌ์ผ ํ๋ ๊ฒ์ด ์๋๋ผ ์ข์ง ์์ ํดํน์ ๋๋ค.
๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค. ๋ํ ๋น๋(์ถ์ ํด๋์ค)๋ฅผ ๊ฑด๋๋ฐ๊ณ ์ถ์ ํ์ผ์ tsconfig.app.json
์ ์ ์ธ ์น์
์ ์ถ๊ฐํ๋๋ฐ ์ฌ์ ํ ๋ค์๊ณผ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋ํ๋ฉ๋๋ค.
.../map-elements/map-element-base.component.ts์์ MapElementBaseComponent ํด๋์ค์ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค! NgModule์ MapElementBaseComponent๋ฅผ ์ถ๊ฐํ์ฌ ์์ ํ์ญ์์ค.
์์ ํ์ ๋ค์ ํ์ธ ํ ํ์ด ๋ฌธ์ ๋ฅผ ์ ๊ฑฐํ์ต๋๋ค.
ัั, 14 ะฝะพัะฑ. 2018๋ ะณ., 15:13 Daniel Groh [email protected] :
๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค. ๋น๋๋ฅผ ๊ฑด๋๋ฐ๊ณ ์ถ์ ํ์ผ๋ ์ถ๊ฐํ์ต๋๋ค.
(์ถ์ ํด๋์ค) tsconfig.app.json ๋ฐ I์ ์ ์ธ ์น์ ์
์ฌ์ ํ ์ป์:์์ MapElementBaseComponent ํด๋์ค์ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค.
.../map-elements/map-element-base.component.ts! MapElementBaseComponent ์ถ๊ฐ
NgModule๋ก ์์ ํฉ๋๋ค.โ
๋น์ ์ด ๋๊ธ์ ๋ฌ์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๋ ๊ฒ์ ๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/angular/angular/issues/13590#issuecomment-438641324 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/AQb6kpWdkakUF8JVvea8Hy42tAnTKTuzks5uvAjvgaJpZM4LSAwS
.
TypeScript๊ฐ ์๊ฒฉํ ๋ AOT ์ปดํ์ผ์์ Angular ๊ฐ์ ธ์ค๊ธฐ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ์ด ์ค๋ฅ๋ฅผ ๋์นญํ๋ฉด... ์ฌ์ฉ๋์ง ์๋ ๊ตฌ์ฑ ์์/๋ชจ๋์ด ์๋ฏธ๊ฐ ์๋์ง ํ์ธ...
์ฌ์ฉํ์ง ์๋ ๋ชจ๋๊ณผ ๊ตฌ์ฑ ์์๊ฐ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํด๋๋ฅผ ์ญ์ ํ๋ฉด ์์ฉ ํ๋ก๊ทธ๋จ์ด strict-aot์์ ์ ๋๋ก ์คํ๋์ง๋ง ์ด ํด๋๋ฅผ ์๋์ผ๋ก ์ญ์ ํ๋ ๊ฒ์ ์๋ฏธ๊ฐ ์์ต๋๋ค.
์ด ์ค๋ฅ๋ ์์ ํ ์ฐ์ค๊ฝ์ค๋ฝ์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ฒด์ ๊ตฌ์ฑ ์์๋ฅผ ์ง์ ํ๋ ๋ชจ๋์ด ์์ต๋๋ค.
const landingComponents = {
'landing-root': LandingComponent,
'get-notified': GetNotifiedComponent,
'typed-component': TypedComponent,
'sticky-bar': StickyBarComponent,
};
๊ทธ๋ฐ ๋ค์ declarations: Object.values(landingComponents)
, entryComponents: Object.values(landingComponents)
๋ชจ๋์ ๊ณต๊ธํ๋ ค๊ณ ํ์ต๋๋ค.
๋ง์ถฐ๋ณด์ธ์ ... AOT ์ปดํ์ผ๋ฌ๋ ๋ฐฐ์ด์ ๋์ด๋ ๊ตฌ์ฑ ์์๋ฅผ ๋ณผ ํ์๊ฐ ์์ต๋๋ค ... ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ ๋ฌํ๋ฉด "ํด๋์ค์ ๋ํ ๋ชจ๋์ ๊ฒฐ์ ํ ์ ์์ต๋๋ค"๋ผ๋ ๋์ฐํ ๋ฉ์์ง๊ฐ ๋ํ๋ฉ๋๋ค.
๋ด๊ฐ Angular๋ฅผ ์ฌ๋ํ๋ ๋งํผ AOT ์ปดํ์ผ๋ฌ๋ ๋ง๋ฒ ์ฃผ๋ฌธ์ ํผ๋์ค๋ฌ์ด ์ํ์ฒ๋ผ ๋ณด์ ๋๋ค.
์ฌ๋ฌ ๋ฒ ์ธ๊ธ๋์์ง๋ง ์๋ฃจ์ ์ ์ด์ ๋ํ ๋ชจ๋๋น 1๊ฐ์ ๊ตฌ์ฑ ์์์ด๋ฉฐ PR์์ Angular์ ๋ํด ์์์ฐจ๋ ธ๋์ง ํ์คํ์ง ์์ง๋ง ์ต๊ทผ์ ๋ณํฉ๋์์ผ๋ฉฐ ์ด ์ฃผ์ ์ ๊ด์ฌ์ด ์์ ์ ์์ต๋๋ค: https://github.com/ ๊ฐ/๊ฐ/๋น๊ธฐ๊ธฐ/27481
์ค๋๋ก 2์ฃผ๋ ์ ๋ง์ดํ ์ด๋ฒ ํธ ๐
๊ทธ๋ฌ๋ ์ด๊ฒ์ด ๋จ์ง ๊ฒฝ๊ณ ๊ฐ ๋ ์ ์๋ ์ด์ ์ ๋ํ ํต์ฌ ํ์ ํ๋ง๋๋ ์์ต๋๋ค.
@tiagodws lol ์ด๊ฑฐ ์ฌ๋ฆฌ๋ ค๊ณ ์ผ๋ง๋ ๊ธฐ๋ค๋ ธ์ด์? ์๋ฆผ์ ์ค์ ํ์ จ๋์?
์ฐธ๊ณ ๋ก
๋ด ๋ฌธ์ ๋ https://github.com/angular/angular/issues/13590#issuecomment -389113560๊ณผ ๋์ผํ์ต๋๋ค.
๊ฐ์ ธ์ค๊ธฐ๋ AOT ๋ชจ๋์์ ๋ถ๋ช
ํ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํฉ๋๋ค.
@peterdeme ... JavaScript๋ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํฉ๋๋ค(๋ฌธ์์ด๊ณผ ๋์ผํ ๊ฒฝ๋ก ... = Windows๊ฐ ์๋ Linux ๊ธฐ๋ฐ).
์๋
ํ์ธ์ ์ฌ๋ฌ๋ถ, ๋ค๋ฆ์ 2์ฃผ๋
๊ธฐ๋
ํ์ฌ๋ฅผ ์ํด ๋ค์ ์ฐพ์์์ต๋๋ค. include
๋ฐ $#$ tsconfig.json
์ exclude
์น์
์ ํฌํจํ์ฌ ์ฌ๋๋ค์ ๊ฐ๋ฅํ ์์ธ์ ๋ํด ๋ง์ ๋
ผ๋์ด ์์ผ๋ฏ๋ก ๊ทผ๋ณธ ๋ฌธ์ ๊ฐ ๋ฌด์์ธ์ง ๋ช
ํํ ํ๊ณ ์ถ์ต๋๋ค. ์ด ์ค๋ ๋๋ฅผ ์ํด.
์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ๊ตฌ์ฑ ์์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง๋ค๊ณ ๋ ์ฝ๊ฒ ๊ฐ์ ธ์ฌ ์ ์๋๋ก ๋ฐฐ๋ด ํ์ผ( index.ts
)์ ์ถ๊ฐํ๋ฉด Angular ์ปดํ์ผ๋ฌ๋ ๊ทธ ์ค ํ๋๋ฅผ ์ฌ์ฉํ ๋ ์ค๋จ๋ฉ๋๋ค. ์ด๋ ํด๋น ๋ฐฐ๋ด ํ์ผ(์: @shared/components
)์์ ๋ฌด์์ด๋ ๊ฐ์ ธ์ค์๋ง์ ๋ชจ๋ ๋จ์ผ ๊ตฌ์ฑ ์์์ ๋ํ ๋ชจ๋์ ์ฐพ์ผ๋ ค๊ณ ์๋ํ๊ธฐ ๋๋ฌธ์
๋๋ค. ์ํ๋ ํน์ ๊ตฌ์ฑ ์์(์: import { SharedToastComponent } from '@shared/components';
)๋ฅผ ์ง์ ํ๋๋ผ๋ ์ปดํ์ผ๋ฌ๋ ์ฌ์ ํ ๋ด๋ณด๋ธ ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ํ ๋ชจ๋์ ์ฐพ๊ณ ๋๋ฝ๋ ๊ตฌ์ฑ ์์์ ๋ํ ์ค๋ฅ(๊ฒฝ๊ณ ์๋)๋ฅผ ๋์ง๋๋ค.
๋ถ๋ช ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
ExtrasModule
๋ฅผ ์ฌ์ฉํ๊ณ ๋ชจ๋์ ์ด๋์๋ ์ฌ์ฉํ์ง ๋ง์ญ์์ค. ์ด๊ฒ์ ํ
์คํธ์๋ง ํ์ํ ๊ตฌ์ฑ ์์๊ฐ ์๋ ์ฌ๋๋ค์๊ฒ๋ ์ ์๋ํ์ง๋ง ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ๊ฐ์ ธ์ค๋ ค๋ ์ฌ๋๋ค์๊ฒ๋ ์ ํฉํ์ง ์์ต๋๋ค.๊ทธ๋ฌ๋ ์ด๋ฌํ ํด๊ฒฐ ๋ฐฉ๋ฒ ์ค ํ๋๋ฅผ ์ฌ์ฉํ๋ฉด ํธ๋ฆฌ ์์ดํน ํ์ ์ ํํ ๋์ผํ ์ถ๋ ฅ ์ฝ๋๊ฐ ์์ฑ๋๊ธฐ ๋๋ฌธ์ ๋ค๋ฅธ ๊ตฌ์ฑ ์์๊ฐ ์ฌ์ฉ๋ ๋ชจ๋์ ํฌํจ๋ ํ์๊ฐ ์๋ค๋ ๊ฒ์ ๋ถ๋ช ํฉ๋๋ค. ์ด 2๋ ๋ ๋ฌธ์ ์ ๋ํด ์ ๊ฐ ์๊ตฌํ๋ ๊ฒ์ ํด๋น ์ค๋ฅ๋ฅผ ๋ณด๋ค ์ ์ ํ ๊ฒฝ๊ณ ๋ก ๋ฐ๊พธ๋ ๊ฒ์ ๋๋ค. ๊ณ์ ํ์ฉํ๋ฉด ์ปดํ์ผ์ด ๊ณ์ ์ฑ๊ณตํ๋ฏ๋ก ์๋ฏธ๊ฐ ์์ต๋๋ค.
2019๋ ์ Angular ํ์ด ์ด ์์ฃผ ์ค๋๋๊ณ ๋งค์ฐ ์ฑ๊ฐ์ ๋ฌธ์ ์ ๋ํด ๋ญ๊ฐ๋ฅผ ํ ์ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. ๐ค
@swimmadude66 ... ์ค์ lib ๋ชจ๋์ ๋ง๋ค๊ณ tsconfig.json
๋ฅผ ํตํด Angular ์ฑ์ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ์ ์ธ๊ธํ์ง ์์์ต๋๋ค. "paths": {"ng-demo": ["./packages/ng-demo/src/index.ts"]}
import { DemoModule } from 'ng-demo';
์ค๊ธฐ๋ฅผ ํตํด ์ฌ์ฉ
๋ชจ๋ ๊ตฌ์ฑ ์์ ์คํ ์ ์ค๋ฅ๊ฐ ์๋ ๊ฒ์ด ๊ฐ์ฅ ์ง์ฆ๋๋ ์ผ์ ๋๋ค. ๋ค๋ค ์คํ ํ ์คํธ/์์ฑ ์ค์ด์์ฃ ? ๋ฐ๋ผ์ ๊ตฌ์ฑ ์์ ์คํ ์ค๋ฅ๋ ๋ชจ๋ ์ฌ๋์๊ฒ ์ํฅ์ ๋ฏธ์นฉ๋๋ค. ๋๋ ๋ฐฐ๋ด ๋ฌธ์ ๊ฐ ๋ ์ฑ๊ฐ์ ๊ฒ์ ๋งํ๋ ๊ฒ์ด ์๋๋๋ค. ๋๋ ๋จ์ง ๋ชจ๋ ์ฌ๋๋ค์ด ๋ฐฐ๋ด์ ํ๊ณ ์๋ ๊ฒ์ ์๋๋ผ๊ณ ๋งํ๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ชจ๋๊ฐ ์ฌ์์ ํ๊ณ ์์ด์ผ ํฉ๋๋ค. ๋ฐ๋ผ์ ์ฌ์ ๋ฌธ์ ๋ ํต์ฌ ํ์ด ์ด๋ฅผ ์์ ํ๋ ๊ฐ์ฅ ํฐ ๋๊ธฐ๊ฐ ๋์ด์ผ ํฉ๋๋ค. ํ์ฌ "Frequency Low"๋ผ๋ ๋ ์ด๋ธ์ด ์ง์ ๋์ด ์์ง๋ง ๋จ์ ํ ์คํธ๋ฅผ ์ํํ๋ ๋ชจ๋ ์ฌ๋์ด ์ด ๋ฌธ์ ์ ๋ถ๋ชํ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ "Frequency High"์ฌ์ผ ํฉ๋๋ค.
์ด๊ฒ์ AOT์์๋ ์ผ๊ด๋์ง ์์ต๋๋ค. Angular CLI๋ ๊ธฐ๋ณธ์ ์ผ๋ก AOT๋ฅผ ์ฌ์ฉํ๋ ์๋ฒ๋ก ์คํํ ๋ ์ค๋ฅ๋ฅผ ํ์ํ์ง ์์ง๋ง ๋น๋์ ํจ๊ป ์คํํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
๋๋ ์ด๊ฒ์ด Angular CLI ์ ์ฅ์๊ฐ ์๋๋ผ๋ ๊ฒ์ ์ดํดํ์ง๋ง ํ์คํ ์ด๊ฒ์ ๋๋ฌ์ผ ๋์์ด ์ด์ํฉ๋๋ค.
๋ชจ์ ๋ชจ๋์ ์์ฑ ํ๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์๋๋ผ๋ ์ด์ UI ๋จ์ ํ ์คํธ ์์ฑ์๊ฐ ๋จ์ผ ๋ชจ์ ๊ตฌ์ฑ ์์๋ฅผ ๋ชจ์ ๋ชจ๋์ ์ถ๊ฐํ๋ ๊ฒ์ ์์ด๋ฒ๋ฆฌ๋ฉด "ng ๋น๋"๊ฐ ์คํจํฉ๋๋ค.
์๋ UI ๋จ์ ํ ์คํธ๊ฐ ํ์ฌ CI/CD ๋ฐฐํฌ ํ์ดํ๋ผ์ธ์ ์ํ ์์ ์์ ์๋ฏธํฉ๋๋ค!
Angular ๋จ์ ํ ์คํฐ๊ฐ ํ ๋ฒ์ ์ฌ์ํ ์๋ต์ผ๋ก ์ ์ฒด ๋ฐฐํฌ ๋น๋๋ฅผ ์ค๋จํ ์ ์๋ค๋ ๊ฒ์ ๋จน์ด ์ฌ์ฌ์ ์์ ์ฌ๋๋ค์๊ฒ ์ค๋ช ํด์ผ ํฉ๋๊น? ์๋์. Angular ๊ฐ๋ฐ์๋ฅผ ๊ด๋ฆฌํ๊ณ ๋ค์ ํ๋ก์ ํธ์ ์ฌ์ฉํ ํ๋ ์์ํฌ๋ฅผ ๊ฒฐ์ ํ๋ ์ฌ๋๋ค์ ์ด๋ฐ ์ข ๋ฅ์ ๋ฌธ์ ์ ๋ํด ๊ถ๊ธํดํด์๋ ์ ๋ฉ๋๋ค.
์์๋ฐฉํธ์ผ๋ก: "ng build"์ ๋ํ๋๋ ์ค๋ฅ๋ฅผ ํ ์คํธ ์์ฑ์์๊ฒ ๋ ๋ง์ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋๋ก ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ฆ "ํ ์คํธ์ ์ฌ์ฉ๋ ๋ชจ์ ๊ตฌ์ฑ ์์์ธ ๊ฒฝ์ฐ: ํด๋น ๋ชจ์ ๋ชจ๋์ ์ถ๊ฐ" ํจ๊ณผ์ ํ ์คํธ๋ฅผ ์ถ๊ฐํฉ๋๋ค. (์ด URL)์ ๋ฐ๋ผ ํ์ผ"
ํ๊ท ์ ์ธ ์น์ํ Angular ๊ฐ๋ฐ์ ์์ฑ ๋จ์ ํ ์คํธ๊ฐ ์ด๋ป๊ฒ ์ฌ๊ธฐ์ ๋๋ฌํ๋์ง:
a) IMHO ๋ชจ๋ .spec ํ์ผ์ด ์ฌ์ฉํ๋ ๋ชจ์ ๊ตฌ์ฑ ์์, ์๋น์ค ๋ฑ์ ๋ฐฐ์นํ๋ "๋์ฐ๋ฏธ" ํ์ผ์ ๋ง๋๋ ๊ฒ์ DRY ์ฝ๋ ๋ฐฉ์์ ๋๋ค. ๊ทธ๋ฌ๋ ์ด ์ฐ์ต์ ํ ์คํฐ๋ฅผ ์ด ๋ฒ๊ทธ ์๋๋ฆฌ์ค๋ก ์คํํฉ๋๋ค.
b) ๋ชจ๋ .spec ํ์ผ์ ์ค์ ํ ์คํธ ์ฝ๋์ ๊ด๋ จ์ด ์๋ "๋ชจ์ ๋ชจ๋" ์์ด ์ด "๋์ฐ๋ฏธ" ํ์ผ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ๋ชจ์ ๊ตฌ์ฑ ์์๋ ์ฌ์์ ํ ์คํธ ํ๊ฒฝ์์ ์ ํ ์ญํ ์ด ์๋ ๋ชจ์ ๋ชจ๋์ ๋ํ ๊ตฌ์ฑ์ ์๊ฒฉ ์์ด ์๋ ๊ทธ๋๋ก ์ ์ฉํฉ๋๋ค.
๋ฌผ๋ก ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ํ์ง๋ง Google ๊ฒ์์ ํตํด ์ด ๋ฒ๊ทธ๋ฅผ ์ฐพ๊ณ ์ค๋ ๋์ ์ ์ฉํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฝ๊ณ ์์ฝํ๋ ๊ฒ์ ๊ทธ๋ ์ง ์์์ต๋๋ค.
๋ชจ์ ๊ตฌ์ฑ ์์๋ฅผ ํฌํจํ๋ ๋์ฐ๋ฏธ ํ์ผ์ ๋์ ์ด๊ฒ์ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
/*
mock components
!! Each mock component added to this file *must* be added to the "MockTestModule", see below !!
*/
@Component({
selector: 'app-mock-component',
template: '<span>mock widget</span>'
})
export class MockComponent {}
/*
This is an unused module to resolve the ng build error:
'ERROR in : Cannot determine the module for class MockComponent
in C:/code/myRepo/src/assets/test/test-resources.ts!
Add MockComponent to the NgModule to fix it.'
Reference: https://github.com/angular/issues/13590
Each mock component added to this file *must* be added to the "MockTestModule"
*/
@NgModule({
declarations: [ MockComponent ],
})
export class MockTestModule {}
์์ ํ์ผ์ ์ค์ ๋ก๋ ๊ฝค ํฝ๋๋ค... "MockTestModule"์ ๋์ฐ๋ฏธ ํ์ผ์ ๋ ๋ถ๋ถ์ ๋ฌปํ ์์ต๋๋ค...
... ํธ์ถ์ ๊ฐ๋ก์ฑ๊ณ ์ฝ์ ๋ฉ์์ง๋ฅผ ์ฝ์ ํ๋ "ng build"์ ๋ํ package.json ํญ๋ชฉ์ ์์ฑํ ํ์๊ฐ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. ์ฌ์ฉ ์ฐ๋ฅด๋ค.
์ฌ๊ธฐ ๋๋ฅผ ์ํด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค. ๋ด ๊ตฌ์กฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
โโโ icons.module.ts
โโโ index.ts
โโโ icon
โย ย โโโ icon.component.html
โย ย โโโ icon.component.ts
โย ย โโโ icon.module.ts
โโโ icon-indicator
โโโ icon-indicator.component.html
โโโ icon-indicator.component.ts
โโโ icon-indicator.module.ts
icons.module.ts
๋๋:
import { IconComponent } from './icon/icon.component';
import { IconIndicatorComponent } from './icon-indicator/icon-indicator.component';
export { IconIndicatorComponent, IconComponent };
@NgModule({
/* this was all fine */
})
export class IconsModule {}
index.ts
์๋ ๋ค์์ด ํฌํจ๋์์ต๋๋ค.
export * from './icons.module';
์ปดํ์ผ๋ฌ๊ฐ ํด๋น ๊ตฌ์ฑ ์์๋ฅผ ๋ง๋๊ธฐ ์ ์ ์์ด์ฝ ๋ฐ ์์ด์ฝ ํ์๊ธฐ ๋ชจ๋์ ๊ตฌ๋ฌธ ๋ถ์ํ์ง ์์ Cannot determine the module for class
์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค. ์ด ํ๋ก์ ํธ๋ ng 5์
๋๋ค. ng 7 ํ๋ก์ ํธ์์ ์ฌ์ฉํ ๋๋ง ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
ํด๊ฒฐ์ฑ
์ ๋ด๋ณด๋ด๊ธฐ๋ฅผ ํ ๋จ๊ณ ์๋๋ก ์ด๋ํ๋ ๊ฒ์
๋๋ค. ๊ทธ๋์ icons.module.ts
์์ export ๋ฌธ์ ์ ๊ฑฐํ๊ณ ๋ค์์ผ๋ก ์ฎ๊ฒผ์ต๋๋ค.
icon.module.ts:
export { IconComponent };
...
icon-indicator.module.ts:
export { IconIndicatorComponent };
...
์กฐ์ ๋ index.ts
:
export * from './icons.module';
export * from './icon/icon.module';
export * from './icon-indicator/icon-indicator.module';
์ด๊ฒ์ด ๋๊ตฐ๊ฐ๋ฅผ ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
๋๋ ์๋ก์ด ์์ด๋น ๋ ๋๋ฌ๊ฐ AOT์ ๊ด๋ จ๋ ๋ช ๊ฐ์ง ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. pull ์์ฒญ ๋ฐ ๋ฌธ์ ์์ ์ ์ ์๋ฏ์ด Angular ํ์ ivy์ ์ด์ ์ ๋ง์ถ๊ณ ์์ผ๋ฏ๋ก angular 6์์ ์ด ๋ฌธ์ ์ ๋ํด ์กฐ์น๋ฅผ ์ทจํ ์ด์ ๊ฐ ์์ต๋๋ค.
๋๋ ์๋ก์ด ์์ด๋น ๋ ๋๋ฌ๊ฐ AOT์ ๊ด๋ จ๋ ๋ช ๊ฐ์ง ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๋๋ ๋ชจ๋ ๋ฌธ์ ์์ ์ด๊ฒ์ ๋ฃ๋ ๊ฒ์ ์ข์ํฉ๋๋ค.
angular 7.2.0 ๋ฐ angular-cli 7.3.0์์๋ ์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
ERROR in : Cannot determine the module for class ModalMockComponent in /Users/user/repos/angular-skeleton/src/app/shared/modal/modal.component.mock.ts! Add ModalMockComponent to the NgModule to fix it.
Cannot determine the module for class TranslatePipeMock in /Users/user/repos/angular-skeleton/src/app/shared/pipes/translate.pipe.mock.ts! Add TranslatePipeMock to the NgModule to fix it.
์๋ฅผ ๋ค์ด ๋ด Shared Module
$ ์์ TranslatePipe
์ TranslatePipeMock
$ ๊ฐ ์์ต๋๋ค. TranslatePipe๋ ๋ชจ๋์ ํฌํจ๋์ด ์์ง๋ง ๋ชจ์ ํ์ดํ๋ ํฌํจ๋์ด ์์ง ์์ต๋๋ค.
translate.pipe.mock.ts
๋ ๋จ์ ํ
์คํธ์ฉ์ด๋ฏ๋ก ์ด ํ์ผ์ ๊ฐ ๋จ์ ํ
์คํธ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
ํ์ง๋ง ์ด์ ๋ด ๋น๋๊ฐ ์คํจํฉ๋๋ค.
ng build --prod
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํ๋์?
Atm ๋๋ ๊ทธ๊ฒ์ ํด๊ฒฐํ๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts",
"**/*.mock.ts"
]
}
๊ฐ๋จํ ์ค๋ช ์ผ๋ก ์ด ๋ฌธ์ ์ ํ์ฌ ์ํ๋ฅผ ํ์ธํ๊ธฐ๋ ์ด๋ ต์ต๋๋ค. ๋๋ ์ด๊ฒ์ด ๋ฌธ์ ๋ผ๋ ๋ฐ ๋์ํฉ๋๋ค(๋์ ๋์์ธ). ๊ทธ๊ฒ์ ๊ณ ์น ๊ณํ์ ๋ฌด์์ ๋๊น? ์ฌ์ด๊ฐ์ ์ด๋ ค์ด๊ฐ์?
@rrmayer ์ด ๋ฌธ์ ์ ์ํ๋ ๊ฑฐ์ ๋ชจ๋ "ํ์ฌ" ๋ฌธ์ ์ ๋ง์ฐฌ๊ฐ์ง๋ก "๋ด์์ด๋ฉ๊ตด์ ๊ธฐ๋ค๋ฆฌ์ญ์์ค"์ผ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
์ฐ๋ฆฌ๋ ์ด๊ฒ์ "์ค๋ฅ"์์ "๊ฒฝ๊ณ "๋ก ๋ณ๊ฒฝํ๊ธฐ๋ฅผ ์ํ๋ฏ๋ก ํ๋ก์ ํธ๊ฐ ์ค์ ๋ก ์ปดํ์ผ๋ฉ๋๋ค... ๊ทธ๋ ๊ฒ ์ด๋ ต์ต๋๊น?
@Terrafire123 ... ์๋ฅผ ๋ค์ด ํ ์คํธ ๋๋ ๋น๋ ๋๊ตฌ์ ๋ง์ ๊ด๋ จ์ด ์์ ์ ์์ต๋๋ค. ์ด๋ ์ค์ ๋ก ์ด ๊ฒฝ์ฐ๊ฐ ์ค๋ฅ๋ก ์ด์ด์ง๋ค๋ ์ฌ์ค์ ๊ธฐ๋ฐ์ผ๋ก ํ๋ฏ๋ก ๊ฒฝ๊ณ ๋ณ๊ฒฝ์ ์ฌ๊ฐํ ๋ฌธ์ ๊ฐ ๋ ์ ์์ต๋๋ค.
ํ์ฌ ์ปดํ์ผ๋ฌ์์ ์์ ๋ ๊ฒ์ด๋ผ๋ ํฌ๋ง์ ์์ต๋๋ค. D
์ต์ํ ์ค๋ฅ๋ ๊ฒฝ๊ณ ๋ฅผ ํ์ํ ์ ์๋ ์ต์ ์ด ์์ด์ผ ํฉ๋๋ค. ๊ตฌ์ฑ ์์๊ฐ ์๋์ ์ผ๋ก ๋ชจ๋์ ์ผ๋ถ๊ฐ ์๋๊ธฐ ๋๋ฌธ์ ๋น๋๊ฐ ๊นจ์ง๋ ๊ฒ์ ๊ฝค ์ฑ๊ฐ์ ์ผ์ ๋๋ค.
์ฌ์ฉํ์ง ์๋ ๊ฐ์ ธ์ค๊ธฐ๋ก ์ธํด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
import { UnusedImportComponent } from "./used-somewhere-else-or-not.component";
ํด๋์ค ์์ ์๋ 'export' ํค์๋๋ @Component ๋ฐ์ฝ๋ ์ดํฐ๊ฐ ์ ์ฉ๋ ํด๋์ค๊ฐ ์ด๋ค ๋ชจ๋์ ํฌํจ๋์ด์ผ ํ๋์ง๋ฅผ ์ด๋ค ์์ผ๋ก๋ ๊ฒฐ์ ํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ตฌ์ฑ ์์์ ํด๋์ค๋ฅผ ๊ฐ์ ธ์ค๊ณ ํ ์คํธ์์ ์ง์ ์ ์ธํ๊ฑฐ๋ CoreMocksModule๊ณผ ๊ฐ์ด ์ ์ธํ ๋ค์ ๋ชจ๋์ ๊ฐ์ ธ์ค๋ ๊ฒ์ ์ค์ํ์ง ์์ต๋๋ค.
๊ทธ๋๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค! ๋ค์๊ณผ ๊ฐ์ด ์ ์ธ๋ ์คํ ๊ตฌ์ฑ ์์๊ฐ ์๋ค๊ณ ๊ฐ์ ํด ๋ณด๊ฒ ์ต๋๋ค.
@Component({
selector: 'app-user-stub-component',
template: ''
})
export class UserStubComponent {}
'export' ํค์๋๋ฅผ ์ ๊ฑฐํด์ผ ํ์ง๋ง ํ ์คํธ/ํ ์คํธ ๋ชจ๋์์ ์ฌ์ฉํ๋ ค๋ฉด ์ฌ์ ํ ๊ตฌ์ฑ ์์๋ฅผ ๋ด๋ณด๋ด์ผ ํฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ด ํ์ญ์์ค.
@Component({
selector: 'app-user-stub-component',
template: ''
})
class UserStubComponent {}
export default UserStubComponent;
์ด์ ์คํ
์ ๊ฐ์ ธ์ฌ ๋ ์ด๋์์๋ ๋ค์๊ณผ ๊ฐ์ ๋๊ดํธ๋ฅผ ํผํด์ผ ํฉ๋๋ค.
import UserStubComponent from 'path'
ํจ๊ณผ๊ฐ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. ๋๋ฅผ ์ํด ๊ทธ๊ฒ์ AOT ์ปดํ์ผ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค.
์ ๊ฒฝ์ฐ์๋ ํด๊ฒฐํ์ต๋๋ค. ๋ฌธ์ ๋ ์ผ์ด์ฑ์ด์์ต๋๋ค. ํด๋์ ๋๋ฌธ์๋ฅผ ์ฌ์ฉํ์ง๋ง VS ์ฝ๋์ ์๋ ๊ฐ์ ธ์ค๊ธฐ๋ ์๋ฌธ์๋ก ๊ฒฝ๋ก๋ฅผ ๊ฐ์ ธ์์ต๋๋ค.
@renilbabu03 JS๋ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํฉ๋๋ค.
์ ๊ฒฝ์ฐ์๋ ๋ฒ์ญ ํ์ดํ๋ฅผ ์กฐ๋กฑํ ๋จ์ ํ ์คํธ๋ฅผ ์ํด ์์ ํ์ต๋๋ค.
export class
์ default export
๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
import { PipeTransform, Pipe } from '@angular/core';
@Pipe({
name: 'translate'
})
class TranslatePipeMock implements PipeTransform { // <-- NOT: "export class TranslatePipeMock implements PipeTransform"
public name = 'translate';
public transform(query: string): any {
return query;
}
}
export default TranslatePipeMock;
์ด์ ๋ํ ์์ ์ฌํญ์ด ์์ต๋๊น?
export default <class>
์๋ํ์ง๋ง $# ng serve --aot
์คํํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์๊ธฐ์น ์์ ๊ฐ 'null'์ด ๋ชจ๋์์ ๋ด๋ณด๋์ต๋๋ค .
๋งค์ฐ ๋ต๋ตํฉ๋๋ค.
@redplane ์ ๊ทธ๋ ๊ฒ ํ๊ณ ์ถ์ด? default
์์ถ์ ์๋ฏธํฉ๋๋ค.
๊ทธ๋ค์ด ์ค์ค๋ก ํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
https://github.com/angular/angular/blob/master/aio/content/examples/testing/src/testing/router-link-directive-stub.ts
๋ด๊ฐ import
exported
์์ฐ์ด ์๋ ํ Angular๋ ํ์ผ์ด ์กด์ฌํ๋ ๊ฒฝ์ฐ ์ ์ ๊ฒฝ์ ์ฐ๋์?
์ข ์ข ๋๋ ์ปดํฌ๋ํธ๋ฅผ ๋ฆฌํฉํ ๋งํ๊ฑฐ๋ ์ปดํฌ๋ํธ๋ฅผ ์ ๊ฑฐํ๊ณ CommonJS ์์ ์ ํ๋ ๊ฒ์ฒ๋ผ ์ค๋๋ ์ปดํฌ๋ํธ ์ฐธ์กฐ๋ฅผ ์ฃผ์ ์ฒ๋ฆฌํ๊ณ ์ถ์ต๋๋ค. ๋๋ ๋ฐฐ๋ด ํ์ผ์ ์ฌ์ฉํ์ง ์์๊ธฐ ๋๋ฌธ์ ์ถฉ๋ถํ ์์ ํ ๊ฒ์ ๋๋ค. ์๋ํ๋ฉด ๊ทธ ์์์ ๋๋ฌด ๋ง์ด ํ์์ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค. ๊ทธ๋ฆฌ๊ณ Angular๊ฐ ๊ฐ์ ๋ก ๋ด ํ๋ก์ ํธ์์ ์์ฐ์ ์ ๊ฑฐํ๋๋ก ํ๋ ๊ฒ์ ๋ด๊ฐ ๋ชฉ์ด ๊น์ ๋ ์ฉ๋ฉ๋ ์ ์์ต๋๋ค. ํ๋กํ ํ์ดํ ๋จ๊ณ...
๋๋ ์ด ํ๋ก์ ํธ์์ ์์ ํ๋ ์ ์ผํ ๊ฐ๋ฐ์์ด๊ธฐ ๋๋ฌธ์ Angular 6์ ๊ฐํ๊ณ ์๋ก์ด ๊ธฐ๋ฅ์ ์ ๊ณตํด์ผ ํ๋ ๊ฐ์ด๋ฐ ์ต์ ์์ ์ ์ธ ๋๊ตฌ๋ฅผ ์ป๊ธฐ ์ํด ๋ชจ๋ ๊ฒ์ ๋ฆฌํฉํ ๋งํ๋ ๊ฒ์ ์ง์ฅ์ผ ๊ฒ์ ๋๋ค. ์ ์ด๋ Angular 6+๊ฐ ์ด ๋์์ ๋นํ์ฑํํ๊ธฐ ์ํ ์ปดํ์ผ๋ฌ ํ๋๊ทธ๋ก ํจ์น๋ ์ ์๋ค๋ฉด ์ข์ ๊ฒ์ ๋๋ค...
์ ๊ฒฝ์ฐ์๋ ๊ฐ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๋ก์ ํธ ์ค์ ์ด ์์ต๋๋ค. ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ด์ ๊ตฌ์ฑ ์์ ์ค ํ๋์์ ๋ช ๊ฐ์ ์ด๊ฑฐํ์ ์ ์ธํ์ต๋๋ค. ์์ฉ ํ๋ก๊ทธ๋จ ํ๋ก์ ํธ์์ ์ด๋ฌํ ์ด๊ฑฐํ์ ์ฌ์ฉํ๊ธฐ ์ํด ์์ฉ ํ๋ก๊ทธ๋จ ๋ฃจํธ์ ํ๋ก์ ํธ ๋๋ ํฐ๋ฆฌ์ ๋ํ ์๋ ๊ฒฝ๋ก ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ์ ธ์์ต๋๋ค.
์ด๊ฒ์ด Angular ์ปดํ์ผ๋ฌ๊ฐ ๋ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ตฌ์ฑ ์์๊ฐ ์ ํ๋ฆฌ์ผ์ด์ ํ๋ก์ ํธ์ ngModule์์ ์ ์ธ๋๊ธฐ๋ฅผ ์ํ๋ ์ด์ ์ ๋๋ค.
์ด ์ค๋ฅ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ๋ด ์ด๊ฑฐํ์ public-api.ts ํ์ผ์ ์ ์ธ ํ๊ณ ์๋ ๊ฐ์ ธ์ค๊ธฐ ๊ฒฝ๋ก๊ฐ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ง์ ๊ฐ์ ธ์ค๋ ์์ฉ ํ๋ก๊ทธ๋จ ํ๋ก์ ํธ์์ ์ฌ์ฉํฉ๋๋ค.
์๋ฅผ ๋ค์ด:
๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๋ก์ ํธ ์ด๋ฆ: components-lib
์ ํ๋ฆฌ์ผ์ด์
ํ๋ก์ ํธ ์ด๋ฆ: demo-app
๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๋ก์ ํธ ๋ด๋ถ์ ์ ์ธ๋ ์ธํฐํ์ด์ค, ํด๋์ค, ์ด๊ฑฐํ ๋ฑ์ ์ฌ์ฉํ๋ ค๋ฉด ์ง์ ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ์ ธ์ต๋๋ค.
'components-lib'์์ { SearchEnum } ๊ฐ์ ธ์ค๊ธฐ;
๊ทธ๋ฆฌ๊ณ ํ์ง๋ง
import { SearchEnum } from '../../../projects/components-lib/path-to-your-component';
๋๋ ์ด๊ฒ์ ์ฐพ๋ ๋ฐ ๋ช ์๊ฐ์ ๋ณด๋๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ด ๋ฏธ๋์ ๋๊ตฐ๊ฐ๋ฅผ ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
ng 8์ ์คํํ๋ ์ฌ๋๋ค์ด ์ฌ์ฉํ ์ ์๊ธฐ๋ฅผ ๋ฐ๋ผ๋ ng 9๋ก ๋น๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ํธํ์ฑ์ ์ ์งํ๋ ๋ฐ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ๊ตฌ์ฑ ์์๋ฅผ ํ์ฅํ ์ ์๋ ๋ช ๊ฐ์ง ์ ํธ๋ฆฌํฐ ํด๋์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. ํด๋น ๋ถ๋ชจ ํด๋์ค ์ฒด์ธ์์ ์ด๋ค ์ค ์ผ๋ถ๋ ์ถ์์ ์ด๋ฉฐ ng 9์์๋ ng 8๊ณผ ํธํ๋๋๋ก @Directive({ selector: 'random' })
๊ฐ ํ์ํฉ๋๋ค.
๊ทธ๋์ ๋๋ ๊ทธ๊ฒ์ ๊ฑฐ์ ํผํ ๋ปํ์ต๋๋ค ... ๊ทธ๋ฌ๋ :
Cannot determine the module for class NgxSubFormComponent in /........./node_modules/ngx-sub-form/ngx-sub-form.d.ts! Add NgxSubFormComponent to the NgModule to fix it.`
๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ด์์ ์ด๋ค ๋ชจ๋๋ ๋ ธ์ถํ์ง ์์ต๋๋ค. ์ฌ๋๋ค์ ์ฐ๋ฆฌ๊ฐ ์ ๊ณตํ๋ ํด๋์ค๋ฅผ ํ์ฅํด์ผ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋๋ ๊ทธ๋ค์ด ๋ชจ๋์์ ๋ถ๋ชจ ํด๋์ค๋ฅผ ๊ฐ์ ธ์์ผ ํ๋ ๊ฒ์ ์ํ์ง ์์ต๋๋ค(์ดํด๊ฐ ๋์ง ์์ต๋๋ค).
๊ทธ๋์ ์ ๋ ๋งํ๊ณ ์ฌ๋๋ค์ด ์ด์ ๋ฒ์ ๊ณผ์ ํธํ์ฑ ๋์ ng 9๋ก ์ ๊ทธ๋ ์ด๋ํด์ผ ํ๋ ์ฃผ์ ๋ณ๊ฒฝ ๋ฆด๋ฆฌ์ค๋ฅผ ์๋ผ๋ผ ๊ฒ์ ๋๋ค.
์ฌ๋ฌ๋ถ, ์ด ๋ฌธ์ ์ ๋ํด ์นจ๋ฌต์ ์ง์ผ์ ์ฃ์กํฉ๋๋ค.
View Engine์ ngc๋ ์๋์ ์ผ๋ก "์ปดํ์ผ"์ ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ํด ngfactory
ํ์ผ์ ์์ฑํฉ๋๋ค. ์ฆ, tsconfig์ ์ํด ์ ์๋ ์ ์ฒด TS ํ์ผ ์ธํธ์
๋๋ค. ์ด๊ฒ์ด TypeScript๊ฐ
์์ฒด ์๋ - tsconfig์ ์ํด ์ ์๋ ๋ชจ๋ ํ์ผ์ ์ปดํ์ผํฉ๋๋ค. ngc๋ ๊ทธ ์์ ์ถ๊ฐ ์ฒ๋ฆฌ๋ฅผ ์ํํ๊ณ ์์ต๋๋ค.
๋ฐ๋ผ์ ํด๋น ์ปดํ์ผ์ @Component
๊ฐ ์๊ณ ngc๊ฐ ์ด๋ฅผ ๋ณผ ์ ์๋ ๊ฒฝ์ฐ(์ฆ, ์ต์์ ์์ค์ด๊ณ ๋ด๋ณด๋ธ ๊ฒฝ์ฐ) ngc๋ ์ปดํ์ผ์ ์๋ํฉ๋๋ค. ngc๊ฐ ์ฒ์์ ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธํ๋ ํ์ผ์ ์ปดํ์ผํ์ง ์๋๋ก ํ๋ ๊ฒ ์ธ์๋ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๋ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
์ด๋ฅผ ์ํํ๋ ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์ tsconfig์ ๋ฒ์๋ฅผ ์ง์ ํ๋ ๊ฒ์
๋๋ค. ์๋ฅผ ๋ค์ด, ๋ชจ๋ ํ์ผ์ ํฌํจํ๋ ํธ์ง๊ธฐ์ฉ ์ต์์ tsconfig๊ฐ ์์ ์ ์์ผ๋ฉฐ, ๋ค์์ผ๋ก ํธ์ง๊ธฐ ๊ตฌ์ฑ์์ ์์ํ๊ณ ์ฌ์ ํ์ผ์ ์ ์ธํ๋ ์ ํ๋ฆฌ์ผ์ด์
์ปดํ์ผ์ ์ํ tsconfig.app.json
๊ฐ ์์ ์ ์์ต๋๋ค. ์ฑ ๊ตฌ์ฑ๋ง ngc๋ก ์ปดํ์ผ๋ฉ๋๋ค.
ํ๋ก์ ํธ(๊ฐ tsconfig๋ "ํ๋ก์ ํธ"์)๋ ๊ตฌ์ฑ ์์์ ํด๋น ๋ชจ๋์ด ํญ์ ํจ๊ป ์ปดํ์ผ๋๋๋ก ๊ตฌ์ฑ๋์ด์ผ ํฉ๋๋ค.
Ivy์์๋ ๋ช ๊ฐ์ง ์์ ์ฐจ์ด์ ์ ์ ์ธํ๊ณ ๋์ผํ ๊ท์น์ด ์ฌ์ ํ ํฌ๊ฒ ์ ์ฉ๋ฉ๋๋ค.
@Component
์ปดํ์ผ์ ์๋ํฉ๋๋ค.jit: true
ํ๋๊ทธ๋ฅผ ์ถ๊ฐํ์ฌ ํน์ ๊ตฌ์ฑ ์์๋ ๋ชจ๋์ ๋ฌด์ํ๊ณ ๋ฐํ์๊น์ง ๊ทธ๋๋ก ๋๋๋ก Ivy ์ปดํ์ผ๋ฌ์ ์ง์ํ ์ ์์ต๋๋ค.@alxhub ๋ ์ด์ ์ค๋ฅ๊ฐ ์๋๋ผ๋ ์์์ ๋ค์ผ๋ ๊ธฐ์ฉ๋๋ค!
๋๋ ngc๊ฐ tsc๊ฐ ํ๋ ๋ชจ๋ ๊ฒ์ ์๋ํ๊ณ ์ปดํ์ผํ ๊ฒ์ด๊ณ , tsc๊ฐ ๊ทธ ๋ฒ์ ๋ด์์ ๋ฌด์์ด๋ ์ปดํ์ผํ ๊ฒ์ด๋ผ๋ ๊ฒ์ ์ดํดํฉ๋๋ค. ์ฆ, ๊ตฌ์ฑ ์์๋ฅผ ๋ชจ๋์ ์ถ๊ฐํด์ผ ํ๋ค๋ ์๊ตฌ ์ฌํญ์ 100% ๊ฐ๋ ๋ฌธ์ ์ด๋ฏ๋ก ํ์ดํ์คํฌ๋ฆฝํธ ํ๋ก์ ํธ ๋ฒ์์์ ๊ตฌ์ฑ ์์๋ฅผ ์ ๊ฑฐํ๋ ๊ฒ์ ๊ธธ์ ๊ฑท์ด์ฐจ๋ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค. ๋ํ ๋ฐฐ๋ด ํ์ผ๊ณผ ๊ฐ์ ํจํด์ด ์ผ๋ฐ์ ์ด๋ฏ๋ก ๋์ค์ ๋ค์ ๋ด๋ณด๋ด๊ธฐ์์ ํ์ผ์ ์ ๊ฑฐํ์ง ์๊ณ ๋จ์ผ ํ์ผ์ ์ปดํ์ผ์์ ์ง์ ์ผ๋ก ์ ๊ฑฐํ๊ธฐ ์ด๋ ค์ธ ์ ์์ต๋๋ค. ์ด๊ฒ์ด ๋ฐ๋ก ์์์ ๋จ์ํ "ํด๋น ๊ตฌ์ฑ ์์๋ฅผ ์ ์ธ"ํ๋ผ๋ ์์ฒญ์ ์ข ์ข ๋ถ๋ง์ ์ ๊ธฐํ ์ด์ ์ ๋๋ค.
ivy์ ๋๋จธ์ง ์ ํ ์ฌํญ(๋ชจ๋์ด ์๋ ๊ตฌ์ฑ ์์์ ํ
ํ๋ฆฟ ์ค๋ฅ)๊ณผ ๊ด๋ จํ์ฌ ๊ฒฝ๊ณ ๋ ์๊ตฌํ๋ ๊ฒ์ด ๋๋ฌด ๋ง์๊ฐ์? ๊ตฌ์ฑ ์์๊ฐ ๋ชจ๋์ด ์๋ ๊ฒ์ผ๋ก ์๋ณ๋๊ธฐ ์ ์ ์ ํ ๊ฒ์ฌ๊ฐ ๋ฐ์ํ๋ฉด ๋ ์ด๋ ต๊ฑฐ๋ ๋ถ๊ฐ๋ฅํ ์ ์๋ค๋ ์ ์ ์ดํดํ์ง๋ง Warning: ExampleUnusedComponent does not belong to an NgModule, and will be excluded from the output
ํ์ ๋ฐ๋ฅธ ๊ฒฝ๊ณ ๊ฐ ๊ตฌ์ฑ ์์(๋ฐ ๊ตฌ์ฑ ์์์์ ์ฐธ์กฐํ๋ ๋ค๋ฅธ ๊ตฌ์ฑ ์์)๋ ngModule์ ์ถ๊ฐ๋์ง ์๋ ํ ํฌํจ๋์ง ์์ต๋๋ค.
์ ๋ฐ์ ์ผ๋ก ์ด ๋ฌธ์ ์ ๋ํ ์์ง์์ ๋ณด๊ฒ ๋์ด ๋งค์ฐ ๊ธฐ์ฉ๋๋ค. ivy ์ปดํ์ผ๋ฌ์ ์๋ก์ด ๋ณ๊ฒฝ ์ฌํญ์ผ๋ก ์๋์ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ์ํํด ๋ณด๊ธฐ๋ฅผ ๊ธฐ๋ํฉ๋๋ค!
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@DzmitryShylovich ์ฌ์ฉ ์ค์ธ ๊ตฌ์ฑ ์์๊ฐ ๋ชจ๋์ ์ผ๋ถ๊ฐ ๋์ด์ผ ํ๋ค๋ ๊ฒ์ ์๋ฏธ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ปดํ์ผ๋ฌ์ ๊ดํ ํ ์ด๋ฌํ ํ์ผ์ ์ค์ํ์ง ์์ต๋๋ค. ๊ตฌ์ฑ ์์๋ฅผ ํฌํจํ๋ ์ฌ์ฉ๋์ง ์๊ณ ์ฐธ์กฐ๋์ง ์์ .ts ํ์ผ์ ๋๋ค.