Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am converting a project from ES6 to Typescript. The TSConfig file sets the following options:

{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "out": "qqq.js",
        "allowJs": true,
}

In my code, I import NPM modules living in node_modules. This was also what I did prior to using Typescript.

import React from 'react'; // This is an NPM module.
// . . .

Running the typescript compiler produces an almost usable *.js bundle, but it is missing all of the NPM modules.

How can I configure Typescript to include all of my NPM dependencies (not just local files) when building a System.js bundle?

share|improve this question
    
I don't think this is supported yet when you use modules. I usually compile them to CommonJS for Node and then use Browserify to bundle them into one file for the browser. – Luka Jacobowitz Feb 3 at 14:19
up vote 1 down vote accepted

You have to create your deployment bundle yourself. The two helpfull samples for you to have a look at are:

Angular2 Seed

This one is great place to start looking for the solution. Dot not bother that it is for angular2. It still does exactly what you are looking for - compile TS files and prepare bundle with all referenced node_modules included.

If you would like to try bundle creation with webpack, you are welcome to checkout this identical sample:

WebPack angular2 starter

Hope this helps.

share|improve this answer

TypeScript won't bundle NPM dependencies for you, you'll need to use something like SystemJS Builder for bundling.

share|improve this answer
    
My question was related to SystemJS. I have not heard of Webpack being used in conjunction with SystemJS (I was under the impression that they were competing solutions). Could you please explain how this would work in relation to SystemJS? – Rick Feb 3 at 15:32
    
You're right, I was under the mistaken impression Webpack could handle anything, but for SystemJS you'd presumably use the SystemJS Builder to bundle your modules. – Vadim Macagon Feb 3 at 16:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.