angularjs - Trying to NPM publish and install a custom angular2 component with Angular-CLI; only compiles the first time -


i'm having unusual , frustrating problem.

i have ng2 component called via-date-picker trying npm publish can used in other projects. in order so, have made angular2 component library. via-date-picker exports module called viadatepickermodule, want import elsewhere.

in order test , make sure being published correctly, npm-installing , importing otherwise empty angular-cli project calling npm-test.

so run npm-test application using "ng serve", , error:

error in viadatepickermodule not ngmodule webpack: failed compile

yet despite error, project compiles anyway:

has error, compiles anyway

and when open project, lo , behold, works!!

but happens first time run project. on successive attempts run project via "ng serve", same compilation error, time project flat-out refuses complete it's compilation:

enter image description here

i have no idea why i'm getting error, , why angular-cli run project not others.

i've scoured web answers , tried every solution can find error, every other thing can think of:

  • i've tried adjusting tsconfig settings in component library
  • i've tried using rollup.js instead of gulp.js build component library
  • i've tried copying existing, working component libraries, swapping out existing code own
  • i've downgraded angular cli
  • i've upgraded angular cli
  • i've downgrade typescript
  • i've upgraded typescript
  • i've deleted , re-installed node_modules several times
  • i've deleted , re-started whole project twice

no matter do, keep coming same webpack error posted above; viadatepickermodule not ngmodule. i'm out of ideas. provide crazy helpful.

for sake of complete thoroughness, i've created public repo on github here containing files involves, divided 2 main directories:

  • component_before_publishing: contains component library running "npm publish"
  • what_is_imported_into_node_modules: contains resulting directory being imported node_modules directory of npm-test project

again, provide extremely, extremely appreciated! really, eternally grateful.

if %100 sure of consumers import components, modules ...etc ts project such angular-cli. can publish ts source directly without transpiling. ie. you'll publishing static .ts files can imported in project transpiling you.

however, if want library also consumed js es5 or es6 module, should transpile.

also, can try angular compiler ngc instead of typescript compiler tsc? ngc wrapper around tsc. start there, there many library starters put there can start angular library , optimized aot compilation.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -