adaltas / adaltas/node-csv

angular stream import

Open
#285 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
4.3k
Forks
299
Avg merge
16h 19m
Merged PRs (30d)
1

Description

When using some of the libraries, I used 'csv-stringify' (Which is Awesome, thanks for the project), inside an angular project I got this error while building using ng build:

Module not found: Error: Can't resolve 'stream' in '{project-path}/node_modules/csv-stringify/lib'
resolve 'stream' in '{project-path}/node_modules/csv-stringify/lib'
  Parsed request is a module
  using description file: {project-path}/node_modules/csv-stringify/package.json (relative path: ./lib)
    Field 'browser' doesn't contain a valid alias configuration
...

I think the API is really awesome and loved it while using it. That's why I think the library should add some kind of notice or warning to non-nodejs execution environments like while using angular, just to clarify that It won't work by default or out of the box as brower environments doesn't implement the stream library (which nodejs by default does.). Also offer a simple fix which is:

Add the dependency stream-browserify node module using "npm install stream-browserify"

Override the path mapping in the tsconfig.json:

"compilerOptions": {
      "paths": {
         ...
        "stream": ["node_modules/stream-browserify"],
      }

This same issue was reported long ago in the old repo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Angular build failure with the reported csv-stringify/lib import and inspect the package.json browser configuration. Determine whether the project should document the stream-browserify and tsconfig.json workaround or change its browser handling; done means the expected Angular behavior and supported workaround are clearly documented or validated by ng build.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript, nodejs
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.