1
votes

I'm trying to create a new TypeScript project.

I'd like it to be as straightforward and lightweight as possible without any unnecessarily complex configurations, while meeting these requirements:

-Using npm

-Using TypeScript

-Using import statements, e.g.

import { A, B } from 'module';

-Bundle all dependencies from node_modules that were imported using import statements into /build for production

-Compile project source into a single outFile and put it in /build

-Load dependencies at runtime according to imports made using import statements

-Using SystemJS, since I understood it's in the process of becoming the standard module loader

So far I created a new project:

-Used npm - installed a framework and its typings for TypeScript

-Compiling using tsc (tsconfig.json) via Visual Studio Code

-tsconfig.json "module": "system" (SystemJS)

-I can write import statements (since module is set to "system")

-tsconfig.json "outFile": "../build/app.js" - compiles project source into a single outFile and puts it in "build" dir

What I'm missing is:

-Bundle all dependencies from node_modules that were imported using import statements into /build for production

-Load dependencies at runtime according to imports made using import statements

I don't have any experience with setting up and configuring module loaders.

Could you please help point me in the right direction?

Searching any of these subjects brings up results and npm modules I could use, but things can get too complex too fast and it'll take me too much time playing around to understand what I'm doing and what needs to be done, so any advice from someone who knows how to best approach this would be much appreciated.

1

1 Answers

0
votes

I think both your problems can be solved by using jspm. It is using systemjs as module loader and takes away from you the burden of configuring and maintaining all packages paths, extensions, etc that are required by systemjs configuration.

Specifically answering your question:

  1. jspm will keep all your client dependencies in one separate folder (jspm_packages) therefore in order to prepare your dependencies for deploy all you need to do is copy this folder to the target location.
  2. jspm will produce config.js for you containing all configuration of all used (including nested) packages

Start off with this user guide - it is very clear and will allow you to configure jspm in no time.