Skip to content

fix(ts-empty): drop unused @crawlee/cheerio dependency#832

Draft
DaveHanns wants to merge 1 commit into
masterfrom
fix/ts-empty-drop-unused-crawlee-dep
Draft

fix(ts-empty): drop unused @crawlee/cheerio dependency#832
DaveHanns wants to merge 1 commit into
masterfrom
fix/ts-empty-drop-unused-crawlee-dep

Conversation

@DaveHanns

Copy link
Copy Markdown
Contributor

Summary

The ts-empty template lists @crawlee/cheerio in dependencies even though the template's src/main.ts doesn't actually import anything from Crawlee — the only reference is a commented-out line:

// import { CheerioCrawler } from '@crawlee/cheerio';

This PR drops the unused dep, removes the commented-out Crawlee/routes.js imports from src/main.ts, and rewords the README so it doesn't advertise Crawlee as an included feature. Users who actually want a Crawlee-based starter already have the parallel ts-crawlee-cheerio template — the README now points there.

Why

Carrying the unused dep has a few concrete downsides:

  1. Install footprint. Scaffolding ts-empty currently pulls in Crawlee + its transitive deps (~190 packages) for a project that only does Actor.init() / log.info / Actor.exit().
  2. apify run behavior. The CLI treats the project as a Crawlee project based on the presence of @crawlee/* in dependencies and applies the default --purge behavior, which is surprising for an "empty" template with no crawler state to purge.
  3. Signals confusion to code assistants. LLM-based tooling that reads package.json to decide "does this project use Crawlee?" answers "yes" and then generates new CheerioCrawler({ router }) snippets against an API that no longer matches the version pin — producing errors from a supposedly empty starter. The commented // import { CheerioCrawler } line in src/main.ts reinforces the same wrong signal.

The two-line "if you'd like to use Crawlee, uncomment this import" instruction in the current README hasn't kept up with Crawlee's evolution (@crawlee/cheerio alone isn't enough for a working crawler anymore) and duplicates what ts-crawlee-cheerio already provides in a first-class way.

Evidence

Current templates/ts-empty/package.json (before this PR):

"dependencies": {
    "apify": "^3.7.0",
    "@crawlee/cheerio": "^3.15.3"
},

Current templates/ts-empty/src/main.ts (before this PR):

// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/)
import { Actor, log } from 'apify';
// Crawlee - web scraping and browser automation library (Read more at https://crawlee.dev)
// import { CheerioCrawler } from '@crawlee/cheerio';

// this is ESM project, and as such, it requires you to specify extensions in your relative imports
// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
// note that we need to use `.js` even when inside TS files
// import { router } from './routes.js';

// The init() call configures the Actor ...
await Actor.init();

log.info('Hello from the Actor!');
/**
 * Actor code
 */

// Gracefully exit the Actor process. It's recommended to quit all Actors with an exit()
await Actor.exit();

Nothing in the file references either CheerioCrawler or router.

Changes

  • templates/ts-empty/package.json — remove @crawlee/cheerio from dependencies (leaves only apify).
  • templates/ts-empty/src/main.ts — remove the commented Crawlee import and the commented routes.js import.
  • templates/ts-empty/README.md — drop the Crawlee "included feature" bullet, remove the "uncomment this import" hint, and add a one-liner pointing at ts-crawlee-cheerio for the scraping use case.

Notes

  • js-empty has the same shape (unused @crawlee/cheerio, same commented import in src/main.js). Not touched here so this PR stays atomic and reviewable; happy to open a follow-up if the same fix is wanted there.
  • templates/manifest.json already describes ts-empty as "Empty template with basic structure for the Actor with Apify SDK ..." with technologies: ["nodejs"] and no mention of Crawlee, so no manifest change is needed.

Test plan

  • apify create foo -t ts-empty — verify the resulting project installs only apify + transitive deps (no @crawlee/* in node_modules).
  • apify run in the scaffolded ts-empty project does not treat it as a Crawlee project.
  • apify create bar -t ts-crawlee-cheerio still installs Crawlee and runs the sample crawler unchanged.
  • Existing repo tests (npm test) still pass.

Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

The ts-empty template ships `@crawlee/cheerio` in `dependencies` even
though the template's `src/main.ts` imports nothing from Crawlee — the
sole reference is a commented-out `// import { CheerioCrawler } ...`
line. This has a few unwanted side effects for users of the template
and for tooling that inspects the generated project:

- ~190 packages get installed for a stub Actor that should install just
  `apify` and its transitive deps.
- `apify run` classifies the project as a Crawlee project based on the
  presence of the dep and applies the default `--purge` behavior, which
  is surprising for an empty template that has no crawler state to
  purge.
- Code assistants / LLMs reading the manifest see the dep and reach
  for Crawlee APIs (e.g. `new CheerioCrawler({ router })`), which then
  fail against the currently installed Crawlee major version and
  produce confusing errors from an "empty" starter.

The parallel `ts-crawlee-cheerio` template already exists as the
canonical starting point for users who want a Crawlee-based scraper,
so this change simply drops the unused dep from `ts-empty`, cleans up
the commented Crawlee/`routes.js` imports in `src/main.ts`, and points
the README at `ts-crawlee-cheerio` for the scraping use case.

Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@DaveHanns DaveHanns requested a review from l2ysho as a code owner July 4, 2026 22:52
@DaveHanns DaveHanns marked this pull request as draft July 5, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants