All guides suggests to install npm
, but I'm searching for a way without it.
There are Angular2 files available, but none of them are TypeScript code.
So what must I do? Do I need Angular2.ts
or specific Angular2-xx.js
and .d.ts
files?
UPDATE: I've downloaded Angular2
through NPM
and gotten the full source tree, in which it's hard to find specific things. Searching for .d.ts
for Angular2
returned no results. A lot of .ts
and .d.ts
files are in the huge collection of code.
In fact, these files are a bundled version of Angular2 and its dependencies. They can be used within an application written with TypeScript. As a matter of fact TypeScript can't be used out of the box into browsers. You must to preprocess them to compile them into ES code with the TypeScript compiler or transpile them in the browser directly with the TypeScript library.
This can be configured within SystemJS directly through its
transpiler
configuration attribute (see below).First simply add these files in your HTML file:
If you want to implement an application without NPM, you can transpile your TypeScript files within the browser.It's way we do when using plunkr. For this you need to configure SystemJS as described below:
Be careful to define your TypeScript files under an
app
folderHere is a simple (and complete) plunkr describing how to do that: https://plnkr.co/edit/vYQPePG4KDoktPoGaxYu?p=info.
You can download the corresponding code and use its code locally with a static HTTP server like
http-server
without using NPM. This could be a good starting point for your use case...Edit
If your TypeScript files are compiled by VS, you need to adapt the SystemJS configuration, as described below:
This way, SystemJS will load your JS files when doing an import. For example:
System.import('app/boot')
will use theapp/boot.js
and not the TypeScript one