git clone git@github.com:Siilwyn/code-class-js-packaging.git
cd code-class-js-packaging
- Add information about the minimum Node.js version of 13 to
package.json
. Try it out with Node.js 12 through npm and Yarn using astart
script inpackage.json
that runsnode ./run.js
. - Run
npm install
andyarn install
, you'll see two modules in your lock files figure out wherefsevents
comes from usingnpm
andyarn
commands. - Add a
build
script to run therollup
binary located innode_modules
with npm using the arguments:./src/main.js --format cjs --file ./dist.js
.
- Package it with
npm pack
! Check the included files, try to influence this with configuration inpackage.json
so only the needed files are packed. - Use Rollup to create a
main.cjs
file and combine withexports
so the package exposes both CommonJS and ECMAScript interfaces. Bonus: Try it out in Node.js 12 and 13 using the JSrun
files. - Show it to the world with
npm version
andnpm publish
! Don't forget to change the package name and you might need tonpm login
. View it through the CLI withnpm view
. npm unpublish --force
Install Yarn Berry and run yarn install
, look into why node ./src/main.js
doesn't work but yarn start
does though it is supposed to behave like this.
To get the solution for an exercise apply the solution patch file, for example for the first exercise:
git apply exercise-1/solution.patch