https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • w

    Walshy | Pages

    01/03/2022, 3:00 PM
    That project was made when functions were still in early beta, the
    worker
    folder is where the function code is
  • m

    maximillian

    01/03/2022, 3:01 PM
    Hmm, wrangler is still complaining about missing node dependencies though
  • w

    Walshy | Pages

    01/03/2022, 3:02 PM
    what's the error you're getting?
  • m

    maximillian

    01/03/2022, 3:15 PM
    The package "events" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
  • m

    maximillian

    01/03/2022, 3:15 PM
    (And the same for
    crypto
    ,
    http
    and several other node packages)
  • s

    SirJosh

    01/03/2022, 3:23 PM
    bumping this, not being able to have my pages project compile is a huge bummer since i can't debug what the issue is, hopefully nobody will mind if i ping someone to hopefully escalate it up to a dev to help fix whatever the internal issue is @User pinging you since you talked recently (hopefully you don't mind/aren't busy)
  • s

    SirJosh

    01/03/2022, 3:29 PM
    oh wait i replied to the wrong message of mine
  • m

    maximillian

    01/03/2022, 3:47 PM
    Are you sure this is supposed to work? I've found an issue on Github referencing the same issue: https://github.com/stripe/stripe-node/issues/997#issuecomment-989179016
  • m

    maximillian

    01/03/2022, 3:47 PM
    However, the announcement article explicitly mentions
    functions
    ...
  • m

    maximillian

    01/03/2022, 4:11 PM
    Hey, did you get this to work? I'm hitting the same issues
  • m

    maximillian

    01/03/2022, 4:22 PM
    I saw you refactored your code to not use the Stripe SDK at all, but instead use Stripes API directly.
  • h

    HardAtWork

    01/03/2022, 5:31 PM
    A _worker.JS file basically bypasses the normal Functions build flow, and deploys it like a normal Worker.
  • m

    maximillian

    01/03/2022, 6:06 PM
    Hmm okay might see if I can use this. Can I use normal workers side by side with functions?
  • m

    maximillian

    01/03/2022, 6:06 PM
    Or will having a worker present disable functions?
    Copy code
    When using a _worker.js file, the entire /functions directory is ignored – this includes its routing and middleware characteristics. Instead, the _worker.js file is deployed as is and must be written using the Module Worker syntax
  • m

    maximillian

    01/03/2022, 6:07 PM
    It's a bit unclear if this applies only to the code inside _worker.js (makes sense) or to everything inside the functions directory (not good)
  • h

    HardAtWork

    01/03/2022, 6:18 PM
    The way I understand it is that it goes in the root of the output directory, and it disables anything present in the functions directory.
  • m

    maximillian

    01/03/2022, 6:26 PM
    Thanks, that's unfortunately a deal breaker :/
  • w

    Walshy | Pages

    01/03/2022, 6:28 PM
    You'd replace the functions dir with your own build flow
  • w

    Walshy | Pages

    01/03/2022, 6:28 PM
    which is what you want no?
  • w

    Walshy | Pages

    01/03/2022, 6:28 PM
    You can still have a directory where all your source is (like a functions folder). Then bundle it up with esbuild and output as _worker.js
  • m

    maximillian

    01/03/2022, 6:32 PM
    For Stripe, yes. But I have a bunch of other code as well that works fine with
    /functions
    . I've tried to avoid touching normal workers so far because I don't really know how to use them and I'm completely new to the Cloudflare ecosystem as it is :/
  • m

    maximillian

    01/03/2022, 6:32 PM
    Functions seems so neat, Workers… less so.
  • m

    maximillian

    01/03/2022, 6:32 PM
    But perhaps it's easier than it sounds
  • w

    Walshy | Pages

    01/03/2022, 6:32 PM
    They're both the same pretty much :p
  • w

    Walshy | Pages

    01/03/2022, 6:32 PM
    functions are actually Workers just bundled nicely with Pages
  • w

    Walshy | Pages

    01/03/2022, 6:33 PM
    But yeah makes sense, I should really make a Stripe function for Pages then I could setup an example repo. I still haven't used Stripe's SDK in Workers yet
  • m

    maximillian

    01/03/2022, 6:45 PM
    Hmm, I found this Youtube video where they use
    stripe-node
    with deno (which is also fetch based)
  • m

    maximillian

    01/03/2022, 6:45 PM

    https://youtu.be/epCHqHEdz8I?t=170▾

  • m

    maximillian

    01/03/2022, 6:46 PM
    In the video he fetches the stripe sdk from a CDN using query params:
    http://esm.sh/stripe?target=deno
  • m

    maximillian

    01/03/2022, 6:56 PM
    But no luck 😦
1...525354...392Latest