juanjoDiaz / json2csv

Flexible conversion between JSON and CSV
https://juanjodiaz.github.io/json2csv/
MIT License
306 stars 32 forks source link

Error compiling Transform with Vue3/Vite4 #12

Closed UglyHobbitFeet closed 1 year ago

UglyHobbitFeet commented 1 year ago

Trying to build with Vue3 / Vite v4.0.4 and it won't compile. Stacktrace is:


#0 3.198 vite v4.0.4 building for production...
#0 3.365 transforming...
#0 12.35 ✓ 745 modules transformed.
#0 12.35 "Transform" is not exported by "__vite-browser-external", imported by "node_modules/@json2csv/node/src/Transform.js".
#0 12.35 file: /app/node_modules/@json2csv/node/src/Transform.js:2:9
#0 12.35 1: import os from 'os';
#0 12.35 2: import { Transform } from 'stream';
#0 12.35             ^
#0 12.35 3: import { StreamParser } from '@json2csv/plainjs';
#0 12.35 4: import { fakeInherit } from './utils.js';
#0 12.35 error during build:
#0 12.35 RollupError: "Transform" is not exported by "__vite-browser-external", imported by "node_modules/@json2csv/node/src/Transform.js".
#0 12.35     at error (file:///app/node_modules/rollup/dist/es/shared/rollup.js:2001:30)
#0 12.35     at Module.error (file:///app/node_modules/rollup/dist/es/shared/rollup.js:12930:16)
#0 12.35     at Module.traceVariable (file:///app/node_modules/rollup/dist/es/shared/rollup.js:13296:29)
#0 12.35     at ModuleScope.findVariable (file:///app/node_modules/rollup/dist/es/shared/rollup.js:11828:39)
#0 12.35     at ChildScope.findVariable (file:///app/node_modules/rollup/dist/es/shared/rollup.js:6707:38)
#0 12.35     at Identifier.bind (file:///app/node_modules/rollup/dist/es/shared/rollup.js:7802:40)
#0 12.35     at ClassDeclaration.bind (file:///app/node_modules/rollup/dist/es/shared/rollup.js:5597:23)
#0 12.35     at ExportDefaultDeclaration.bind (file:///app/node_modules/rollup/dist/es/shared/rollup.js:5597:23)
#0 12.35     at Program.bind (file:///app/node_modules/rollup/dist/es/shared/rollup.js:5593:28)
#0 12.35     at Module.bindReferences (file:///app/node_modules/rollup/dist/es/shared/rollup.js:12926:18)
#0 12.47 ERROR: "build-only" exited with 1.
UglyHobbitFeet commented 1 year ago

Dunno if it's related or not, but importing it generates the following error in VsCode.

import { AsyncParser } from '@json2csv/node'; // <-- Error shows up here (aka red squiggly line)
const parseAsync = (data: string[], opts: { fields: string[] }, transformOpts: string[]) => new AsyncParser(opts, transformOpts).parse(data).promise();
Error:
Could not find a declaration file for module '@json2csv/node'. '/home/myPath/node_modules/@json2csv/node/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/json2csv__node` if it exists or add a new declaration (.d.ts) file containing `declare module '@json2csv/node';`ts(7016)
juanjoDiaz commented 1 year ago

Hi @UglyHobbitFeet ,

This is cause by the lack of Typescript typings in the project as already raised in #1

I'm in the middle of porting the library to Typescript to provide the best possible support. In the meantime, check that other issue for the workaround which is to create you own type definition.

Sorry for the inconvenience!

UglyHobbitFeet commented 1 year ago

Ok thanks!

On Sat, Jan 21, 2023, 6:27 AM Juanjo Diaz @.***> wrote:

Hi @UglyHobbitFeet https://github.com/UglyHobbitFeet ,

This is cause by the lack of Typescript typings in the project as already raised in #1 https://github.com/juanjoDiaz/json2csv/issues/1

I'm in the middle of porting the library to Typescript to provide the best possible support. In the meantime, check that other issue for the workaround which is to create you own type definition.

Sorry for the inconvenience!

— Reply to this email directly, view it on GitHub https://github.com/juanjoDiaz/json2csv/issues/12#issuecomment-1399232862, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBDS7QQJEPLVDYTWYDPBCTWTPBYNANCNFSM6AAAAAATYIL3P4 . You are receiving this because you were mentioned.Message ID: @.***>

juanjoDiaz commented 1 year ago

I just released v7.0.0 which entirely rewrites @json2csv to typescript.

Let me know if you find any issues with it. This was a massive change.