mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.54k stars 1.15k forks source link

ES6 module for PapaParse #813

Open aishwaryasharma14 opened 4 years ago

aishwaryasharma14 commented 4 years ago

While upgrading to Angular 10, using PapaParse gives following warning message - WARNING in C:\parser.component.ts depends on papaparse. CommonJS or AMD dependencies can cause optimization bailouts.

This seems to be because PapaParse is CommonJS module dependency.

I am importing papaparse as follows - import * as csvParser from 'papaparse';

and using it as - csvParser.parse(file, {});

Can you help me with an ES6 module that I could use instead?

pokoli commented 4 years ago

Currently the typescript defintions are managed here https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/papaparse So you should update them there.

See #545

PooSham commented 4 years ago

@pokoli That doesn't seem very relevant at all. ES6 modules are part of modern javascript, they have nothing to do with typescript.

The import and export keywords are now native to javascript, and you can now isolate your files as modules without wrapping everything in a function that you call (like you do now). If you still want backward compatibility, you can use babel that will generate CommonJS and AMD modules for you. Your code gets cleaner and users of this library can get more aggressive optimization. win-win.

TLDR; Having typescript definitions is not enough. We want ES6 modules.

pokoli commented 4 years ago

@PooSham Thanks for the explanation. I will reopen the issue.

I think this should be part of a new major release to allow users continue using the current version.

I will be happy to review any PR implementing ES6 modules.

PooSham commented 4 years ago

@pokoli Thank you for reopening it :)

Yes, making it a part of a major release seems reasonable.

I have quite a lot at work right now, but I might look at it in 2 weeks or so (can't promise though).

zgosalvez commented 3 years ago

Looking forward to this release. I fear my Angular app might break if we decide to continue upgrading to Angular 11.

raysuelzer commented 3 years ago

Looking forward to this release. I fear my Angular app might break if we decide to continue upgrading to Angular 11.

@zgosalvez Just upgraded to angular 11, no issues other than the library cannot be optimized for size.

Silic0nS0ldier commented 3 years ago

As a first step I've created a PR that introduces support in (hopefully) the least backwards incompatible way. The code I'm confident with, build system support less so. Anyone up for some integration testing? PR is https://github.com/mholt/PapaParse/pull/875