Closed guillaumeprevost closed 1 year ago
bump
Hi guys,
Sorry for the slow response. I'm looking into this.
Looking at the files structure, there doesn't seem to be any JS file at the root of the package, only within dist / src.
That is correct. You can see the routing here: https://github.com/juanjoDiaz/json2csv/blob/main/packages/formatters/package.json#L27-L36
I haven't been able to reproduce the issue. It just works for me... π
Can you create a public sample project that I can use to reproduce the issues?
Have you tried it using Nuxt/VueJS ?
Unfortunately I don't have much extra time to create a repro repository, I have reverted to the previous version (unsupported) from package zemirco/json2csv
If I manage to find time for this I'll do it gladly !
Running into this issue on my end as well. The imports being made from BaseParser.js are pointing to the root of formatters instead of the /src folder. Error when away when I added /src to the import path
We had to add this to our jest.config.js moduleNameMapper to get it to map properly: "^@json2csv/formatters/(.*)\\.js$": "<rootDir>/node_modules/@json2csv/formatters/src/$1.js",
Running into this issue on my end as well. The imports being made from BaseParser.js are pointing to the root of formatters instead of the /src folder. Error when away when I added /src to the import path
The src shouldn't be needed since the mapping is configured in package.json
(See code)
We had to add this to our jest.config.js moduleNameMapper to get it to map properly:
"^@json2csv/formatters/(.*)\\.js$": "<rootDir>/node_modules/@json2csv/formatters/src/$1.js",
That seems specific to jest (does jest not respect the exports
setting?).
However, the original question in this issue was about Vue/Nuxt.
Does Vue/Nuxt use a resolver that doesn't respect exports
?
As said, I can't reproduce. I sample project to reproduce will accelerate the resolution of this issue.
@juanjoDiaz I could make a reproduction for jest if that's useful? I didn't have an issue importing it in our actual project though.
It has the same errors for Meteor Js. We are using absolute import. it may be reason.
@juanjoDiaz I could make a reproduction for jest if that's useful? I didn't have an issue importing it in our actual project though.
Please do.
Sorry guys, but without a repo to reproduce the issue, there isn't much that I can do π.
I just released v7.0.0 which entirely rewrites @json2csv to typescript.
Is the issue still present?
@juanjoDiaz yes just tried this for a Vue/Jest project.
Shouldn't this be updated to import ts files?
Nope! π
This was a very controversial design choice made by typescript. You can read https://github.com/microsoft/TypeScript/issues/16577#issuecomment-703190339 or any of the other gazillion issues on their repo about this issue.
In short:
People went crazy around this topic for a while and the Typescript maintainers have been absolutely categorical in many occasions on that they will never implement the mapping from .ts to .js and that this is the way.
I know that is weird. But that Typescript π€·ββοΈ
Thanks for the info @juanjoDiaz, good to know! π
Same error v7 for Meteorjs v2.12
I've released v7.0.1 which imports formatters from the top level package. But really guys... without a repo for me to reproduce... I can't do anything else...
Hi there, same issue here. I don't have enough time to create a PoC but i'll share my tsconfig.json
in case that helps or we can find a common pattern:
{
"compilerOptions": {
"target": "es2016",
"experimentalDecorators": true,
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"strictFunctionTypes": false,
"noImplicitThis": false,
"useUnknownInCatchVariables": false,
"noImplicitAny": false,
"allowJs": true,
"types": [
"vuetify"
],
"paths": {
"@/*": ["src/*"]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
],
"outDir": "dist",
},
"include": [
"src/**/*",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx",
],
"exclude": [
"node_modules",
...
]
}
I'll see if I can take a deeper dive next week.
I also stumbled into this issue. My problem was when running test with jest@27.x.x. After updating jest to v29 the issue went away.
I made a reproduction repo before trying out to upgrade jest. Sharing the repo in case anyone is curious and wants to reproduce it:
Is this still an issue for anyone?
Popping in to say that I was facing similar issues as @Rapol, but upgrading to jest@29 also fixed my issues
I'll close then.
If someone is still facing the issue, this can be reopenened.
I run into an error after migrating from
json2csv v5.0.7
(that was working nicely)Using
@json2csv/node v6.1.2
Node versionv16.19.1
Here is the code I am using (within a VueJS / Nuxt web app) :
When trying to start the web app (npm run dev), I get this error :
And indeed, this is what I see when looking into my node_modules folder to check the json2csv
BaseParser
:Looking at the files structure, there doesn't seem to be any JS file at the root of the package, only within dist / src.
Expected the sample code to compile and run Actual output : error message mentioned above
Am I doing something wrong here or is there really an import problem within the lib ?