npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-webpack-typescript-pipeline

v17.0.1

Published

easy transpiling and bundling of typescript back to es5

Downloads

237

Readme

Easy transpiling of typescript back to browser friendly es5

Wraps together:

  • webpack
  • typescript
  • gulp
  • eslint for typescript

in one simple to use build pipeline. Your seperate typescript files are downcompiled and bundled together, leaving you a nice simple bundle to use in your browser

setting up

  • install node > v4 + npm (note: node v8 is preferred)
  • npm init your project in a folder npm init
  • install global gulp npm install -g gulp
  • add gulp package npm install gulp --save-dev
  • add this package npm install gulp-webpack-typescript-pipeline --save-dev
  • create a file called gulpfile.js in your projects root folder
  • create a tsconfig.json in your projects root folder and fill in your typescript options
  • in your gulpfile add the following:
const gulp = require('gulp');
const tsPipeline = require('gulp-webpack-typescript-pipeline');

tsPipeline.registerBuildGulpTasks(
  gulp,
  {
    entryPoints: {
      'BUNDLE_NAME': 'PATH_TO_ENTRY_POINT'
    },
    outputDir: 'PATH_TO_BUNDLE_OUTPUT_DIRECTORY'
  }
);

Your entrypoints are the first javascript files you want to enter. Webpack will follow all the imports and requires to build you a final bundle. Your bundles will be made in the output directory and called [BUNDLE_NAME].

e.g:

given a tsconfig.json in the project root folder that contains:

{
  "compilerOptions": {
    "target": "es5",
    "module": "esnext",
    "sourceMap": true
  }
}

and a gulp file that contains:

const gulp = require('gulp');
const tsPipeline = require('gulp-webpack-typescript-pipeline');

tsPipeline.registerBuildGulpTasks(
  gulp,
  {
    entryPoints: {
      'myNiceBundle': __dirname + '/scripts/myentrypoint.ts'
    },
    outputDir: __dirname + '/bundles'
  }
);

Then running gulp tsPipeline:build:dev Will result in a bundle called myNiceBundle.js in /bundles under the root of your project

gulp commands

You now have the following commands:

  • gulp tsPipeline:build:dev - build all the files in dev mode
  • gulp tsPipeline:build:release - build all the files in minified release mode
  • gulp tsPipeline:watch - rebuilds whenever a file is changed

features

  • linting (tslint)
  • typescript (ts -> es6)
  • webpack (bundling)

and then dump out the bundles.

options

{
  entryPoints, // required,  an array of bundlename to entrypoint location mappings,
  outputDir, // required,  where the resulting bundles get written,
  esLintFile, // optional, full path to your .eslintrc.js file
  isNodeLibrary // if set to true will output code suitable to be consumed by node rather than the browser
  externals, the packages to not include in the compiled output
}

questions

but I dont want to use typescript, I want to use normal es6

That's cool, feel free to use gulp-webpack-es6-pipeline to do the same thing for normal es6.

using custom linting rules

If you don't like the built in linting rules you can override them in one of two ways:

  • put a .eslintrc.js file in the root of your project
  • set the esLintFile setting in the options (see options above)

I don't like the defaults and want to set X

Also fine, feel free to use this as a reference for setting up your own build pipeline. This project is really for people who want a fast opinionated setup.