0

I'm just starting out with Angular 4 and Typescript imports. I would like to do:

 npm install papaparse-angular4
 //Inside csv-service.ts
 import pa4 from  `papaparse-angular4`;

The library papaparse-angular4 does not exist. So I need to create it. I'm wondering what the basic outline of steps I need to take to convert papaparse over to something that can be used by angular 4 are?

Ole
  • 41,793
  • 59
  • 191
  • 359
  • do you need a service? you can just use it anywhere in your angular code. Assuming you have it as a script on the page. – Ahmed Musallam May 04 '17 at 00:26
  • True - Although if I can refactor it to typescript and provide it as an es5 module then it's a better fit for web pack / rollup etc. The .d.ts definitions can also be made available. – Ole May 04 '17 at 02:12
  • Well, it's open source. To refactor it entirely, you have to read and understand the source code. – Ahmed Musallam May 04 '17 at 02:29
  • Yeah I"m going through it right now. Also found a pretty good article on steps to create esm modules for Angular 4 (http://blog.mgechev.com/2017/01/21/distributing-an-angular-library-aot-ngc-types/) .... if anyone has any additional tips they would be very much appreciated. – Ole May 04 '17 at 04:37
  • Your case is pretty straight forward. You can use one of the available quickstarters like angular-cli or seed. Build papaParse into services, add them to a module and export them. Then publish the library on NPM and use it. Or use it from your local or included it in your current repo. – Ahmed Musallam May 04 '17 at 12:11
  • There already is a module for angular4. https://github.com/Alberthaff/ngx-papaparse Just scroll down and it tells you to install it with `npm install ngx-papaparse@1.2.5 --save` for angular4. – Oliver Nybroe Apr 04 '18 at 13:27

0 Answers0