ovsleep / bootstrap-switch

This is a Angular 2 Component to add a switch like input.
https://bootstrap-switch.herokuapp.com/
8 stars 10 forks source link

Problem running a production build #10

Open smlombardi opened 7 years ago

smlombardi commented 7 years ago

The component works great with ng serve, but when I try to build by project angular-cli throws an error:

ERROR in Unexpected value 'SwitchComponent in /Users/stevelombardi/github/ng-designsystem/client/node_modules/angular2-bootstrap-switch/lib/switch.component.d.ts' declared by the module 'WebModule in /Users/stevelombardi/github/ng-designsystem/client/src/app/web/web.module.ts'. Please add a @Pipe/@Directive/@Component annotation.
smlombardi commented 7 years ago

You might also consider renaming this component to something less generic, as there are many SwitchComponents out there.

ovsleep commented 7 years ago

Ha, yea didn't think much about the naming. This was just a personal project, didn't thought anyone would actually use it. But it's really cool someone does. About the error, I came across with it before and I think it's an issue provoked by the angular version I used to create the project the first time, which was Angular 2. Using version 4> has this compatibility issues. Which versions of angular and angular-cli are you using? and the parameter for ng build? I'm guessing I'll need to rewrite this from scratch using latest versions to avoid this issues

ovsleep commented 7 years ago

Seems everything works running the build like this: ng build --env=prod

Can you confirm if this works for you too?

HappyCodeSloth commented 7 years ago

Firstly thanks for the component. That does work. It's with aot that it doesn't work. So, ng build --aot --env=prod

LucaDelBuono commented 6 years ago

Any updates on this? I need to build using AOT...

Sathishchary commented 6 years ago

I am also getting the same problem when i build project with AOT.

jimjaeger commented 6 years ago

Hi,

the component/module still does not work with aot compilation in ng build.

You might want to look into the attached version of the module to fix the issue? bootstrap-switch_patched.zip

I tried a production build with using this code and the build was successful. you can try with


import { SwitchModule } from '../bootstrap-switch/switch.module';
..
 imports: [
...
  SwitchModule,
...
}`
ovsleep commented 6 years ago

Thanks @jimjaeger , did you made any changes in the component itself? Or was it just adding the switch.module.ts file? I'm currently trying to find a way to package it and make everything work, but I'm running into lot of different errors. Any help is appreciated!

ovsleep commented 6 years ago

BTW, I'm trying to pack everything up following this tutorial

ovsleep commented 6 years ago

After going back and forward I think I've finally found a solution for this. I changed the way I was packaging the component using this. I reached a dead end with the previous tutorial. So please update to the latest version (0.2.1) and make sure to check the installation instructions, it changed a bit since previous version due to the new packaging. Hope this finally fix this, please let me know if anything looks off.

jimjaeger commented 6 years ago

@ovsleep Right, I added the module but also changed the visibility of the private variables because they need to be accessible when you want to use it in the html file. Also I ordered the variables and methods and changed compares based on the lint markers.

If you want to package your module in standard way here is a description: https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview and also a example project in the examples section: filipesilva/angular-quickstart-lib

jimjaeger commented 6 years ago

When you are going to rewrite your module, you may think about to additionally support an Observable as status input value. Also did you see this project https://ng-bootstrap.github.io/#/home .. Did you already think about to donate the code to this collection?

ovsleep commented 6 years ago

@jimjaeger thanks for the doc, I'll review it and check if my packaging now respect it. Not sure about donating the code, in fact this was just an experiment trying to learn a bit of Angular, never though someone actually would try to use it. I might try to add a few other components now if everything works.