| 1 | # @distilled.cloud/vendor-workers-shared |
| 2 | |
| 3 | Private workspace package vendoring raw TypeScript source from |
| 4 | [`@cloudflare/workers-shared`](https://github.com/cloudflare/workers-sdk/tree/f9e7727dbef58e71c6b297dc688d3c544cef87cb/packages/workers-shared). |
| 5 | This package does not bundle or publish; consumer packages in this monorepo |
| 6 | import the `.ts` files directly and apply their own bundling. |
| 7 | |
| 8 | Sibling vendored packages live alongside this one under `packages/` |
| 9 | (e.g. `packages/cloudflare-runtime/src/internal/workflows-shared` for `@cloudflare/workflows-shared`). |
| 10 | |
| 11 | ## Layout |
| 12 | |
| 13 | The source tree is split into three buckets that correspond to three tsconfig |
| 14 | project references: |
| 15 | |
| 16 | - `src/internal/workers-shared/workers/` — code that runs in the Workers runtime. Typechecked against |
| 17 | `@cloudflare/workers-types` only (plus `@cloudflare/vitest-plugin/types` |
| 18 | for the colocated `tests/` directories). |
| 19 | - `src/internal/workers-shared/shared/` — isomorphic code (web-platform APIs only) used by both Workers |
| 20 | and Node consumers. Typechecked against the intersection of Workers and Node |
| 21 | type sets. |
| 22 | - `src/internal/workers-shared/node/` — Node-only code (build/config-time helpers that use `node:fs`, |
| 23 | `node:path`, `process`, etc.). Typechecked against `@types/node` only. |
| 24 | |
| 25 | `src/internal/workers-shared/index.ts` is the Node-facing barrel (matching the upstream |
| 26 | `packages/workers-shared/index.ts`) and is typechecked under `tsconfig.node.json`. |
| 27 | |
| 28 | ## Provenance |
| 29 | |
| 30 | Sourced from [`cloudflare/workers-sdk`](https://github.com/cloudflare/workers-sdk) |
| 31 | at commit [`f9e7727dbef58e71c6b297dc688d3c544cef87cb`](https://github.com/cloudflare/workers-sdk/commit/f9e7727dbef58e71c6b297dc688d3c544cef87cb) (path: |
| 32 | `packages/workers-shared`). Upstream license: MIT OR Apache-2.0. |
| 33 | |
| 34 | | Upstream path | Vendored path | |
| 35 | | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------- | |
| 36 | | `asset-worker/` | `src/internal/workers-shared/workers/asset-worker/` | |
| 37 | | `router-worker/` | `src/internal/workers-shared/workers/router-worker/` | |
| 38 | | `utils/{constants,types,performance,responses,sentry,tracing}.ts` | `src/internal/workers-shared/shared/` | |
| 39 | | `utils/configuration/{constants,parseHeaders,parseRedirects,parseStaticRouting,validateURL,types}.ts` | `src/internal/workers-shared/shared/configuration/` | |
| 40 | | `utils/tests/parse*.test.ts` | `src/internal/workers-shared/shared/tests/` | |
| 41 | | `utils/helpers.ts` | `src/internal/workers-shared/node/helpers.ts` | |
| 42 | | `utils/configuration/constructConfiguration.ts` | `src/internal/workers-shared/node/configuration/constructConfiguration.ts` | |
| 43 | | `utils/tests/helpers.test.ts` | `src/internal/workers-shared/node/tests/helpers.test.ts` | |
| 44 | | `index.ts` | `src/internal/workers-shared/index.ts` (rewritten paths) | |
| 45 | |
| 46 | ## Consumer imports |
| 47 | |
| 48 | ```ts |
| 49 | // Node-facing barrel (helpers + parsers + types + constants) |
| 50 | import { getContentType, parseHeaders } from "@distilled.cloud/vendor-workers-shared"; |
| 51 | |
| 52 | // Worker entries (default + named re-exports of their local ./src/worker) |
| 53 | import assetWorker from "@distilled.cloud/vendor-workers-shared/workers/asset-worker"; |
| 54 | import routerWorker from "@distilled.cloud/vendor-workers-shared/workers/router-worker"; |
| 55 | |
| 56 | // Any individual module under the package via the wildcard |
| 57 | import { AssetConfig } from "@distilled.cloud/vendor-workers-shared/shared/types"; |
| 58 | import { generateRulesMatcher } from "@distilled.cloud/vendor-workers-shared/workers/asset-worker/src/utils/rules-engine"; |
| 59 | ``` |