Skip to content

A minimal Typescript setup to "npm install" modules painlessly

Notifications You must be signed in to change notification settings

mleg/typescript-npm-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typescript setup to use npm modules

As minimal as possible Webpack / Typescript setup to use npm modules in the browser with npm install
Made in October 2017, don't forget to upgrade the dependencies. There are just a few of them.

Story

I needed some simple setup to use RxJS 5 with Typescript. And wanted to add rxjs with just npm install -- what an innocent wish after all!
As a novice typescripter and webpacker I tried hard to find such a thing on the Web, ready to use. With no luck.
I hope you won't repeat my struggle and will come across this repo.

Features

  • When you want to add a library to your project just yarn add it (or npm install if you're so conservative). Everything should work as expected;
  • Minimal configs, few lines each;
  • Minimal dependencies. Thus are typescript itself, webpack, ts-loader and tslint. RxJS is just for example, remove it.
  • Development only. For production use you need to tweak setup further. At least you'll probably want to minify your build and get rid of source maps.
  • Example of rxjs partial imports (for smaller builds)
  • It's for frontend apps (things are much simpler on the Node side);
  • Based on vanilla example from examples folder of the ts-loader repo. Thanks guys both for the tool and the examples!

PS

  1. Don't be afraid of Webpack as I was, it's simple for such basic scenarios. The docs are really good and beginner friendly.
  2. If you use VS Code, you may not need a development server to finish up this setup. The excellent Live Server extension does the job. Just start from index.html. Zero configuration, hot reloading included.
  3. Being scared by stories of post-webpack stress disorder I first tried to avoid Webpack and go with Typescript only. But it is nowhere close to simple, I abandoned the effort.

About

A minimal Typescript setup to "npm install" modules painlessly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published