0.2.0 • Published 3 years ago

@kubric/creative-renderer v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

jslib-scaffolding

Scaffoling for setting up an open source libarary with the following stack

  • code in JS/TypeScript
  • Build with Rollup
  • Test with Jest
  • Publish to npm with CircleCI

For the discussion below, assume that the code resides in the src folder and the entry point is index.ts/index.ts.

package.json

  • Change the following fields name, version, description, repository, author, license, bugs.url and homepage as required
  • Change/remove main as per requirement.
  • Change/remove module as per requirement.
  • Change/remove browser as per requirement.
  • Run npm install
  • Add additional packages required by the library

Typescript

  • types in package.json should point to the types declaration file generated for the library.
  • Write code in index.ts in src folder
  • Change the tsconfig.json file as required
  • Change all input in rollup.config.js to src/index.ts

JavaScipt

  • Remove types and packages related to TypeScript from devDependencies in package.json
  • Remove tsconfig.json
  • Remove the entry @babel/preset-typescript from .babelrc
  • Write code in index.ts in src folder
  • Remove import typescript from 'rollup-plugin-typescript'; in rollup.config.js
  • Remove typescript() call from plugins in rollup.config.js
  • Change all input in rollup.config.js to src/index.ts

If you have other rollup built libraries as dependencies, and you use some named exports from those libraries, these imports will have to be explicitly declared in your rollup.config.js as named exports. If these dependencies are peer dependencies, you can mark them as external in your rollup.config.js and avoid having to declare all named imports.

Build

npm run build will build the library

Tests

  • Write your tests in the tests directory as files ending in .test.js
  • Change the Jest config as required in jest.config.js
  • npm test will run the tests and print the results

Publish

  • Login into Circle CI and follow the github project where the library resides
  • Change the node version in .circleci/config.yml if required
  • Do npm login in local and extract the auth token from ${HOME}/.npmrc
  • The token can be configured in 2 ways
    • In the Circle CI organization settings, create a context named npm and add and environment variable named npm_TOKEN with the copied auth token as it's value. This is the default approach configured in .circleci/config.yml.
    • Otherwise, create an environment variable npm_TOKEN in Circle CI under project settings and paste the copied auth token as it's value. Afterwards, delete the line context: npm(line 68) from .circleci/config.yml

Once all the above steps have been completed and the library is ready, commit to github.

  • The tests will be run in CircleCI for every branch and tag
  • Publish to npm will happen whenever a commit is tagged with v${versionNumber}.

Before tagging a commit for publish, make sure that the correct version number is updated in package.json

0.1.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago