Open sakamossan opened 1 year ago
Hello, this is very strange. You are using ESModule instead of commonjs, but "imported" commonjs. Can you provide me a repo with a reproduction? I will try to resolve it. @sakamossan
nextjs and other framework takes the main entry so this is why
Apologies for the delayed response. I have prepared a minimal code example to reproduce the issue in my environment.
jest.config.js
ts-jest/presets/default-esm
--experimental-vm-modules
optiontsconfig
tsc --init
$ git clone git@gist.github.com:2128748b0da8e7b884413cfe8a001883.git repro-zodcsv
$ cd repro-zodcsv/
$ npm ci
$ npm test
$ npm test
> tryzodcsv@1.0.0 test
> node --experimental-vm-modules node_modules/.bin/jest
FAIL ./index.test.ts
● Test suite failed to run
TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at f (node_modules/zod-csv/dist/zcsv.js:204:10)
at node_modules/zod-csv/dist/zcsv.js:207:7
at node_modules/zod-csv/dist/zcsv.js:218:7
at ne (node_modules/zod-csv/dist/zcsv.js:239:6)
at $ (node_modules/zod-csv/dist/zcsv.js:248:18)
at node_modules/zod-csv/dist/zcsv.js:385:60
at node_modules/zod-csv/dist/zcsv.js:386:3
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.577 s
Ran all test suites.
(node:99050) ExperimentalWarning: VM Modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
$ node --version
v18.13.0
The error occurs in the following part of the code
at f (node_modules/zod-csv/dist/zcsv.js:204:10)
return function(c, h) {
f(c, h);
function p() {
this.constructor = c;
}
c.prototype = h === null ? Object.create(h) : (p.prototype = h.prototype, new p());
};
It seems like the issue might be related to the process of adding polyfills during transpilation.
It seems that this issue might be encountering a similar error. a situation where the prototype, which should be null, is instead becoming undefined.
TypeError: Class extends value undefined is not a constructor or null
I encountered the same error as described in this thread.
@sakamossan Have you successfully integrated zod-csv into your project?
Update from my side: Downgrade to v0.0.7 worked for me. So issue is still relevant for v0.0.8.
Hello. I encountered an issue when using version 0.0.8 where modules couldn't be loaded.
Error
When I downgraded to version 0.0.7, the import worked without any issues. There might be an issue with the generated umd.cjs file.
Environment
その他
Though seemingly unrelated, there were warnings and 429 errors during the build process of version 0.0.8.