Skip to content

Installation

Your Scrapers live in a repository of your own. Install the SDKs from npm and set up the workspace.

Two repositories work together:

RepositoryHoldsYou use it to
The Scwrap repositoryThe instance's Stack, the SDKs, the scwrap CLI and two example ScrapersInstall and upgrade your instance (Setting up a new instance) and release the SDKs to npm.
Your Scraper repositoryYour Scraper packages and their ReleasesWrite, test and deploy your Scrapers to the instance.

This guide sets up the second one. The rest of Getting Started builds the quotes Scraper inside it.

Requirements ​

ToolVersion
Node.js>=24.18.0
pnpm11.3.0

Do not install with npm or Bun. The workspace relies on pnpm's settings and exact pins.

Get the SDKs ​

The SDKs are published on npm under the @scwrap scope, each with a provenance statement that ties it to the Scwrap repository's Publish SDKs workflow.

PackageJob
@scwrap/domainDefinitions, Scraper.layer, Scraper.run, Shared errors, HTTP helpers, the Capability ports, and the test kit at @scwrap/domain/testing.
@scwrap/browserThe Browser providers: Cloudflare Browser Run, Browser Use and a local Chromium.
@scwrap/deployDeployment.worker and the scwrap CLI.
@scwrap/clientThe typed instance client.
@scwrap/platform-apifyApify Proxy, for Workers and for Node.
@scwrap/captcha-templatesThe local template captcha solver.
@scwrap/ai-cloudflareWorkers AI through AI Gateway.

All are MIT-licensed. Depend on each with an exact version, the one your instance runs; pnpm view @scwrap/domain version shows the newest on npm. The examples in this guide use 0.5.0.

IMPORTANT

The SDKs and the instance share exactly one effect, 4.2.0. Every artifact records the SDK version and the Effect version it was built with; the instance accepts only its own Effect version, and its own SDK version or the one before it (How Releases are built). When an upgrade of your instance changes either, move your SDK dependencies to the versions it runs.

The workspace file ​

The workspace file lists the packages and pins two dependencies the SDKs do not pin for you.

Example (pnpm-workspace.yaml)

yaml
packages:
  - "packages/*"
  - "releases"

allowBuilds:
  esbuild: true

overrides:
  "@effect/platform-node-shared": "4.2.0"
  "playwright-core": "1.65.2"

minimumReleaseAgeExclude:
  - "@scwrap/*"

Why the less obvious lines are there:

SettingReason
allowBuilds: esbuildThe scwrap CLI bundles Releases with esbuild, which installs its binary in a build script.
minimumReleaseAgeExcludepnpm installs a version only once it is a day old. Excluding the @scwrap scope lets you move to an SDK release on the day it is published, whatever its version.
@effect/platform-node-shared, playwright-core@effect/platform-node asks for @effect/platform-node-shared ^4.2.0, which would otherwise resolve to a version newer than the instance's effect. @cloudflare/playwright accepts any playwright-core; the override keeps the 1.65.2 that @scwrap/browser pins.

The root package.json ​

The root package holds the tools every package shares and the scwrap script.

Example (the relevant parts of package.json)

json
{
  "private": true,
  "type": "module",
  "scripts": {
    "prepare": "effect-tsgo patch",
    "scwrap": "SCWRAP_CATALOG=\"${SCWRAP_CATALOG:-releases/src/catalog.ts}\" scwrap"
  },
  "devDependencies": {
    "@effect/tsgo": "0.74.1",
    "@scwrap/deploy": "0.5.0",
    "effect": "4.2.0",
    "typescript": "7.0.2"
  }
}
  • prepare patches TypeScript with the Effect language service, so Effect mistakes such as a missing Capability fail tsc.
  • pnpm scwrap runs the scwrap CLI with your catalog as the default.
  • effect is exactly 4.2.0. In the SDK packages effect is an exact peer dependency, and scwrap deploy refuses to build against any other version:
text
Releases build against effect 4.2.1, but the instance shares effect 4.2.0. Install effect 4.2.0 exactly.

Copy tsconfig.base.json from the Scwrap repository to your repository's root. It turns the Effect language service diagnostics into errors.

Then install:

sh
pnpm install

The layout ​

text
your-scrapers/
  package.json          the tools and the scwrap script
  pnpm-workspace.yaml   the workspace packages and pins
  tsconfig.base.json    copied from the Scwrap repository
  packages/
    quotes/             one package per Scraper
      package.json      exports "." and "./schema"
      tsconfig.json
      tsconfig.build.json
      vitest.config.ts
      src/
        quote.ts        input and output schemas
        definition.ts   the Definition
        api.ts          an Implementation
        index.ts        public exports
      test/
        acceptance.test.ts
  releases/
    package.json        name releases, depends on @scwrap/deploy and every Scraper it releases
    tsconfig.json
    src/
      quotes.ts         one module per Release
      catalog.ts        the array of Releases

Each Scraper owns one package. Its package depends on the SDKs by exact version and on "effect": "4.2.0". A Scraper package never imports the deployment SDK, so the same Scraper runs in a test, a script or an instance.

The releases package holds one module per Release and the catalog, whose default export is the array of Releases that scwrap deploy reads. Release modules are .ts files that Node loads with type stripping, so releases/tsconfig.json allows .ts imports. Copy it from the Scwrap repository's apps/infra/tsconfig.json:

json
{
  "extends": "../tsconfig.base.json",
  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "lib": ["ES2023", "DOM"],
    "module": "Preserve",
    "moduleResolution": "Bundler",
    "target": "ESNext"
  },
  "include": ["src/**/*.ts"]
}

Commands you will use ​

CommandPurpose
pnpm --filter <package> testRun one package's tests.
pnpm --filter <package> buildBuild one package into dist/.
pnpm --filter '{./releases}^...' buildBuild every Scraper package the Releases import.
pnpm scwrapThe deployment CLI for your instance.

Tests use fake HTTP clients and a local Chromium. They need no cloud credentials.

Next ​

Your first Scraper creates the quotes package.