7 hours ago · Tech · hide · 0 comments

Getting a package published on npm has long been a mystery to me. There are too many little details that have to be just right, and I was confused about what the end product was even supposed to be. Vite really gave me the push that I needed to bring it all together. It offers a “library” mode, which handles some of the tricky bits behind the scenes. I think this is where I had given up in the past. It bundles the code and outputs it in two formats, which is good for compatibility. Next, a key part is adding "type": "module" to the package.json file. This is a signal to Node.js to use the files you’ve created as a module, and allow those who’ve installed your package to import it in that way. For the Alexander package that I published, here’s the new entries in package.json that I made, including the type. This also shows the two formats that have been output, and I’ve included files here so that it will install both the dist and scss folder when someone adds it to their project (the…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.