chargebee / chargebee-typescript

Typescript library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=typescript
MIT License
23 stars 15 forks source link

Typescript issue with webpack < 5 #35

Closed saurabhjdsingh closed 7 months ago

saurabhjdsingh commented 1 year ago

I have installed chargebee-typescript in my angular 14 app using npm install chargebee-typescript@">=2"

Then imported the library as: import {ChargeBee} from 'chargebee-typescript'; var chargebee = new ChargeBee();

Now I see this error =>

Screenshot 2022-12-11 at 11 11 35 PM
mariusgnicula commented 1 year ago

Hey @saurabhjdsingh ! I had the same issue, you need to install those packages first. I did it with Yarn, npm install stream-http --save-dev npm install https-browserify --save-dev npm install os-browserify --save-dev Then you can add those to your webpack config file, like so: resolve: { fallback: { http: require.resolve("stream-http"), https: require.resolve("https-browserify"), os: require.resolve("os-browserify/browser"), } } For me that fixed my issue. Hope this helps!

cb-bharathvaj commented 1 year ago

@mariusgnicula @saurabhjdsingh Would like to know your use case more. Are you looking at using this package in browser ?

jalexw commented 1 year ago

I would imagine these errors would pop up when using a Next.js Edge Runtime to host with edge functions on Vercel (way more performant than Node.js; there are virtually no cold start times). However, only certain Web APIs are supported instead of the full set of Node.js APIs...

bdueck-oftr commented 11 months ago

Same issue here and as @jalexw surmised, I'm encountering the same error when trying to use Chargebee TS lib on Vercel edge functions. Fails on these lines in Core.js as these modules are not supported in Vercel edge.

Core.http = require('http');
Core.https = require('https');
Core.os = require('os');
cb-sriramthiagarajan commented 7 months ago

Hello folks, this SDK is currently not supported in Edge runtimes. This is also not supported in browsers. Like mentioned in https://github.com/chargebee/chargebee-typescript/issues/50#issuecomment-2020376820, we're planning to make this Edge runtime compatible but we don't have any timelines yet.

I'm closing this issue for now and request you all to keep track of the Edge runtime compatibility in #50. Thanks.

JanThiel commented 6 months ago

Just FYI, we have a fully Edge compatible Fork of the chargebee api client: https://github.com/Hive-IT-GmbH/chargebee-node We use it on Vercel and Cloudflare Pages.

Please note: We do not offer any kind of support. The fork is ment "as it is" and might push Chargebee to officially move on as the changes are minimal when using a modern NodeJS runtime ;-)

cb-sriramthiagarajan commented 6 months ago

Thanks for the note @JanThiel. Good to see this :)

And yeah, we're starting with this soon ;-)

cb-sriramthiagarajan commented 3 months ago

Hi @bdueck-oftr @jalexw @mariusgnicula, we have repleased a new beta version that supports different run times like Workers, Deno, Bun etc. It'd be great if you could give it a try and share your feedback.

You can install this using npm install chargebee@beta

Edit: We have a Migration guide for v3. README in the next branch also has more info on the usage.