Open linonetwo opened 3 years ago
Sadly this breaks only in production and works fine locally. While I work on a fix, you can run this locally if that's a blocker.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
is this actually a wontfix
?
How can we help you debug this @ritz078 ?
is this actually a wontfix?
No. I fixed this locally but this breaks in production. I haven't been able to pinpoint the actual reason.
How can we help you debug this @ritz078 ?
This is mostly due to the unavailability of lib.d.ts is production env but I don't know why it isn't available.
I fixed this locally
@ritz078 do you mean a) you saw this failure locally, made a change that fixed it locally, but it's still broken in prod or b) things work locally but fail in production
because I can only do (b).
I also don't know what's unique about this route. Why isn't this failing for other (all?) routes?
I know this works locally but not on production. the package used for this conversion looks for lib.d.ts which it isn't able to find in production
I think the reason it is not working is because the API needs filesystem to work but vercel is serverless. The only solution I can think of right now is to either move transform to something like heroku or just move this particular API to heroku.
I am thinking of doing the latter.
Is that server close source or written in other language? Will it be possible to run in frontend? If it requires nodejs, there are some virtual fs that can run in the browser.
https://github.com/ritz078/transform/blob/master/pages/api/typescript-to-json-schema.ts is the API code that is deployed on vercel as a serverless function. The client-side uses this API. As you can see it does filesystem operation which doesn't work when deployed as a lambda and works locally since it has access to the filesystem.
We can create a separate directory that has a server that gets deployed to Heroku. transform.tools can use those APIs from there.
Will it be possible to run in frontend? If it requires nodejs, there are some virtual fs that can run in the browser.
Yes, it should be possible but it will be too much work as we will have to run both the typescript compiler and the converter on the browser. Both do not support this by default. Also, that will be a lot of JS on the browser-side making the page load slow.
Typescript should stay on devDependencies in package.json
https://github.com/vercel/pkg/issues/572#issuecomment-440978846
may be it works
Bump
@ShivnathGupta That didn't work https://github.com/ritz078/transform/pull/329
Can you try some vitrual fs to run this package? https://github.com/vfile/vfile#vfiletostringencoding this ecosystem has many packages.
JSON.parse: unexpected character at line 1 column 1 of the JSON data
https://transform.tools/typescript-to-json-schema