Readworthy: No bundler? Crud JSON. Publish NPM.
Readworthy is misc bits of information I found usefull since last time.
You may not need a bundler
“I have seen a couple threads on twitter where people complain about the difficulty with publishing NPM libraries or ask what starter kit they should use (or, people recommended starter packs anyways) Example threads: here here here and here One thing that is notable to me in these threads is that people often recommend that you use a bundler (a program that combines multiple src files into a single or fewer output files) when developing a library”
Do a CRUD with regular JSON
A Simple and plain file-based JSON database for Node
Install npm i @beforesemicolon/node-json-db
Watch on Youtube
The npm package:
[node-json-lib](https://www.npmjs.com/package/@beforesemicolon/node-json-db)
How to publish your typescript repo to npm
From the begining.
- Name your package to the name that will be used on NPM. If your name is not original enough or you just want to group your uploaded packages over time add a namespace
@myNamespace/[package name here]
- Add a license (MIT)
- Add typescript as a dev dependency
pnpm add -D typescript
- Add a index.ts file
- Run
pnpm tsc --init
- To tighten up some rules and use typescript as a linter, in tsconfig.json add
"noUncheckedIndexedAccess": true","noEmit": "true"
- Run
git init
- Add
node_modules/
anddist/
to the git ignore file - Add tsup with
pnpm add -D tsup
which bundles your files for you, turning typescript files into js files. - In package.json / scripts add
"build": "tsup src/index.ts --format cjs,esm --dts"
(‘cjs’ if you want common-js support) - test run with
pnpm run build
- In package.json add
"main": "dist/index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts"
, - Add a lint script in
"scripts": { ... "lint": "tsc", ...}
- To make versioning easier add chsangesets cli:
pnpm add -D @changesets/cli
- Run
pnpm changeset init
- It wil add a folder called changesets
- Add an initial version number to your package in package.json.
- Every time you want add a change you could add a changeset through
pnpm changeset
wich creates a markdown file that describes what change you’ve done. When you publish later it will merge those into a full changeset. - Create a login at https://npmjs.org and login with
npm login
- publish with
npm publish --access public
This is part one. Next I’ll update with added github action worklflow. Soon, stay put.
Source Publishing to npm
How to Create a Scoped NPM Package
To create a scoped package, first navigate to the root of your package directory.
Then, run the npm init command and pass your username as the value to the scope flag:
npm init --scope=@your-username
Respond to the prompts to create a package.json file. For your package name, the format should be @your-username/package-name.
For example @foundit/broadcaster.
You can now add the code for your package and test it. The process is the same as already explained above.
Two links with all artist to be inspired body
- Why Lit Element is not as good as React
- Epic list midjourney promts
- The event bubbling model (capture/bubble) visualized
- Create fotorealistic images with chatGPT for prompt writing
That’s it for today.