Hi! I trying to create my own npm package for BabylonJS.
Could give advice how to improve my package and which potential problems does it have now?
Firstly I worrie about dependencies description in the package.json, is it correct? Should I add @babylonjs/core into usual dependency or devDependency?
These is always a never-ending list of improvements. And no one gets it perfect ever
Just a few things from looking at the code a few minutes:
You should tell npm which files to publish using the “files” key in package.json. Otherwise only the index.js file will be deployed.
Babylon should be a dev dependency AND a peerr dependency. Now - the dev dependency can have a fixed version, but the peer dependency is the one defining what version of babylon will work with this plugin. The more generalized you make it, the more people will be able to use it. Are you using features that were introduced in 5.20.0? then this is the minimum version that you support. Maybe > 5.0.0 works? You should check that
You should build both cjs and mjs (commonjs and esm as module output).
You should include the build scripts in package.json. I assume you use typescript?
when importing from @babylonjs/core import from the right file and not from the main directory to improve tree-shaking (the first line in AttachNodeToScroll.ts
Document your API, so people importing it will see the codedoc.
IMO - you don’t need to commit the dist folder. The dist folder will be included when pushing it to npm, but github is not for dists. Some will argue that it is a good thing (there are advantages), this is more of a personal opinion.