The `node16` module resolution requires imports to use the `.js` file
extension in type definitions.
`@rollup/plugin-typescript` is needed to make this work with the Vite
setup used by Mermaid.
The module option for Mermaid internally is set to `nodenext`. This is
needed to support `.json` imports. Note that setting `module` to
`node16` or `nodenext` implies a matching `moduleResolution` value.
* develop:
Add highlight tag info in contributing.md
chore(deps): update dependency cypress to v12
docs: fix links
Fix types
chore(deps): update dependency vite to v4
Cache eslint in `pnpm run lint:fix`.
This was added to the `pnpm run lint` script in
b7f9495 (build: add eslint --cache file, 2022-08-27), but we
didn't add it to `pnpm run lint:fix` due to worries about cache
invalidation.
However, we switched to using `--cache-strategy content` in
b3e509b7 (build(lint): cache eslint with strategy content, 2023-02-05),
which should avoid any caching issues.
Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
Cache eslint using `--cache-strategy content` instead of the default
`--cache-strategy metadata`.
By default, `eslint` uses the file metadata (e.g. modification time)
to detect when the cache should be invalidated.
However, this is not efficient with `git`, since git constantly changes
the modification time,
e.g. running `git switch main && git switch original-branch` would not
change the file contents, but would change the file mtimes and force
eslint to re-lint everything.
Using the file contents is slower (~3% for me), but more resilient.
See
https://eslint.org/docs/latest/use/command-line-interface#--cache-strategy
[Prettier 2.7.0](https://prettier.io/blog/2022/06/14/2.7.0.html) added
a `--cache` CLI option to greatly speed up subsequent prettier runs.
By default, the cache is stored in
`./node_modules/.cache/prettier/.prettier-cache` and uses an `md5`
checksum of the contents as the cache-key.
On my PC, running `pnpm run lint` used to take 13.9 seconds, but now
it only takes 6 seconds.
Potential issues
----------------
Although updating Node.JS/Prettier will invalidate the cache,
updating or changing prettier plugins won't invalidate the cache.
Since we do use `prettier-plugin-jsdoc` in Mermaid, this might cause
a minor issue, but CI should catch it.