https://discord.cloudflare.com logo
Join Discord
Powered by
# durable-objects
  • k

    Kevin W - Itty

    04/03/2021, 8:19 PM
    Yeah, I've been meaning to play w esbuild... just haven't found/made the time :p
  • k

    Kevin W - Itty

    04/03/2021, 8:19 PM
    it's 2021... we should be beyond all this crap, haha
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:19 PM
    I only just tried it out properly yesterday. I was very impressed though!
  • k

    Kevin W - Itty

    04/03/2021, 8:19 PM
    w Workers or...?
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:19 PM
    Yup.
  • k

    Kevin W - Itty

    04/03/2021, 8:21 PM
    any trick to get it working or can i find any old guide?
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:23 PM
    This has been tested for the
    service-worker
    type:
    esbuild src/index.ts --format=esm --bundle --outfile=dist/index.js
    . I think it'll pretty much just work with modules type as well.
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:25 PM
    There's a bunch of other settings you might want to enable (e.g.
    --minify
    and its variants), but the docs are pretty great: https://esbuild.github.io/api/#minify. And if you are using any plugins, it's pretty easy to create a small build script file à la:
    Copy code
    js
    const esbuild = require("esbuild");
    const alias = require("esbuild-plugin-alias");
    
    esbuild.build({
      entryPoints: ["src/index.ts"],
      bundle: true,
      format: "esm",
      define: { "process.env.NODE_ENV": '"production"' },
      outfile: "dist/index.js",
      plugins: [
        alias({
          fs: require.resolve("./null.js"),
          crypto: require.resolve("./null.js"),
          path: require.resolve("./null.js"),
        }),
      ],
    });
  • k

    Kevin W - Itty

    04/03/2021, 8:28 PM
    build works fine (thanks for the script)... still getting an error with
    --new-class
    flag...
  • k

    Kevin W - Itty

    04/03/2021, 8:28 PM
  • k

    Kevin W - Itty

    04/03/2021, 8:31 PM
    can confirm it's exporting from the built file:
  • k

    Kevin W - Itty

    04/03/2021, 8:31 PM
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:31 PM
    Should probably actually be
    --outfile=dist/index.mjs
    , and make sure that's what you've also got as
    "module": "./dist/index.mjs"
    in
    package.json
    .
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:31 PM
    That's promising, at least.
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:31 PM
    Rest of the file looks sensible?
  • k

    Kevin W - Itty

    04/03/2021, 8:33 PM
    well i've never looked at an esbuild output (looks diff from webpack output), but it def contains my code in there at least...
  • k

    Kevin W - Itty

    04/03/2021, 8:47 PM
    got it - just had to dig through the rollup template to find the missing pieces - thanks @User!
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:47 PM
    What was it that you needed?
  • k

    Kevin W - Itty

    04/03/2021, 8:48 PM
    in package.json
  • k

    Kevin W - Itty

    04/03/2021, 8:48 PM
    in wrangler.toml
  • k

    Kevin W - Itty

    04/03/2021, 8:49 PM
    then it still wouldn't work till i wiped the extraneous crap that had been generated into the dist folder (prev attempted builds)
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:49 PM
    Ah, great!
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:49 PM
    And good to know esbuild does work with Durable Objects.
  • k

    Kevin W - Itty

    04/03/2021, 8:49 PM
    yeah, zero issues
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:50 PM
    Will 💯% be my go-to from now on
  • k

    Kevin W - Itty

    04/03/2021, 8:50 PM
    and this is importing external libs (itty-router+extras), no prob
  • k

    Kevin W - Itty

    04/03/2021, 8:50 PM
    yeah for sure! build in ~25ms
  • g

    Greg Brimble | Cloudflare Pages

    04/03/2021, 8:50 PM
    Unbeatable lol
  • m

    matt

    04/03/2021, 8:58 PM
    May have to explore making an official esbuild template... that’s fast
  • w

    Webjocke

    04/03/2021, 9:05 PM
    Hi 😁 I did read on the forum that Workers are not allowed to call each other because "The vector could potentially generate a burst attack on a target by doing a chained fetch of workers, and in the last step, a targetted fetch.". But Durable Objects are able to call each other, is there a chance that this will be disables in the future? My use-case kinda needs Durable Objects to be able to communicate with each other 😬
1...414243...567Latest