Skip to content

Fix issue with vercel compatibility #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2021

Conversation

kaaloo
Copy link
Contributor

@kaaloo kaaloo commented Feb 10, 2021

This PR refactors dynamic requires to simpler static ones to fix the following issue in vercel deployment:

2021-02-10T17:48:10.778Z	undefined	ERROR	Cannot find module './main/packages/Cosine'
Require stack:
- /var/task/node_modules/string-comparison/lib/index.js
- /var/task/node_modules/article-parser/src/utils/chooseBestUrl.js
- /var/task/node_modules/article-parser/src/utils/parseFromHtml.js
- /var/task/node_modules/article-parser/src/main.js
- /var/task/node_modules/article-parser/index.js
- /var/task/api/index.ts
- /var/task/___vc_launcher.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
2021-02-10T17:48:10.788Z	undefined	ERROR	Did you forget to add it to "dependencies" in `package.json`?
RequestId: ea2ddc67-287f-4183-a996-6794719a4207 Error: Runtime exited with error: exit status 1
Runtime.ExitError
Copy link
Owner

@Rabbitzzc Rabbitzzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with changing the code before?

@kaaloo
Copy link
Contributor Author

kaaloo commented Mar 1, 2021

Hi sorry to get back to you so late. Vercel uses ncc under the hood when packaging serverless functions for deployment. Unfortunately, this means dynamic requires like the ones in the current code fail because ncc relies on static analysis of requires.

@Rabbitzzc Rabbitzzc merged commit 2c7e400 into Rabbitzzc:master Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants