Declare the library you read
Setlibrary to the npm package your plugin reads and the semver range you wrote it against.
Handle breaking majors
When two majors of a library use the same name for different things, the plugin can’t tell from the code alone which one it is reading. It can tell from the file’s package, though. When the narrator has a dependency index,e.libraryMajor("effect") returns the major version the nearest package.json declares, for example 3 for "^3.10.0".
Plugins whose libraries changed meaning also take a version option, which wins over the package:
version, then the package’s declared major, then auto.
Here is the same Effect schema read with each setting. In Effect 3,
Schema.Date decodes a date from a string. In Effect 4 it is a date value.
Effect 3
English
Effect 4
English
Effect.catch is another example. In Effect 4 it catches every failure. In Effect 3 it takes a discriminator and catches one kind of failure. Pinning to one major also drops the other major’s names entirely, so a v3-only API in a v4 codebase is narrated generically instead of being explained with the wrong meaning.
Writing a versioned plugin
Resolve the version inside your rules, because the engine only knows the file’s package once narration starts:version: 3, version: 4 and no version, and assert each output. The Elysia tests do the same with versions 1 and 2.