Mango Juicy
Explore posts from serversTTCTheo's Typesafe Cult
•Created by Mango Juicy on 10/29/2024 in #questions
Recommended abstract syntax tree for JavaScript/TypeScript
For context, I'm trying to create a Eslint plugin to detect JavaScript runtime compatibility issues.
So I need to keep track of variable types - a bit like how TypeScript keeps track of types.
I find the way Eslint exposes the AST to be quite limiting.
4 replies
TTCTheo's Typesafe Cult
•Created by Mango Juicy on 7/12/2024 in #questions
NPM library best practices?
I was creating my own NPM library, @menglinmaker/soundfont3 but there are so many technical decisions:
- So many bundlers to choose from: esbuild, webpack, rollup, snowpack, tsup...
- Do I bundle to 1 file? Tree-shake?
- So many testing frameworks too: jest, vitest...
- So many eslint plugins.
- How do I even test if ESM and CJS imported correctly?
Attempt:
I decided to take inspiration from a few GitHub repos like vuejs/core, solidjs/solid, mrdoob/three.js.
This is what I pickup up on:
- Use script "preinstall" to force the use of "pnpm" for development. Very opinionated decision, but improves consistency with setup and CI.
- Use script "postinstall" to ensure git hooks are installed.
- Lint and format at least every pre-commit.
- Use "eslint-plugin-compat" to detect browser compatibility issues for web apis.
Areas for improvement in JS ecosystem:
- Lack of runtime compatibility linting - does api exist on Node, Deno, Bun, Cloudflare worker...?
TLDR:
Mostly unsure what bundler + config and testing library to use.
Eg: Apparently it's possible to unit test on a browser?
Boilerplate repo:
https://github.com/MengLinMaker/npm-library-boilerplate
11 replies