Skip to content

Ronin11/IncrementalGameLib

Repository files navigation

Typescript lib starter

Build Status Standard Version

based on https://github.com/elboman/typescript-lib-example and http://marcobotto.com/compiling-and-bundling-typescript-libraries-with-webpack/

  • proper package.json file references for build
  • compiles esm-lib to vanilla es2015 instead just es2015 modules
  • compiles types to typings folder instead of multiple distribution
  • umd is shiped under umd folder instead of _bundles

Consumption of published library:

library is shiped in 3 formats:

  • raw es2015 module and code format ( ideal for tree shaking with Webpack 2 )
  • CommonJS format for bundler consumption
  • UMD format for usage withou bundler

Webpack

// main.ts
import {Greeter} from 'my-lib';

const mountPoint = document.getElementById('app');
const App = () => {
  const greeter = new Greeter('Stranger');
  return `<h1>${greeter.greet()}</h1>`
}
const render = (Root: Function, where: HTMLElement) => {
  where.innerHTML = Root();
}

render(App, mountPoint);
<html>
  <head>
    <script src="bundle.js" async></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

UMD ( no bundler )

<html>
  <head>
    <script src="node_modules/my-lib/umd/my-lib.min.js"></script>
    <script async>
        var Greeter = MyLib.Greeter;

        var App = function() {
          var greeter = new Greeter('Stranger');
          return '<h1>'+greeter.greet()+'</h1>'
        }
        var render = function(Root, where) {
          where.innerHTML = Root();
        }

        render(App, mountPoint);
    </script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

Release

yarn release

Initial Release (without bumping package.json version):

yarn release -- --first-release

Check what files gonna be published to npm

  • CLI output via yarn release:preflight
  • or yarn release:preflight:package will create tarball which you can check

Check size of your published NPM bundle

run yarn build then npm run size

Format and fix lint errors

yarn ts:style:fix

Commit ( via commitizen )

yarn commit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published