Upgrade from 0.1.0-rc.3
Move a project's imports to the Fetch namespace with the effetch-migrate command.
This page shows how to move a project written for 0.1.0-rc.3 or earlier to
the Fetch export, with the effetch-migrate command.
Before 0.1.0-rc.4, the main entry exported each API by name, and you
imported it with import * as Fetch. Since 0.1.0-rc.4, everything in the
main entry is under one export, Fetch (see
Installation).
Before you begin
Upgrade the project's @monarcode/effetch dependency first. Then run the
commands on this page in the directory of the package that depends on
Effetch. The commands use npx; with pnpm, run pnpm exec effetch-migrate
instead.
Preview the changes
To list the files the migration would change, without changing them, run the following command:
npx -p @monarcode/effetch effetch-migrate --dry-runRun the migration
To change the files, run the following command:
npx -p @monarcode/effetch effetch-migrateThe migration makes these changes:
import * as Fetch from "@monarcode/effetch"becomesimport { Fetch } from "@monarcode/effetch".- Named imports, such as
import { HttpError, type Client }, becomeimport { Fetch }, and each use becomesFetch.HttpErrororFetch.Client. export … from "@monarcode/effetch"re-exports from@monarcode/effetch/Fetch, andimport("@monarcode/effetch").Clienttypes becomeimport("@monarcode/effetch").Fetch.Client.- Code that already imports
Fetchis left as it is.
Choose the files it reads
The migration reads .ts, .tsx, .js and similar files, and uses the
project's own TypeScript. Which files it reads depends on where it runs:
- In a git repository, it reads the files git sees, so it skips what
.gitignoredoes. - Elsewhere, it skips
node_modules,dist,build,coverageand hidden directories, and lists the build output it skipped.
To choose what it reads, pass paths, such as effetch-migrate src test.
Change the rest by hand
The migration lists, with their lines, what it can't rewrite. Change these by hand:
- a dynamic
import(); - a
vi.mock("@monarcode/effetch"); - an import inside a
declare moduleblock; - JSDoc comments that use the old names.
The migration doesn't read Markdown.
Finish the migration
After the migration, run your formatter and type checker.
What's next
- Installation: see the entry points Effetch has now and how to import from them.
- Getting started: write a complete program with
the
Fetchexport.