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

    Isaac McFadyen | YYZ01

    03/13/2022, 10:57 PM
    One more thing you could try is
    wrangler pages dev --proxy=3000 -- npm run dev
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 10:57 PM
    Although I don't know if that will enable WebCrypto since it still uses SvelteKit's dev server.
  • b

    balage

    03/13/2022, 10:58 PM
    wrangler@beta you mean?
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 10:58 PM
    I'd use
    @alpha
    . But one sec, let me check one more thing.
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 10:59 PM
    Wait a second... I think my above command was missing something.
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 10:59 PM
    Try
    npx wrangler@alpha pages dev ./.svelte-kit/cloudflare
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 10:59 PM
    (with the
    .
    in front of
    svelte-kit
    there)
  • b

    balage

    03/13/2022, 11:02 PM
    this worked!
  • b

    balage

    03/13/2022, 11:02 PM
    works with @beta too
  • i

    Isaac McFadyen | YYZ01

    03/13/2022, 11:07 PM
    Great! 👍
  • b

    Bytesource

    03/14/2022, 8:46 AM
    import { Creds } from '../credentials';
    (credentials being located at functions/credentials.ts) works with locally with wrangler but fails on the server with
    [ERROR] Could not resolve "../_credentials"
    . Is importing
    ts
    files not supported?
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 1:35 PM
    Try adding an extension.
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 3:42 PM
    Anyone have any idea of whether bundling with Functions is supported in any way?
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 3:42 PM
    For example, via
    esbuild
    ?
  • j

    James

    03/14/2022, 4:00 PM
    I believe
    wrangler pages functions build
    uses esbuild under the hood - not sure if you mean manually building yourself or something though?
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 4:01 PM
    Yeah, mainly just cause I'm wondering if I can do my own aliases using something like
    esbuild-plugin-alias
    .
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 4:01 PM
    I don't necessarily need to control the build, just add that plugin somehow.
  • s

    simpson

    03/14/2022, 4:57 PM
    will there be any significant code changes needed when workers and pages become married as one?
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 5:20 PM
    Workers and Pages aren't going to come together; instead, there's a separate variant for Pages called Functions (similar concept, slightly different API + changes like file-system based routing).
  • i

    Isaac McFadyen | YYZ01

    03/14/2022, 5:20 PM
  • s

    simpson

    03/14/2022, 5:44 PM
    has anyone been able to use functions with Apollo to hydrate data to a static js client (like nextjs)? (is it even possible without node?) something like this: https://medium.com/@sppericat/how-to-setup-an-apollo-graphql-server-on-vercel-cc3f2dd72b3e
  • b

    Bytesource

    03/15/2022, 1:47 AM
    Unfortunately, adding the `.ts `file ending didn't work either:
    Copy code
    16:26:11.597    ✘ [ERROR] Could not resolve "../credentials.ts"
    16:26:11.597        ../../../buildhome/repo/functions/contact/index.ts:3:22:
    16:26:11.597          3 │ import { Creds } from '../credentials.ts';
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:02 AM
    Try a
    .js
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:03 AM
    Typescript is internally compiled to
    .js
    , so it's probably trying to import an non-existent file.
  • b

    Bytesource

    03/15/2022, 2:46 AM
    Importing
    credentials.js
    is indeed working. It's just that I wanted to use Typescript with all files. Do you know if importing `ts `files is possible with Cloudflare Functions?
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:47 AM
    Importing
    .js
    should work with typescript.
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:47 AM
    Basically Typescript compiles all files to
    .ts
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:47 AM
    So importing
    .ts
    doesn't work because after compilation there is no
    .ts
    files.
  • i

    Isaac McFadyen | YYZ01

    03/15/2022, 2:47 AM
    Typescript is runtime only, therefore you can never import
    .ts
    files (except if your bundler transforms it to a
    .js
    when building).
  • b

    Bytesource

    03/15/2022, 2:51 AM
    Yes, importing
    .js
    into a
    .ts
    file works. The problem is that when importing a
    .js
    file, this file's contents cannot be written in Typescript. Or am I missing something?
1...949596...392Latest