Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cloudflare/workers-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: miniflare@3.20240129.2
Choose a base ref
...
head repository: cloudflare/workers-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: miniflare@3.20240129.3
Choose a head ref

Commits on Feb 13, 2024

  1. C3: Nuxt template dev improvements (#4996)

    * C3: Update dev bindings support in nuxt template
    
    * Add initial wrangler.toml for pages frameworks with getBindingsProxy
    
    * Changeset
    
    * Use hello-world wrangler.toml template for qwik and nuxt
    
    * Increase wait time in framework e2e to combat verifyDevScript flakiness
    
    * Fixup changesets
    
    * Wait for dev server a little longer. And fix changeset
    
    * Attempt to resolve verifyDev flakiness
    
    * Skip nuxt e2e on win32
    jculvey authored Feb 13, 2024
    Copy the full SHA
    246512c View commit details
  2. C3: next templates refactoring (#4999)

    * add variant selection to c3 templates' `copyFiles`
    
    * add possibility to edit destination dir for c3's `copyFiles`
    
    * C3: refactor Next.js template code
    
    Align the Next.js template code with the rest of the
    C3 templates by removing its `templates.ts` file and
    including templates files directly in the next template
    directory
    
    * add new copyFile utility
    
    * fix: make sure not to wrongly ask users if they want to use typescript
    dario-piotrowicz authored Feb 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ce6d4bc View commit details
  3. Use partitioned cookies (#5004)

    * Improve local development
    
    * Enable partitioned cookies & allow development from localhost
    
    * Hide Preview tab when using Safari
    
    * Improve HTTP tab spacing
    
    * Update tests
    
    * Adapt to new Vitest version
    penalosa authored Feb 13, 2024
    Copy the full SHA
    b9b34ce View commit details

Commits on Feb 14, 2024

  1. [C3] bump create-qwik from 1.4.4 to 1.4.5 in /packages/create-cloudfl…

    …are/src/frameworks (#5011)
    
    * [C3] bump create-qwik in /packages/create-cloudflare/src/frameworks
    
    Bumps [create-qwik](https://github.com/BuilderIO/qwik/tree/HEAD/packages/create-qwik) from 1.4.4 to 1.4.5.
    - [Release notes](https://github.com/BuilderIO/qwik/releases)
    - [Commits](https://github.com/BuilderIO/qwik/commits/v1.4.5/packages/create-qwik)
    
    ---
    updated-dependencies:
    - dependency-name: create-qwik
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 14, 2024
    Copy the full SHA
    89482d4 View commit details
  2. Copy the full SHA
    7723ac1 View commit details
  3. Copy the full SHA
    9f78704 View commit details
  4. Add feature to use environment variable for Hyperdrive local dev conn…

    …ection string (#4900)
    
    * hyperdrive: support HYPERDRIVE_LOCAL_CONNECTION_STRING
    
    * hyperdrive: add changeset
    
    * Fix build issues and add tests
    
    * Use binding name in hyperdrive local string environment variable
    
    * Fix changeset, use simpler method for grabbing environment variable
    
    ---------
    
    Co-authored-by: Matt Silverlock <matt@eatsleeprepeat.net>
    mtlemilio and elithrar authored Feb 14, 2024
    Copy the full SHA
    3389f2e View commit details

Commits on Feb 15, 2024

  1. C3: Update Next.js template (to use the latest tooling from next-on-p…

    …ages) (#5009)
    
    * add `wrangler.toml` template
    
    * update `next.config.mjs` file (instead of completely overriding it)
    
    * update `README.md` template
    
    * update `env.d.ts` template
    
    * update api hello route templates
    
    * update Next.js template scripts
    dario-piotrowicz authored Feb 15, 2024
    Copy the full SHA
    1e26369 View commit details
  2. [C3] bump create-astro from 4.7.2 to 4.7.3 in /packages/create-cloudf…

    …lare/src/frameworks (#5021)
    
    * [C3] bump create-astro in /packages/create-cloudflare/src/frameworks
    
    Bumps [create-astro](https://github.com/withastro/astro/tree/HEAD/packages/create-astro) from 4.7.2 to 4.7.3.
    - [Release notes](https://github.com/withastro/astro/releases)
    - [Changelog](https://github.com/withastro/astro/blob/main/packages/create-astro/CHANGELOG.md)
    - [Commits](https://github.com/withastro/astro/commits/create-astro@4.7.3/packages/create-astro)
    
    ---
    updated-dependencies:
    - dependency-name: create-astro
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 15, 2024
    Copy the full SHA
    ae1ef47 View commit details
  3. [C3] bump nuxi from 3.10.0 to 3.10.1 in /packages/create-cloudflare/s…

    …rc/frameworks (#5020)
    
    * [C3] bump nuxi in /packages/create-cloudflare/src/frameworks
    
    Bumps [nuxi](https://github.com/nuxt/cli) from 3.10.0 to 3.10.1.
    - [Release notes](https://github.com/nuxt/cli/releases)
    - [Changelog](https://github.com/nuxt/cli/blob/main/CHANGELOG.md)
    - [Commits](nuxt/cli@v3.10.0...v3.10.1)
    
    ---
    updated-dependencies:
    - dependency-name: nuxi
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 15, 2024
    Copy the full SHA
    0e74c74 View commit details
  4. Fix changeset typo (#5025)

    1000hz authored Feb 15, 2024
    Copy the full SHA
    ce23ed7 View commit details

Commits on Feb 16, 2024

  1. [C3] Improve bindings support in Svelte template (#5027)

    * Improve bindings support in svelte template
    
    * Improve parsing of tsconfig when updating types entrypoint
    
    * Improve docstring
    
    * Change svelte copyFiles definition to new format
    
    * Fix formatting issues
    
    * Add changeset
    
    * Fixing svelte verifyBuild tests
    
    * Addressing PR feedback
    
    * Fix build-cf-types task for win32
    jculvey authored Feb 16, 2024
    Copy the full SHA
    a751489 View commit details
  2. fix e2e test failures (#5022)

    * test: ensure that standard pricing warning is removed from normalized output in e2e tests
    
    This normalization relied upon the ACCOUNT ID being a specific value, which is not always valid.
    
    * fix: ensure that Hyperdrive in local dev can use the localConnectionString
    
    Previously if there was no appropriate env var, then Wrangler would exit with an error.
    
    This is checked by the Wrangler e2e tests, which were failing previously - so no need to add additional tests.
    
    * fixup! test: ensure that standard pricing warning is removed from normalized output in e2e tests
    petebacondarwin authored Feb 16, 2024
    Copy the full SHA
    2aaeab8 View commit details
  3. [C3] bump @angular/create from 17.1.3 to 17.2.0 in /packages/create-c…

    …loudflare/src/frameworks (#5019)
    
    * [C3] bump @angular/create in /packages/create-cloudflare/src/frameworks
    
    Bumps [@angular/create](https://github.com/angular/angular-cli) from 17.1.3 to 17.2.0.
    - [Release notes](https://github.com/angular/angular-cli/releases)
    - [Changelog](https://github.com/angular/angular-cli/blob/main/CHANGELOG.md)
    - [Commits](angular/angular-cli@17.1.3...17.2.0)
    
    ---
    updated-dependencies:
    - dependency-name: "@angular/create"
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 16, 2024
    Copy the full SHA
    f939ed7 View commit details
  4. [C3] bump create-hono from 0.3.2 to 0.4.0 in /packages/create-cloudfl…

    …are/src/frameworks (#5001)
    
    * [C3] bump create-hono in /packages/create-cloudflare/src/frameworks
    
    Bumps [create-hono](https://github.com/honojs/create-hono) from 0.3.2 to 0.4.0.
    - [Release notes](https://github.com/honojs/create-hono/releases)
    - [Commits](honojs/create-hono@v0.3.2...v0.4.0)
    
    ---
    updated-dependencies:
    - dependency-name: create-hono
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 16, 2024
    Copy the full SHA
    efe8b44 View commit details
  5. Improve getPlatformProxy's (no-op) caches (#5026)

    * [wrangler] fix: make sure `getPlatformProxy` produces a production-like `caches` object
    
    * [wrangler] fix: relax the `getPlatformProxy`'s' cache request/response types
    dario-piotrowicz authored Feb 16, 2024
    Copy the full SHA
    0458472 View commit details
  6. chore: add turbo.json to kv-asset-handler (#5031)

    * chore: add `turbo.json` to `kv-asset-handler`
    
    * ci: move `ensure-turbo-build-output` to root `check` script
    mrbbot authored Feb 16, 2024
    Copy the full SHA
    b58d9bc View commit details
  7. fix: don't suggest reporting UserErrors to GitHub (#5030)

    mrbbot authored Feb 16, 2024
    Copy the full SHA
    55ea072 View commit details
  8. fix: fixup E2E test snapshots now that user errors don't prompt GitHub (

    mrbbot authored Feb 16, 2024
    Copy the full SHA
    d1bcaaf View commit details
  9. Add warning for explicit usage model after bundled/unbound deprecation (

    #5023)
    
    Co-authored-by: Zeb Piasecki <zeb@cloudflare.com>
    zebp and zebp authored Feb 16, 2024
    Copy the full SHA
    397c3ae View commit details
  10. fix(startApiDev): pass accountId to startDevServer (#3109)

    * fix(startApiDev): pass `accountId` to `startDevServer`
    
    * Update dev.tsx
    
    * fix syntax precedence
    
    ---------
    
    Co-authored-by: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com>
    SimonDegraeve and RamIdeas authored Feb 16, 2024
    Copy the full SHA
    ed4bf22 View commit details
  11. feat: Custom https cert (#4475)

    * feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    * fixup! feat: add flags to provide custom https cert
    
    ---------
    
    Co-authored-by: Peter Bacon Darwin <pbacondarwin@cloudflare.com>
    paulrostorp and petebacondarwin authored Feb 16, 2024
    Copy the full SHA
    86d94ff View commit details
  12. Implement Vitest testing environment for Miniflare 3 (#4795)

    * [miniflare] Add support for module fallback service
    
    Adds a `unsafeUseModuleFallbackService` worker option and a
    `unsafeModuleFallbackService` shared option for using `workerd`'s
    module fallback service. Note `workerd` only accepts an address for
    fallback service configuration. This means if we wanted per-worker
    fallback service configuration, we'd need to start a new HTTP server
    for each worker that enabled it. To avoid starting additional servers,
    we reuse Miniflare's existing loopback server, and allow each worker
    to enable/disable the fallback service instead.
    
    * [miniflare] Return `Response` from `fetch()` if socket upgrade failed
    
    Previously, Miniflare would throw an error if the `Upgrade: websocket`
    header was set, but a non-WebSocket response was returned. This change
    ensures the response is returned, just without `webSocket` set. This
    allows the caller to handle the error case/response themselves.
    
    * MVP for `@cloudflare/vitest-pool-workers`
    
    Implements a basic Vitest pool that runs tests inside `workerd`,
    using the module fallback service and a test runner Durable Object.
    Provides access to bindings via `env` from the `cloudflare:test`
    module.
    
    Closes DEVX-1052 and DEVX-1053
    
    * Implement workspace/test file worker isolation
    
    Adds a `singleWorker` option for running all a project's test files
    serially in the same worker. This can speed up execution if the
    project contains lots of small test files, as Vitest only needs to
    be initialised once.
    
    * Add Durable Object test helpers and support for self-service bindings
    
    Adds a `runInDurableObject()` test helper for running arbitrary code
    inside a Durable Object's I/O context, and a `runDurableObjectAlarm()`
    helper for running a Durable Object's scheduled alarms.
    
    These require the new `main` option to be set to the worker's
    entrypoint, so the Vitest pool can create instances of the user's
    Durable Objects.
    
    The `main` option also allows service bindings to be declared to the
    worker running the tests. Events dispatched to these service bindings
    will use the handler exported by the `main` worker.
    
    Closes DEVX-1056, DEVX-1057 and DEVX-1058
    
    * Add support for fetch mocking with `undici` `MockAgent`
    
    Adds `fetchMock` to the `cloudflare:test` module. This is an instance
    of `undici`'s `MockAgent`, and can be used to mock global `fetch()`
    requests in the test worker. This works by bundling just the `undici`
    `MockAgent` code, with a customisable `Dispatcher` that is set to the
    original workers `fetch()` function in the pool.
    
    Closes DEVX-1059
    
    * Use custom test runner and reset fetch mock at the start of each file
    
    A custom test runner allows us to hook into test execution.
    Specifically, this allows us to run code before and after
    files/suites/tests are executed. We'll need this for isolated storage.
    
    * Add (inline) snapshot support and fix source maps
    
    By default, Vitest uses the `node:fs` module for reading/writing
    snapshots. This isn't available in workers, so this change implements
    a custom snapshot client using service bindings.
    
    Closes DEVX-1054
    
    * Fix logs not showing on re-runs
    
    * [miniflare] Export `formatZodError`
    
    We'd like to use Zod for validating the pool's options. Miniflare has
    a `formatZodError` function that makes pretty error messages from Zod
    validation errors.
    
    * Validate pool options with Zod and pretty error formatting
    
    * Bump to stable `vitest@1.0.1`
    
    * Add support for serialising any structured serialisable
    
    * Add support for fake timers
    
    * Verify module mocking and spies work
    
    * [miniflare] Add support for "sticky blobs" that aren't deleted
    
    For isolated per-test storage, we'll be pushing/popping databases
    to a "stack". After pushing a database stack frame, we may delete a
    record in a test. We'd like to avoid deleting the associated blob here
    so when we pop the frame, the record still links up with it.
    
    This change adds an `unsafeStickyBlobs` option that disables garbage
    blob cleanup if enabled.
    
    * [miniflare] Add support for getting persistence paths
    
    Isolated storage will need access to SQLite database files. This
    change adds a `unsafeGetPersistPaths()` function for getting the
    persistence paths used by a `Miniflare` instance. This is unsafe as
    the layout of persistence directories is not a public interface.
    
    * [miniflare] Add support for colo-local ephemeral "Durable" Objects
    
    For isolated storage, we'd like the runner object not to persist any
    state to disk, so we don't have to worry about excluding it when
    managing the storage stack. We currently have an
    `unsafeEphemeralDurableObjects` option that makes _all_ Durable
    Objects in a worker use in-memory state. This isn't suitable for our
    Vitest pool, as user objects will run in the same worker as the runner
    object.
    
    This change adds support for `workerd` "colo-local" actors. These are
    like Durable Objects, but don't provide any durable storage (i.e. no
    `state.storage` API), and have a slightly different namespace binding
    API.
    
    * [miniflare] Bind `this` to `Miniflare` instance in custom services
    
    We'd like to extend our Vitest pool's custom loopback service with
    endpoints for managing isolated storage stacks. To do this, we need to
    know the persistence paths of the `Miniflare` instance we're currently
    running in. A previous commit added an `unsafeGetPersistPaths()`
    function. If we wanted to access these paths in the pool's loopback
    service, we'd need to capture the paths/`Miniflare` instance in a
    closure used as the service binding function. Unfortunately, we use
    `util.deepStrictEqual()` on Miniflare options to determine if we
    should restart the `Miniflare` instance. This would always return
    `true` if we created a new bound/arrow function on each test run.
    
    This change binds `this` to the current `Miniflare` instance when
    calling custom service functions, meaning we can reuse the same
    function when building options.
    
    * Add support for isolated storage
    
    This change adds an `isolatedStorage` pool option. If enabled, each
    test gets its own isolated storage environment. Storage writes in a
    test are automatically undone at the end of the test. The storage
    environment is copied from the parent suite, ensuring writes from
    `beforeAll()`s show up in tests.
    
    This is implemented with an on-disk stack of `.sqlite` files. Before
    a suite/test attempt begins, the current storage state is "pushed".
    When the suite/test attempt completes/fails, the state is "popped",
    undoing all changes. Sticky blobs are used to ensure deleting records
    in a test keeps the corresponding blobs around, so they can be used
    when the state is "popped".
    
    Closes DEVX-1055
    
    * [miniflare] Use `z.input()` for user facing options types
    
    Previously, we were using `z.infer()` on our option schemas to derive
    `WorkerOptions` and `SharedOptions` types. This gave the _output_
    types for schemas, rather than the user _input_ types. Usually, these
    were the same. However, if a schema was `.transform()`ed, they could
    be different. Notably, `hyperdrives` values output objects, but accept
    strings, leading to type errors if these were used.
    
    * Add `defineWorkersPoolOptions()` for typed pool options in config
    
    * [miniflare] Easy service bindings to self
    
    * Use Miniflare's mechanism for self-service bindings
    
    * Tidy up Node and package polyfills
    
    Tries to remove unnecessary polyfills/functions, so users are less
    likely to import APIs that would be unsupported in production in their
    tests.
    
    * Throw actual unhandled errors in pool on failed test runs
    
    Tunnels through the error thrown when running tests fails. This is
    useful for debugging, as it means the startup error thrown by Vitest
    includes a useful message and stack.
    
    * Add argument validation to `cloudflare:test` Durable Object helpers
    
    While we expect most users to write their tests in TypeScript,
    JavaScript tests are also supported. Since we can't guarantee correct
    types at runtime, this change adds type validation to test helpers,
    throwing errors in the same JSG-style as other `workerd` APIs.
    
    * [miniflare] Add support for `rootPath`s
    
    Previously, Miniflare would always resolve path-valued options
    relative to the current working directory. For the Vitest pool, we'd
    like to be able to resolve these relative to the project config file.
    
    This change adds back Miniflare 2's `rootPath` option for controlling
    the resolution directory. `rootPath` can be set as a shared or
    per-worker option. Path-valued options resolve relative to the closest
    `rootPath`.
    
    * [miniflare] Fix linting scripts
    
    * Resolve pool Miniflare options relative to `vitest.config.ts`
    
    ...rather than the current working directory. This ensures paths are
    always resolved to the same location when `vitest` is run in different
    directories.
    
    * Support injecting provided values in pool options
    
    Vitest global setup hooks provide a good place to start auxiliary
    servers required by tests (e.g. upstream). This change allows provided
    values to be injected into the Miniflare config (e.g. using port from
    global setup in hyperdrive local connection string).
    
    * Support seeding data in config and reset storage between runs
    
    This change adds a `setupEnvironment(env)` function called with a
    bindings proxy per-`Miniflare`-instance per-test-run. This should be
    used for seeding data from disk (e.g. applying D1 migrations).
    
    * [miniflare] Fix `DurableObjectStub` detection
    
    Enabling Durable Object JS RPC changes the class name of
    `DurableObjectStub` from `DurableObject` to `WorkerRpc`. This was
    breaking `Fetcher#fetch()` detection and WebSocket-upgrading
    `DurableObjectStub#fetch()`es when using the magic proxy.
    
    * Bump to `vitest@1.1.3`
    
    * Support calling `fetch`/`scheduled`/`queue` handlers directly
    
    This change adds some new test helpers useful when importing Worker
    source code and calling handlers directly. Namely...
    
    - `createExecutionContext()` for creating an `ExecutionContext`
    - `getWaitUntil()` for waiting for all `ctx.waitUntil()` callbacks
    - `createScheduledController()` for creating a `scheduled` handler's
      `ScheduledController`
    - `getScheduledResult()` for getting the "no-retry" state of a
      `ScheduledController`
    - `createMessageBatch()` for creating a `queue` handler's
      `MessageBatch`
    - `getQueueResult()` for getting ack/retry state of a `MessageBatch`
    
    Note `createScheduledController()`/`getScheduledResult()` and
    `createMessageBatch()`/`getQueueResult()` take/return the same types
    as `Fetcher#scheduled()` and `Fetcher#queue()` respectively.
    
    Closes DEVX-1060
    
    * Block custom environments
    
    Our Vitest pool runs tests inside `workerd` itself. This means we
    don't need to use Vitest's custom environment feature to setup the
    correct global scope. Modifying the global scope would result in some
    franken-`workerd`-environment that didn't match production.
    
    With Miniflare 2's `vitest-environment-miniflare`, we _did_ require
    users to enable a custom environment. Considering this is a
    significant difference, this change adds a very helpful error message
    if we detect a custom `environment` is configured.
    
    * Assert compatible Vitest version on startup
    
    Our Vitest pool currently depends on internal Vitest APIs that are not
    protected by semantic-versioning guarantees. Therefore, this change
    adds a runtime sanity check for a peer-dependency version constraint
    on `vitest`.
    
    * Fix fallback service on Windows
    
    * [miniflare] Update API docs for unsupported products
    
    * Integrate `vitest-pool-workers` with monorepo tooling
    
    * Only include `dist` directory when publishing
    
    * [pre] Move `CloudflareTestEnv` to `cloudflare:test` `ProvidedEnv`
    
    * [pre] Use correct project path for non-workspace projects
    
    `WorkspaceProject#path` was actually giving the path to the directory
    containing the Vitest config, not the config file itself, for
    non-workspace projects.
    
    * [pre] Manually construct `__dirname`s
    
    `vite-node` was transforming the pool files during development, but
    externalising them when the pool was depended on externally. When
    Vite transforms files, it automatically injects `__dirname`, even
    though these are ES modules, which shouldn't have this by default.
    
    * [pre] Construct serialised `poolOptions` to prevent serialising symbol
    
    * [pre] Include `cloudflare:test` types in package
    
    These can be referenced by adding `@cloudflare/vitest-pool-workers` to
    the `types` array in `tsconfig.json`.
    
    * Fixup comments: move method comments to JSDocs & add additional docs
    
    * fixup! [miniflare] Add support for `rootPath`s
    
    * Allow pool restarts on config change
    
    Vitest will dispose of the pool and recreate it when the Vitest config
    changes. This was causing `Miniflare` instances to be disposed, then
    reused when the pool was recreated. This change moves the project
    cache from the module-level to a "pool-level" local variable.
    
    * Get builtin module list and `ExportedHandler` keys from RTTI
    
    * fixup! Add support for fetch mocking with `undici` `MockAgent`
    
    Our mock agent implementation depends on `undici` internals. This
    change ensures we pin our version, so we don't accidentally upgrade
    to an incompatible version.
    
    * fixup! [miniflare] Bind `this` to `Miniflare` instance in custom services
    
    Switch to passing `Miniflare` instance as parameter instead of `this`
    
    * Use the same `esbuild` version as `wrangler`
    
    * Use `node:path/posix` for posix path helpers in module fallback
    
    * fixup! Fix fallback service on Windows
    
    * Check all parents in `"type": "module"` cache before reading files
    
    * fixup! Support seeding data in config and reset storage between runs
    
    Rename abort-all helper worker
    
    * Remove unnecessary `if` statement in fallback service
    
    * fixup! Tidy up Node and package polyfills
    
    Update not-implemented messages
    
    * Remove unnecessarily complex `groupBy()`
    
    * Add back support for listing Durable Objects in a namespace
    
    Adds a `listDurableObjectIds()` test helper that behaves similarly to
    `getMiniflareDurableObjectIds()` from Miniflare 2's test environments.
    
    * [miniflare] Allow `URL`s to be passed in `hyperdrives` option
    
    Importantly, this change makes the Zod output type of `hyperdrives`
    assignable to the input type. This means we can pass the output of
    parsing options schemas back to the `new Miniflare()` constructor.
    Also adds a few more `hyperdrives` tests to verify this doesn't change
    behaviour.
    
    * Remove `setupEnvironment()` in favor of services to access file-system
    
    * Add `SELF` export to `cloudflare:test` module
    
    Exposing `kCurrentWorker` to users for integration testing wasn't very
    nice. This is a common use case so this change ensures it's always
    bound and adds it directly to the `cloudflare:test` module.
    
    * Replace `getWaitUntil` with `waitOnExecutionContext` and `void` return
    
    This function aims to allow users to wait on side-effecting
    `waitUntil`s, then assert on their effects. `workerd` ignores the
    resolved value of `Promise`s, so exposing these may make it trickier
    to change the implementation of this function in the future.
    
    * Remove redundant `isolateDurableObjectBindings` serialised option
    
    `durableObjectBindingDesignators` includes the same and more
    information, so there's no need to pass this.
    
    * Fail if required compatibility flags aren't set
    
    This makes it explicit which flags we're enabling, and helps avoid
    behaviour differences when running `wrangler dev` or deployed code.
    
    * Rename `WorkersProjectOptions` to `WorkersPoolOptions`
    
    * fixup! Add support for isolated storage
    
    Clarify `StackedStorageState` is per `Miniflare`-instance
    
    * fixup! Add `SELF` export to `cloudflare:test` module
    
    Update docs in `config.ts`
    
    * Format with monorepo's `prettier` version
    mrbbot authored Feb 16, 2024
    Copy the full SHA
    027f971 View commit details
  13. fix: wait for actual port before opening browser with --port=0 (#5033)

    * fix: wait for actual port before opening browser with `--port=0`
    
    * fix: don't allow multiple browser opens when waiting for port
    mrbbot authored Feb 16, 2024
    Copy the full SHA
    b1ace91 View commit details
  14. Version Packages (#5006)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    workers-devprod and github-actions[bot] authored Feb 16, 2024
    Copy the full SHA
    fd0fb23 View commit details
Showing with 10,044 additions and 1,014 deletions.
  1. +4 −0 .prettierignore
  2. +1 −1 fixtures/dev-env/package.json
  3. +38 −0 fixtures/get-platform-proxy/tests/get-platform-proxy.caches.test.ts
  4. +3 −3 package.json
  5. +44 −0 packages/create-cloudflare/CHANGELOG.md
  6. +8 −0 packages/create-cloudflare/e2e-tests/fixtures/nuxt/server/routes/test.ts
  7. +2 −0 packages/create-cloudflare/e2e-tests/fixtures/nuxt/wrangler.toml
  8. +1 −1 packages/create-cloudflare/e2e-tests/fixtures/qwik/src/routes/test/index.ts
  9. +9 −0 packages/create-cloudflare/e2e-tests/fixtures/svelte/src/routes/test/+server.ts
  10. +2 −0 packages/create-cloudflare/e2e-tests/fixtures/svelte/wrangler.toml
  11. +27 −3 packages/create-cloudflare/e2e-tests/frameworks.test.ts
  12. +2 −2 packages/create-cloudflare/e2e-tests/helpers.ts
  13. +1 −1 packages/create-cloudflare/package.json
  14. +2 −0 packages/create-cloudflare/scripts/build.ts
  15. +9 −6 packages/create-cloudflare/src/__tests__/workers.test.ts
  16. +2 −0 packages/create-cloudflare/src/cli.ts
  17. +5 −5 packages/create-cloudflare/src/frameworks/package.json
  18. +8 −0 packages/create-cloudflare/src/helpers/files.ts
  19. +84 −27 packages/create-cloudflare/src/templates.ts
  20. +8 −0 packages/create-cloudflare/src/types.ts
  21. +44 −24 packages/create-cloudflare/src/workers.ts
  22. +7 −5 packages/create-cloudflare/templates/common/c3.ts
  23. +7 −5 packages/create-cloudflare/templates/hello-world-durable-object/c3.ts
  24. +7 −5 packages/create-cloudflare/templates/hello-world/c3.ts
  25. +58 −0 packages/create-cloudflare/templates/next/README.md
  26. +21 −0 packages/create-cloudflare/templates/next/app/js/app/api/hello/route.js
  27. +58 −0 packages/create-cloudflare/templates/next/app/js/app/not-found.js
  28. +22 −0 packages/create-cloudflare/templates/next/app/ts/app/api/hello/route.ts
  29. +58 −0 packages/create-cloudflare/templates/next/app/ts/app/not-found.tsx
  30. +75 −62 packages/create-cloudflare/templates/next/c3.ts
  31. +7 −0 packages/create-cloudflare/templates/next/env.d.ts
  32. +23 −0 packages/create-cloudflare/templates/next/pages/js/pages/api/hello.js
  33. +24 −0 packages/create-cloudflare/templates/next/pages/ts/pages/api/hello.ts
  34. +0 −281 packages/create-cloudflare/templates/next/templates.ts
  35. +57 −0 packages/create-cloudflare/templates/next/wrangler.toml
  36. +56 −16 packages/create-cloudflare/templates/nuxt/c3.ts
  37. +50 −0 packages/create-cloudflare/templates/nuxt/templates/wrangler.toml
  38. +7 −5 packages/create-cloudflare/templates/queues/c3.ts
  39. +6 −3 packages/create-cloudflare/templates/qwik/c3.ts
  40. +50 −0 packages/create-cloudflare/templates/qwik/templates/wrangler.toml
  41. +7 −5 packages/create-cloudflare/templates/scheduled/c3.ts
  42. +4 −2 packages/create-cloudflare/templates/solid/c3.ts
  43. +80 −28 packages/create-cloudflare/templates/svelte/c3.ts
  44. +25 −0 packages/create-cloudflare/templates/svelte/js/src/hooks.server.js
  45. +50 −0 packages/create-cloudflare/templates/svelte/js/wrangler.toml
  46. +0 −13 packages/create-cloudflare/templates/svelte/templates.ts
  47. +24 −0 packages/create-cloudflare/templates/svelte/ts/src/hooks.server.ts
  48. +50 −0 packages/create-cloudflare/templates/svelte/ts/wrangler.toml
  49. +9 −0 packages/kv-asset-handler/turbo.json
  50. +121 −0 packages/miniflare/CHANGELOG.md
  51. +34 −8 packages/miniflare/README.md
  52. +3 −2 packages/miniflare/package.json
  53. +19 −11 packages/miniflare/src/http/fetch.ts
  54. +65 −14 packages/miniflare/src/index.ts
  55. +12 −3 packages/miniflare/src/plugins/cache/index.ts
  56. +66 −20 packages/miniflare/src/plugins/core/index.ts
  57. +11 −10 packages/miniflare/src/plugins/core/modules.ts
  58. +11 −5 packages/miniflare/src/plugins/core/services.ts
  59. +12 −3 packages/miniflare/src/plugins/d1/index.ts
  60. +13 −2 packages/miniflare/src/plugins/do/index.ts
  61. +35 −45 packages/miniflare/src/plugins/hyperdrive/index.ts
  62. +14 −13 packages/miniflare/src/plugins/index.ts
  63. +14 −4 packages/miniflare/src/plugins/kv/index.ts
  64. +3 −2 packages/miniflare/src/plugins/queues/index.ts
  65. +12 −3 packages/miniflare/src/plugins/r2/index.ts
  66. +27 −4 packages/miniflare/src/plugins/shared/constants.ts
  67. +20 −3 packages/miniflare/src/plugins/shared/index.ts
  68. +1 −0 packages/miniflare/src/runtime/config/workerd.ts
  69. +25 −1 packages/miniflare/src/shared/types.ts
  70. +6 −3 packages/miniflare/src/workers/core/constants.ts
  71. +5 −1 packages/miniflare/src/workers/shared/blob.worker.ts
  72. +1 −0 packages/miniflare/src/workers/shared/constants.ts
  73. +1 −1 packages/miniflare/src/workers/shared/index.worker.ts
  74. +8 −1 packages/miniflare/src/workers/shared/object.worker.ts
  75. +7 −8 packages/miniflare/src/zod-format.ts
  76. +7 −5 packages/miniflare/test/http/fetch.spec.ts
  77. +231 −4 packages/miniflare/test/index.spec.ts
  78. +26 −1 packages/miniflare/test/plugins/core/modules.spec.ts
  79. +32 −0 packages/miniflare/test/plugins/do/index.spec.ts
  80. +119 −29 packages/miniflare/test/plugins/hyperdrive/index.spec.ts
  81. +41 −0 packages/miniflare/test/plugins/kv/index.spec.ts
  82. +1 −1 packages/miniflare/test/shared/blob.spec.ts
  83. +19 −19 packages/miniflare/test/snapshots/zod-format.spec.ts.md
  84. BIN packages/miniflare/test/snapshots/zod-format.spec.ts.snap
  85. +12 −0 packages/miniflare/test/test-shared/storage.ts
  86. +3 −3 packages/miniflare/test/zod-format.spec.ts
  87. +7 −0 packages/pages-shared/CHANGELOG.md
  88. +1 −1 packages/pages-shared/package.json
  89. +5 −1 packages/playground-preview-worker/src/index.ts
  90. +15 −15 packages/playground-preview-worker/tests/index.test.ts
  91. +2 −0 packages/vitest-pool-workers/.eslintignore
  92. +28 −0 packages/vitest-pool-workers/.eslintrc.js
  93. +8 −0 packages/vitest-pool-workers/CHANGELOG.md
  94. +57 −0 packages/vitest-pool-workers/package.json
  95. +130 −0 packages/vitest-pool-workers/scripts/bundle.mjs
  96. +63 −0 packages/vitest-pool-workers/scripts/rtti/query.mjs
  97. +324 −0 packages/vitest-pool-workers/scripts/rtti/rtti.capnp
  98. +614 −0 packages/vitest-pool-workers/scripts/rtti/rtti.capnp.d.ts
  99. +773 −0 packages/vitest-pool-workers/scripts/rtti/rtti.capnp.js
  100. +33 −0 packages/vitest-pool-workers/src/config/index.ts
  101. +18 −0 packages/vitest-pool-workers/src/mock-agent/client.cjs
  102. +9 −0 packages/vitest-pool-workers/src/mock-agent/dispatcher.cjs
  103. +28 −0 packages/vitest-pool-workers/src/mock-agent/index.cjs
  104. +34 −0 packages/vitest-pool-workers/src/mock-agent/pending-interceptor-formatter.cjs
  105. +9 −0 packages/vitest-pool-workers/src/mock-agent/pool.cjs
  106. +225 −0 packages/vitest-pool-workers/src/pool/config.ts
  107. +23 −0 packages/vitest-pool-workers/src/pool/helpers.ts
  108. +815 −0 packages/vitest-pool-workers/src/pool/index.ts
  109. +342 −0 packages/vitest-pool-workers/src/pool/loopback.ts
  110. +403 −0 packages/vitest-pool-workers/src/pool/module-fallback.ts
  111. +6 −0 packages/vitest-pool-workers/src/pool/types-global.d.ts
  112. +313 −0 packages/vitest-pool-workers/src/worker/durable-objects.ts
  113. +28 −0 packages/vitest-pool-workers/src/worker/env.ts
  114. +343 −0 packages/vitest-pool-workers/src/worker/events.ts
  115. +133 −0 packages/vitest-pool-workers/src/worker/fetch-mock.ts
  116. +82 −0 packages/vitest-pool-workers/src/worker/import.ts
  117. +225 −0 packages/vitest-pool-workers/src/worker/index.ts
  118. +13 −0 packages/vitest-pool-workers/src/worker/lib/README.md
  119. +7 −0 packages/vitest-pool-workers/src/worker/lib/cloudflare/test-internal.ts
  120. +301 −0 packages/vitest-pool-workers/src/worker/lib/cloudflare/test-runner.ts
  121. +14 −0 packages/vitest-pool-workers/src/worker/lib/cloudflare/test.ts
  122. +3 −0 packages/vitest-pool-workers/src/worker/lib/debug.ts
  123. +44 −0 packages/vitest-pool-workers/src/worker/lib/mlly.ts
  124. +108 −0 packages/vitest-pool-workers/src/worker/lib/node/console.ts
  125. +21 −0 packages/vitest-pool-workers/src/worker/lib/node/fs.ts
  126. +1 −0 packages/vitest-pool-workers/src/worker/lib/node/fs/promises.ts
  127. +68 −0 packages/vitest-pool-workers/src/worker/lib/node/http.cts
  128. +11 −0 packages/vitest-pool-workers/src/worker/lib/node/module.ts
  129. +1 −0 packages/vitest-pool-workers/src/worker/lib/node/net.cts
  130. +2 −0 packages/vitest-pool-workers/src/worker/lib/node/perf_hooks.ts
  131. +341 −0 packages/vitest-pool-workers/src/worker/lib/node/process.cts
  132. +13 −0 packages/vitest-pool-workers/src/worker/lib/node/querystring.cts
  133. +1 −0 packages/vitest-pool-workers/src/worker/lib/node/timers.ts
  134. +3 −0 packages/vitest-pool-workers/src/worker/lib/node/tty.ts
  135. +81 −0 packages/vitest-pool-workers/src/worker/lib/node/url.ts
  136. +14 −0 packages/vitest-pool-workers/src/worker/lib/node/vm.ts
  137. +1 −0 packages/vitest-pool-workers/src/worker/lib/tinypool.ts
  138. +12 −0 packages/vitest-pool-workers/src/worker/tsconfig.json
  139. +58 −0 packages/vitest-pool-workers/src/worker/types-ambient.d.ts
  140. +21 −0 packages/vitest-pool-workers/src/worker/types-globals.d.ts
  141. +7 −0 packages/vitest-pool-workers/test/basic/env.d.ts
  142. +16 −0 packages/vitest-pool-workers/test/basic/fake-timer.test.ts
  143. +15 −0 packages/vitest-pool-workers/test/basic/maths.test.ts
  144. +58 −0 packages/vitest-pool-workers/test/basic/mocking.test.ts
  145. +10 −0 packages/vitest-pool-workers/test/basic/setup/global-setup.ts
  146. +4 −0 packages/vitest-pool-workers/test/basic/setup/setup.ts
  147. +7 −0 packages/vitest-pool-workers/test/basic/strings.test.ts
  148. +25 −0 packages/vitest-pool-workers/test/basic/vitest.config.ts
  149. +271 −0 packages/vitest-pool-workers/test/cloudflare-test.d.ts
  150. +3 −0 packages/vitest-pool-workers/test/kv/__snapshots__/store.test.ts.snap
  151. +12 −0 packages/vitest-pool-workers/test/kv/env.d.ts
  152. +11 −0 packages/vitest-pool-workers/test/kv/other-worker.mjs
  153. +1 −0 packages/vitest-pool-workers/test/kv/seed.txt
  154. +139 −0 packages/vitest-pool-workers/test/kv/store.test.ts
  155. +43 −0 packages/vitest-pool-workers/test/kv/vitest.config.ts
  156. +52 −0 packages/vitest-pool-workers/test/kv/worker.ts
  157. +69 −0 packages/vitest-pool-workers/test/stacked/stacked.test.ts
  158. +18 −0 packages/vitest-pool-workers/test/stacked/vitest.config.ts
  159. +8 −0 packages/vitest-pool-workers/test/tsconfig.json
  160. +12 −0 packages/vitest-pool-workers/tsconfig.emit.json
  161. +21 −0 packages/vitest-pool-workers/tsconfig.json
  162. +9 −0 packages/vitest-pool-workers/turbo.json
  163. +10 −0 packages/vitest-pool-workers/vitest.workers.config.ts
  164. +4 −0 packages/vitest-pool-workers/vitest.workspace.ts
  165. +2 −0 packages/workers-playground/.env.development
  166. +6 −4 packages/workers-playground/README.md
  167. +15 −17 packages/workers-playground/src/QuickEditor/HTTPTab/HTTPTab.tsx
  168. +17 −7 packages/workers-playground/src/QuickEditor/ToolsPane.tsx
  169. +15 −12 packages/workers-playground/vite.config.ts
  170. +36 −0 packages/wrangler/CHANGELOG.md
  171. +102 −3 packages/wrangler/e2e/dev.test.ts
  172. +2 −2 packages/wrangler/e2e/helpers/normalize.ts
  173. +2 −4 packages/wrangler/e2e/r2.test.ts
  174. +1 −1 packages/wrangler/package.json
  175. +21 −58 packages/wrangler/src/__tests__/deploy.test.ts
  176. +4 −6 packages/wrangler/src/__tests__/dev.test.tsx
  177. +8 −32 packages/wrangler/src/__tests__/kv.test.ts
  178. +2 −8 packages/wrangler/src/__tests__/mtls-certificates.test.ts
  179. +3 −12 packages/wrangler/src/__tests__/pages/pages.test.ts
  180. +0 −3 packages/wrangler/src/__tests__/r2.local.test.ts
  181. +3 −12 packages/wrangler/src/__tests__/secret.test.ts
  182. +1 −4 packages/wrangler/src/__tests__/sentry.test.ts
  183. +30 −0 packages/wrangler/src/__tests__/standard-pricing.test.ts
  184. +4 −0 packages/wrangler/src/api/dev.ts
  185. +26 −2 packages/wrangler/src/api/integrations/platform/caches.ts
  186. +4 −1 packages/wrangler/src/api/startDevWorker/ProxyController.ts
  187. +7 −1 packages/wrangler/src/api/startDevWorker/types.ts
  188. +11 −0 packages/wrangler/src/deploy/index.ts
  189. +38 −4 packages/wrangler/src/dev.tsx
  190. +30 −0 packages/wrangler/src/dev/dev.tsx
  191. +4 −0 packages/wrangler/src/dev/local.tsx
  192. +6 −1 packages/wrangler/src/dev/miniflare.ts
  193. +21 −5 packages/wrangler/src/dev/proxy.ts
  194. +4 −0 packages/wrangler/src/dev/remote.tsx
  195. +6 −0 packages/wrangler/src/dev/start-server.ts
  196. +1 −0 packages/wrangler/src/environment-variables/factory.ts
  197. +32 −2 packages/wrangler/src/https-options.ts
  198. +6 −4 packages/wrangler/src/index.ts
  199. +14 −0 packages/wrangler/src/pages/dev.ts
  200. +11 −0 packages/wrangler/src/versions/index.ts
  201. +302 −60 pnpm-lock.yaml
  202. +4 −0 turbo.json
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ fixtures/**/dist/**
# Miniflare shouldn't be formatted with the root `prettier` version
packages/miniflare

# Generated Cap'n Proto files shouldn't be formatted
*.capnp.js
*.capnp.d.ts

# In the C3 templates, in particular framework templates, we want to be able to
# use any format that the framework authors prefer/use in their own templates,
# so let's ignore all the c3 template files, exlcuding the c3.ts ones
2 changes: 1 addition & 1 deletion fixtures/dev-env/package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"@types/ws": "^8.5.7",
"@cloudflare/workers-tsconfig": "workspace:^",
"get-port": "^7.0.0",
"miniflare": "3.20240129.2",
"miniflare": "3.20240129.3",
"undici": "^5.28.2",
"wrangler": "workspace:*",
"ws": "^8.14.2"
Original file line number Diff line number Diff line change
@@ -17,6 +17,44 @@ describe("getPlatformProxy - caches", () => {
}
})
);

it("should match the production runtime caches object", async () => {
const { caches: platformProxyCaches, dispose } = await getPlatformProxy();
const caches = platformProxyCaches as any;
try {
expect(Object.keys(caches)).toEqual(["default"]);

expect(() => {
caches.has("my-cache");
}).toThrowError(
"Failed to execute 'has' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.delete("my-cache");
}).toThrowError(
"Failed to execute 'delete' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.keys();
}).toThrowError(
"Failed to execute 'keys' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.match(new URL("https://localhost"));
}).toThrowError(
"Failed to execute 'match' on 'CacheStorage': the method is not implemented."
);

expect(() => {
caches.nonExistentMethod();
}).toThrowError("caches.nonExistentMethod is not a function");
} finally {
await dispose();
}
});
});

async function testNoOpCache(
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -11,15 +11,15 @@
"author": "wrangler@cloudflare.com",
"scripts": {
"build": "dotenv -- turbo build",
"check": "dotenv -- turbo check:lint check:type check:format type:tests",
"check": "node ensure-turbo-build-output.mjs && dotenv -- turbo check:lint check:type check:format type:tests",
"check:format": "prettier . --check --ignore-unknown",
"check:lint": "node ensure-turbo-build-output.mjs && dotenv -- turbo check:lint",
"check:lint": "dotenv -- turbo check:lint",
"check:type": "dotenv -- turbo check:type type:tests",
"dev": "dotenv -- turbo dev",
"fix": "pnpm run prettify && dotenv -- turbo check:lint -- --fix",
"prettify": "prettier . --write --ignore-unknown",
"test": "dotenv -- turbo test",
"test:ci": "vitest run && dotenv -- turbo test:ci --filter=wrangler --filter=miniflare --filter=kv-asset-handler",
"test:ci": "vitest run && dotenv -- turbo test:ci --filter=wrangler --filter=miniflare --filter=kv-asset-handler --filter=@cloudflare/vitest-pool-workers",
"test:watch": "turbo test:watch",
"type:tests": "dotenv -- turbo type:tests",
"gen:package": "turbo gen package"
44 changes: 44 additions & 0 deletions packages/create-cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# create-cloudflare

## 2.12.0

### Minor Changes

- [#4996](https://github.com/cloudflare/workers-sdk/pull/4996) [`246512c8`](https://github.com/cloudflare/workers-sdk/commit/246512c8e34fa218b1d52d3a52cd6aa348fdf563) Thanks [@jculvey](https://github.com/jculvey)! - feature: Add `getBindingsProxy` support to `nuxt` template via `nitro-cloudflare-dev` module.

The `nuxt` template now uses the default dev command from `create-nuxt` instead of using `wrangler pages dev` on build output in order to improve the developer workflow. `nitro-cloudflare-dev` is a nitro module that leverages `getBindingsProxy` and allows bindings to work in nitro commands.

* [#5027](https://github.com/cloudflare/workers-sdk/pull/5027) [`a751489f`](https://github.com/cloudflare/workers-sdk/commit/a751489f2530bc7a7adec1167319cd145f080812) Thanks [@jculvey](https://github.com/jculvey)! - feature: Improve bindings support in Svelte template.

C3 will now create Svelte projects with a hook that uses `getPlatformProxy` to proxy bindings in development mode. A `wrangler.toml` file will also be added where bindings can be added to be used in conjunction with `getPlatformProxy`.

Along with this change, projects will use the default vite-based dev command from `create-svelte` instead of using `wrangler pages dev` on build output.

When Typescript is used, the `app.d.ts` will be updated to add type definitions for `cf` and `ctx` to the `Platform` interface from the `@cloudflare/workers-types` package. Types for bindings on `platform.env` can be re-generated with a newly added `build-cf-types` script.

### Patch Changes

- [#5001](https://github.com/cloudflare/workers-sdk/pull/5001) [`efe8b444`](https://github.com/cloudflare/workers-sdk/commit/efe8b444e4220cfb23c443dc172582ee58119bc5) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: Bumped `create-hono` from `0.3.2` to `0.4.0`

* [#5011](https://github.com/cloudflare/workers-sdk/pull/5011) [`89482d44`](https://github.com/cloudflare/workers-sdk/commit/89482d4475780c3cd3efbbd004c6b4f85c8daf53) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: Bumped `create-qwik` from `1.4.4` to `1.4.5`

- [#5019](https://github.com/cloudflare/workers-sdk/pull/5019) [`f939ed73`](https://github.com/cloudflare/workers-sdk/commit/f939ed739a89de174099f128530a29bd51b04899) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: Bumped `@angular/create` from `17.1.3` to `17.2.0`

* [#5020](https://github.com/cloudflare/workers-sdk/pull/5020) [`0e74c743`](https://github.com/cloudflare/workers-sdk/commit/0e74c743236d2a9055648eac9397d566ac90d83b) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: Bumped `nuxi` from `3.10.0` to `3.10.1`

- [#5021](https://github.com/cloudflare/workers-sdk/pull/5021) [`ae1ef47c`](https://github.com/cloudflare/workers-sdk/commit/ae1ef47c8981a1059b5c8a2adaf7edeb38c1c49d) Thanks [@dependabot](https://github.com/apps/dependabot)! - chore: Bumped `create-astro` from `4.7.2` to `4.7.3`

* [#5009](https://github.com/cloudflare/workers-sdk/pull/5009) [`1e263694`](https://github.com/cloudflare/workers-sdk/commit/1e2636940cc05b06475cce6d96a882f03216ff78) Thanks [@dario-piotrowicz](https://github.com/dario-piotrowicz)! - chore: update Next.js template

Update the C3 Next.js template so that it uses the latest `@cloudflare/next-on-pages` tooling (i.e. `setupDevPlatform` and `getRequestContext`)

- [#4996](https://github.com/cloudflare/workers-sdk/pull/4996) [`246512c8`](https://github.com/cloudflare/workers-sdk/commit/246512c8e34fa218b1d52d3a52cd6aa348fdf563) Thanks [@jculvey](https://github.com/jculvey)! - feature: Add an empty `wrangler.toml` file to qwik and nuxt templates.

* [#4999](https://github.com/cloudflare/workers-sdk/pull/4999) [`ce6d4bc4`](https://github.com/cloudflare/workers-sdk/commit/ce6d4bc4753625d2aaf1b832bbb47fc50b24a98b) Thanks [@dario-piotrowicz](https://github.com/dario-piotrowicz)! - fix: make sure not to wrongly ask users if they want to use typescript

currently if a CLI invoked by C3 asks the user if they want to use
typescript and the user opted out of it, C3 could actually again offer
typescript to the user afterwords, make sure that this does not happen

- [#5010](https://github.com/cloudflare/workers-sdk/pull/5010) [`9f787042`](https://github.com/cloudflare/workers-sdk/commit/9f787042fc6894f5f1ebdc99e0ae10afbe6bdae6) Thanks [@dario-piotrowicz](https://github.com/dario-piotrowicz)! - chore: update qwik template to use `getPlatformProxy`

update the C3 Qwik template to use the `getPlatformProxy` utility instead of the deprecated `getBindingsProxy` one

## 2.11.3

### Patch Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default eventHandler(async (event) => {
if (!event.context.cloudflare) {
return { success: false };
}
const { TEST } = event.context.cloudflare.env;

return { value: TEST, success: true };
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[vars]
TEST = "C3_TEST"
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ export const onGet: RequestHandler = async ({ platform, json }) => {
return;
}

json(200, { value: platform.env["TEST"], version: 1 });
json(200, { value: platform.env["TEST"], success: true });
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export async function GET({ platform }) {
const test = platform?.env.TEST;

return new Response(JSON.stringify({ test }), {
headers: {
"Content-Type": "application/json",
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[vars]
TEST = "C3_TEST"
30 changes: 27 additions & 3 deletions packages/create-cloudflare/e2e-tests/frameworks.test.ts
Original file line number Diff line number Diff line change
@@ -152,10 +152,21 @@ const frameworkTests: Record<string, FrameworkTestConfig> = {
nuxt: {
testCommitMessage: true,
timeout: LONG_TIMEOUT,
unsupportedOSs: ["win32"],
verifyDeploy: {
route: "/",
expectedText: "Welcome to Nuxt!",
},
verifyDev: {
route: "/test",
expectedText: "C3_TEST",
},
verifyBuild: {
outputDir: "./dist",
script: "build",
route: "/test",
expectedText: "C3_TEST",
},
},
react: {
testCommitMessage: true,
@@ -211,6 +222,16 @@ const frameworkTests: Record<string, FrameworkTestConfig> = {
route: "/",
expectedText: "SvelteKit app",
},
verifyDev: {
route: "/test",
expectedText: "C3_TEST",
},
verifyBuild: {
outputDir: ".svelte-kit/cloudflare",
script: "build",
route: "/test",
expectedText: "C3_TEST",
},
},
vue: {
testCommitMessage: true,
@@ -421,8 +442,8 @@ const verifyDevScript = async (
logStream
);

// Wait a few seconds for dev server to spin up
await sleep(4000);
// Wait an eternity for the dev server to spin up
await sleep(12000);

// Make a request to the specified test route
const res = await fetch(`http://localhost:${TEST_PORT}${verifyDev.route}`);
@@ -457,6 +478,9 @@ const verifyBuildScript = async (
[pm, "run", script],
{
cwd: projectPath,
env: {
NODE_ENV: "production",
},
},
logStream
);
@@ -474,7 +498,7 @@ const verifyBuildScript = async (
);

// Wait a few seconds for dev server to spin up
await sleep(4000);
await sleep(7000);

// Make a request to the specified test route
const res = await fetch(`http://localhost:${TEST_PORT}${route}`);
4 changes: 2 additions & 2 deletions packages/create-cloudflare/e2e-tests/helpers.ts
Original file line number Diff line number Diff line change
@@ -115,6 +115,8 @@ export const spawnWithLogging = (
) => {
const [cmd, ...argv] = args;

logStream.write(`\nRunning command: ${[cmd, ...argv].join(" ")}\n\n`);

const proc = spawn(cmd, argv, {
...opts,
env: {
@@ -123,8 +125,6 @@ export const spawnWithLogging = (
},
});

logStream.write(`\nRunning command: ${[cmd, ...argv].join(" ")}\n\n`);

proc.stdout.on("data", (data) => {
const lines: string[] = data.toString().split("\n");

2 changes: 1 addition & 1 deletion packages/create-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-cloudflare",
"version": "2.11.3",
"version": "2.12.0",
"description": "A CLI for creating and deploying new applications to Cloudflare.",
"keywords": [
"cloudflare",
2 changes: 2 additions & 0 deletions packages/create-cloudflare/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ const run = async () => {
bundle: true,
outdir: "./dist",
platform: "node",
// This is required to support jsonc-parser. See https://github.com/microsoft/node-jsonc-parser/issues/57
mainFields: ["module", "main"],
format: "cjs",
};

15 changes: 9 additions & 6 deletions packages/create-cloudflare/src/__tests__/workers.test.ts
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ describe("addWorkersTypesToTsConfig", () => {

// Mock the read of tsconfig.json
vi.mocked(readFile).mockImplementation(
() => `{types: ["@cloudflare/workers-types"]}`
() => `{ "compilerOptions": { "types": ["@cloudflare/workers-types"]} }`
);
});

@@ -101,8 +101,10 @@ describe("addWorkersTypesToTsConfig", () => {
test("happy path", async () => {
await addWorkersTypesToTsConfig(ctx);

expect(vi.mocked(writeFile).mock.calls[0][1]).toEqual(
`{types: ["@cloudflare/workers-types/2023-07-01"]}`
expect(writeFile).toHaveBeenCalled();

expect(vi.mocked(writeFile).mock.calls[0][1]).toContain(
`"@cloudflare/workers-types/2023-07-01"`
);
});

@@ -123,12 +125,13 @@ describe("addWorkersTypesToTsConfig", () => {

test("don't clobber existing entrypoints", async () => {
vi.mocked(readFile).mockImplementation(
() => `{types: ["@cloudflare/workers-types/2021-03-20"]}`
() =>
`{ "compilerOptions": { "types" : ["@cloudflare/workers-types/2021-03-20"]} }`
);
await addWorkersTypesToTsConfig(ctx);

expect(vi.mocked(writeFile).mock.calls[0][1]).toEqual(
`{types: ["@cloudflare/workers-types/2021-03-20"]}`
expect(vi.mocked(writeFile).mock.calls[0][1]).toContain(
`"@cloudflare/workers-types/2021-03-20"`
);
});
});
2 changes: 2 additions & 0 deletions packages/create-cloudflare/src/cli.ts
Original file line number Diff line number Diff line change
@@ -138,6 +138,8 @@ const configure = async (ctx: C3Context) => {
await installWrangler();
await installWorkersTypes(ctx);

// Note: updateWranglerToml _must_ be called before the configure phase since
// pre-existing workers assume its presence in their configure phase
await updateWranglerToml(ctx);

const { template } = ctx;
10 changes: 5 additions & 5 deletions packages/create-cloudflare/src/frameworks/package.json
Original file line number Diff line number Diff line change
@@ -6,19 +6,19 @@
"additionally it also contains a map that maps frameworks to their respective clis"
],
"dependencies": {
"create-astro": "4.7.2",
"@angular/create": "17.1.3",
"create-astro": "4.7.3",
"@angular/create": "17.2.0",
"create-docusaurus": "3.1.1",
"create-hono": "0.3.2",
"create-hono": "0.4.0",
"create-next-app": "14.1.0",
"create-qwik": "1.4.4",
"create-qwik": "1.4.5",
"create-react-app": "5.0.1",
"create-remix": "2.6.0",
"create-solid": "0.4.10",
"create-svelte": "6.0.8",
"create-vue": "3.9.2",
"gatsby": "5.13.3",
"nuxi": "3.10.0"
"nuxi": "3.10.1"
},
"frameworkCliMap": {
"angular": "@angular/create",
8 changes: 8 additions & 0 deletions packages/create-cloudflare/src/helpers/files.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,14 @@ import TOML from "@iarna/toml";
import { getWorkerdCompatibilityDate } from "./command";
import type { C3Context } from "types";

export const copyFile = (path: string, dest: string) => {
try {
fs.copyFileSync(path, dest);
} catch (error) {
crash(error as string);
}
};

export const writeFile = (path: string, content: string) => {
try {
fs.writeFileSync(path, content);
Loading