* tighten up turbo dependencies to avoid having to manually build
* test: ensure that fixture packages always start with `fixture-`
* refactor: consolidate fixture package names with consistent `fixture-` prefix
Updates all 63 fixture package names to use a consistent naming scheme with logical categorization:
- Core workers: fixture-worker-basic, fixture-worker-ai, fixture-worker-typescript, etc.
- Pages functions: fixture-pages-functions, fixture-pages-workerjs, etc.
- Database/storage: fixture-d1-basic, fixture-secrets-store, etc.
- Module handling: fixture-import-wasm, fixture-no-bundle-import, etc.
- Development tools: fixture-interactive-dev, fixture-local-mode, etc.
Also updates test files that reference specific fixture package names to maintain compatibility.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* add CI_OS env var to the check run to ensure correct turbo remote caching
* fixup! refactor: consolidate fixture package names with consistent `fixture-` prefix
* fixup! test: ensure that fixture packages always start with `fixture-`
* revert unnecessary change
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Do not console log wrangler output during normal fixture tests
This creates a lot of unwanted logging in the console.
The logging is still dumped to the console if the test times out, or if `WRANGLER_LOG=debug` is set as env var.
* no need to get relative config path for calls to verifyWorkerMatchesCITag()
* feat: add support for redirecting Wrangler to a generated config when running deploy commands
This new feature is designed for build tools and frameworks to provide a deploy-specific configuration,
which Wrangler can use instead of user configuration when running deploy commands.
It is not expected that developers of Workers will need to use this feature directly.
The commands that use this feature are:
- `wrangler deploy`
- `wrangler dev`
- `wrangler versions upload`
- `wrangler versions deploy`
When running these commands, Wrangler will look up the directory tree from the current working directory for a file at the path `.wrangler/deploy/config.json`. This file must contain only a single JSON object of the form:
```json
{ "configPath": "../../path/to/wrangler.json" }
```
When this file exists Wrangler will use the `configPath` (relative to the `deploy.json` file) to find an alternative Wrangler configuration file to load and use as part of this command.
When this happens Wrangler will display a warning to the user to indicate that the configuration has been redirected to a different file than the user's configuration file.
A common approach that a build tool might choose to implement.
- The user writes code that uses Cloudflare Workers resources, configured via a user `wrangler.toml` file.
```toml
name = "my-worker"
main = "src/index.ts"
[[kv_namespaces]]
binding = "<BINDING_NAME1>"
id = "<NAMESPACE_ID1>"
```
Note that this configuration points `main` at user code entry-point.
- The user runs a custom build, which might read the `wrangler.toml` to find the entry-point:
```bash
> my-tool build
```
- This tool generates a `dist` directory that contains both compiled code and a new deployment configuration file, but also a `.wrangler/deploy/config.json` file that redirects Wrangler to this new deployment configuration file:
```plain
- dist
- index.js
- wrangler.json
- .wrangler
- deploy
- config.json
```
The `dist/wrangler.json` will contain:
```json
{
"name": "my-worker",
"main": "./index.js",
"kv_namespaces": [{ "binding": "<BINDING_NAME1>", "id": "<NAMESPACE_ID1>" }]
}
```
And the `.wrangler/deploy/config.json` will contain:
```json
{
"configPath": "../../dist/wrangler.json"
}
```
* add config redirect fixture with tests
* Add config redirect support for Pages commands
* refactor: compute both the actual config path and the original user's configuration
* add `userConfigPath` to the `Config` type so it can be used where needed
* add fixture and test for redirected config in a pages project
* Do not check formatting of generated fixture files
* clean node_modules for npm-import fixture before testing
* fix unstable_dev tests
* run more Wrangler e2e tests on safe ports
* Requires that you create a `.env` file in the `packages/wrangler` directory containing:
```
CLOUDFLARE_ACCOUNT_ID=<dev-prod-account-id>
CLOUDFLARE_API_TOKEN=<dev-prod-account-api-key>
WRANGLER="node <path to workers-sdk/packages/wrangler/bin/wrangler.js>"
WRANGLER_IMPORT="<path to /workers-sdk/packages/wrangler/wrangler-dist/cli.js>"
````
* correctly configure python workers when no command line script is provided
* test: ensure that `pages functions build-env` command outputs correct relative pages_build_output_dir path
* Improve error message when deploy/config.json is not valid
* Complete jsdoc description
* Update jsdocs to note that the result of `resolveWranglerConfigPath()` contains absolute paths.
* PR feedback
* rename `useRedirect` to `useRedirectIfAvailable`
* Rename command definition behaviour from "useConfigRedirect" to "useConfigRedirectIfAvailable"
* Add clarifying comment
* Do not store package-lock.json for import-npm fixture
This fixture does not need a package lockfile to work.
* Remove unnecessary option in test
* No more React in dev
* fix e2e
* remove more dead code
* fix
* fix fixtures
* fix prettier
* fix lockfile
* more dead code elimination
* lockfile
* fix regression
* Create late-guests-end.md
* fix lockfile
* fix merge
* fix snapshots
* remove stray log
* windows?
* add e2e retries
* fail at the right bit of e2e c3 test
* skip on windows
* remove retries
* Update messaging
* add --x-dev-env to fixtures usage of `wrangler dev`
* set experimental.devEnv flag on fixtures usage of `unstable_dev()`
* fixups
* fixups
* cleanup runWranglerLongLived with tree-kill
* disable --x-registry/fileBasedRegistry in external-durable-objects-app fixtures
* unstable_dev should wait for ProxyWorker and UserWorker to be ready
* fixup
* fixup
* use runWranglerDevPages instead of fork
* add changeset
* chore: update wrangler tests to support running on node 18
* test: hide unwanted console logs from test output
* chore: tighten up wrangler turbo inputs further
The tests change files within the src directory, which was causing cache misses every time on builds
* test: use explicit IPv4 localhost address (127.0.0.1) to avoid known issue
When `wrangler dev` is run with `--port=0` workerd can get messed up on Node 18+
because it starts listening to both 127.0.0.1 and ::1 addresses with different dynamically
assigned ports. The workaround is to always specify the IP address when setting port to 0.
* chore: update the mono-repo to run on Node 18+
* chore: do not try to format temporary turbo files
* docs: remove incorrect requirement from pages-example-forum-app template
* ci: run Github Actions in Node.js 18.20.2
* test: ignore EBUSY errors when trying to clean up temp directories on Windows
* cache + speedup windows e2e
* fix README
* Merge prerelease jobs
* Run tests on PRs
* Fix turborepo
* Cache changesets
* Use turbo for create-cloudflare publishing
* feature: support named entrypoints in `wrangler (pages) deploy`
* chore: exclude `miniflare` from monorepo's Prettier config
* fix: allow `script`s without `scriptPath`s to import built-ins
* feature: service binding named entrypoints for single-instance JSRPC
* feature: direct socket named entrypoints for multi-instance JSRPC
* refactor: switch middleware to `external` services for dev registry
* feature: support binding to named entrypoints in `wrangler dev`
* feature: add middleware support to `WorkerEntrypoint`s
* feature: add API for starting isolated dev registry
* fix: ensure `url` and `cf` blob preserved across service bindings
* test: add tests for named entrypoints and RPC
* fixup! test: add tests for named entrypoints and RPC
Update error messages
* fix: improve error message for cross-session Durable Object RPC
* chore: move service binding assignment before Durable Objects
* fix: improve error message for RPC on not found service
* test: update deploy snapshot
* Add test for binding to own named entrypoint
* fix: allow named entrypoints to current worker
* Simplify cross-Worker Durable Object RPC error message
* Bump @cloudflare/workers-types@4.20240402.0
---------
Co-authored-by: bcoll <bcoll@cloudflare.com>
* ci: remove fixture from changeset releases
* ci: ensure that fixtures are not deployable
* ci: actually run the deploy script not the deploy command for deploying Workers and Pages
* fixup! ci: ensure that fixtures are not deployable
* fix: ensure that the Pages dev proxy server does not change the Host header
Previously, when configuring `wrangler pages dev` to use a proxy to a 3rd party dev server,
the proxy would replace the Host header, resulting in problems at the dev server if it was
checking for cross-site scripting attacks.
Now the proxy server passes through the Host header unaltered making it invisible to the
3rd party dev server.
Fixes#4799
* fixup! fix: ensure that the Pages dev proxy server does not change the Host header
* fixup! fix: ensure that the Pages dev proxy server does not change the Host header
* fixup! fix: ensure that the Pages dev proxy server does not change the Host header
* [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
* fixup! [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
* fixup! [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
* fixup! [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
* Update .changeset/hip-files-count.md
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
* !fixup: [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
* !fixup: [wrangler] fix: stop rebuild attempts when sources are missing (#3886)
---------
Co-authored-by: Peter Bacon Darwin <pbacondarwin@cloudflare.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
As of #4072, whenever Wrangler connected to the V8 inspector, it would
clear V8's internal buffer of log messages. This ensured only messages
logged while the inspector was connected would be displayed.
Unfortunately, we only connect to the inspector once the Worker has
reported it's ready to receive connections. This meant any
`console.log()`s during Worker startup wouldn't be displayed. This
change switches to clearing V8's buffer whenever we _disconnect_
from the inspector instead, ensuring startup logs are shown.
* typo
* move stuff
* remove unnecessary typing
* remove unnecessary `active` property from middleware loader config
* more refactorings
* rename traverseModuleGraph as this is not what it does
* refactor to simplify findAdditionalModules()
* Rename the functions build helpers to make it more clear what their role is.
* invert module collector config - no longer need to return it as it is passed in
* implement module finding in normal bundling if the find_additional_modules flag is on
* allow `__STATIC_CONTENT_MANIFEST` to be imported from any module
* test: improve no-bundle-import tests
The no-bundle-import tests would actually pass if Wrangler actually bundled the code,
since it would identify and inline all the dynamic
imports that were being tested.
This change adds a test that would not pass if we are not capturing the additional modules.
It also moves the declaration of no-bundle to the wrangler.toml to ensure that normal use of `wrangler dev` will get this behavior.
* refactor: convert additional file finding to a generator function
This has a few of benefits:
- we don't risk creating too many file reads in a single go (using up all the available file handles); previously file reads were all done in parallel
- we don't read the files over and over for each rule
- the code is a bit easier to follow as we don't have to create `Promise.all()` objects
* fix: ensure that additional modules appear in the out-dir
When using `find_additional_modules` (or `no_bundle`) we find files that
will be uploaded to be deployed alongside the Worker.
Previously, if an `outDir` was specified, only the Worker code was output
to this directory. Now all additional modules are also output there too.
* pnpm fixups
* test: ignore failure to remove tmp dir on Windows
* test: do not show output in d1 time-travel tests
* refactor: consolidate writing additional modules
* test: add CommonJS lazy import to additional-modules fixture
* test: rename spec to test
* Add debug logging when writing additional modules
* Test additional module failure case and fix message typo
* Display build warnings before updating the bundle
---------
Co-authored-by: bcoll <bcoll@cloudflare.com>
* Turborepo
- Turbo Workspaces: isolated tasks and localized pipelines more complex packages to exist in the monorepo.
- Persistent mode for dev keyword let's Turborepo know it's something that will be watched or run long term.
- Update all packages with namespaced ones for configs
- Namespacing TSConfig & ESlint with `@Cloudflare/` per security suggestion by Greg Brimble
* ESLint and TSConfig Monorepo Configuration
- ESLint & TSConfig are local packages, the monorepo now isolates its configs to packages utilizing them,
configurations are now monorepo packages
- Type Checking TypeScript can now directly
use the TSConfig which infers from valid TS config formats, since we are using Monorepo conventions each
package only needs to care about its own config specifics and the extended global config as a package.
- Wrangler Emit TSConfig: Figure out if this can be part of the TurboRepo pipeline then move this into the workers-
tsconfig package as "wrangler-emit"
- TurboRepo setup to work with TypeScript subdirectories as TS projects & added configs to more fixtures
- Instructions for VSCode TypeScript Project Version
- ESLint & Turbo require the `.` declared where to run monorepo tasks from each package
* Dependencies
- Adding Wrangler as direct Dependency for Fixtures that need it
- Standardize Monorepo packaging in Fixtures
- All Wrangler dependencies are now devDependency
* Vitest
- Update Vitest & remove global Vitest config
- Added Vitest script for explicit test:watch
- Refactor pages-simple-assets test
- Fix tests in fixtures (thanks @petebacondarwin)
* refactor: tidy up fixture tests of long-lived wrangler processes
We now use helper functions to setup and teardown a long-lived wrangler process.
This means that we can remove the `--forceExit` option from the jest setup.
* feat: support bundling the raw Pages `_worker.js` before deploying
Previously, if you provided a `_worker.js` file, then Pages would simply check the
file for disallowed imports and then deploy the file as-is.
Not bundling the `_worker.js` file means that it cannot containing imports to other
JS files, but also prevents Wrangler from adding shims such as the one for the D1 alpha
release.
This change adds the ability to tell Wrangler to pass the `_worker.js` through the
normal Wrangler bundling process before deploying by setting the `--bundle`
command line argument to `wrangler pages dev` and `wrangler pages publish`.
This is in keeping with the same flag for `wrangler publish`.
Currently bundling is opt-in, flag defaults to `false` if not provided.
* test: increase timeout on local-mode test