Import Renaming¶
When your readme imports your own package by name, readme-assert rewrites the import to point to your local source code.
How It Works¶
readme-assert reads the name field from the nearest package.json.
When it finds an import or require of that name in a code block, it
replaces it with the resolved local path.
Given a package.json:
And a readme code block:
The import is rewritten to:
Sub-path Imports¶
Sub-path imports are also rewritten:
import { helper } from "my-package/utils";
// becomes:
import { helper } from "/absolute/path/to/utils";
CJS require()¶
CommonJS require() calls are rewritten too:
Overriding with --main¶
Use --main to point to a different entry point: