DEV Community

Discussion on: A Nice TypeScript Buildchain

Collapse
caseywebb profile image
Casey Webb • Edited

You could also just add es2015 to tsconfig -> compilerOptions -> lib and set module as mentioned elsewhere in the comments. lib tells tsc "Hey, I know I'm compiling to ES5, but you can count on an ES2015 polyfill." You could restrict the scope further with just es2015.promise, which would tell it that a Promise constructor will be available at runtime.

If you're explicit, you end up with lib being the exact list of polyfills that will be required.

Collapse
caseywebb profile image
Casey Webb

It's also worth mentioning, in this setup, you could add your gulp command to the package.json scripts, and then no one needs to know about npx as npm will add ./node_modules/.bin to the path for anything executed with npm run.

e.g.

{
  "scripts": {
    "build": "gulp"
  },
  "devDependencies": {
    "gulp": "..."
  }
}

You'd then be able to run gulp with npm run build or yarn build.

I like using package.json scripts, because it's self-documenting in terms of all of the available build commands.