Skip to content

wrangler dev #1

@threepointone

Description

@threepointone

This is the parent issue tracking the implementation of wrangler dev.

Usage

In it's simplest form, you can write a worker, say at index.js, and run: wrangler dev index.js, and -

  • it'll immediately start up a local server at http://localhost:8787/
  • in "watch" mode on by default
  • You'll also see a bar in your terminal with hotkeys for some added functionality-
    • B to open a browser
    • D to open devtools (relevant issue: TODO)
    • S to start a tunnel to the internet, and copies a url to your clipboard that you can share with anyone (relevant issue: TODO)
    • X (or Q) to quit
  • You'll note that you do NOT have to specify an account id. wrangler dev will infer your account id automatically (unless you provide it in your wrangler.toml or via CF_ACCOUNT_ID)
  • Notably, we aim to provide a default experience that's immediately useful, so you shouldn't have to setup a bundler/compiler for most usecases. So, you can use modules from npm, create separate modules, use react (todo: --jsx <reference> for other libraries), use typescript, and it should all Just Work.
    • This is currently powered by esbuild, but we may/may not change that in the future. We're not planning on exposing all the configuration options, or even the plugin interface yet. We have ideas for how we'll do this, and will share details when we have some clarity.
      • A notable miss is being able to 'polyfill' node's builtins (like crypto, path, etc) to provide compatibility with a number of libraries in the ecosystem. We'll do this soon (and perhaps for Deno libs as well?)
      • Similarly, we should probably also enable http imports for module.
    • That said, you're not blocked on setting up your own build pipeline, you can indeed use any tools you like (like, webpack, parcel, etc), and point wrangler to the output as an entry point. We'll document this properly soon.
    • We'd like to move away from custom build configuration, instead passing it directly in the cli, so you should be able to do, for example wrangler dev script.js -- webpack --watch (and similarly for publish) Custom builds implemented in implement custom builds, for dev and publish #149
  • wrangler dev will automatically infer whether you're using the service-worker format or the newer ES modules format.
  • This doesn't currently support wasm, workers-rs well, and we'll fix that soon. Done.
  • And finally, we haven't implemented all the other flags for dev yet. --port works, but we have yet to do --ip, --host, --local-protocol, --upstream-protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions