2.0.5 • Published 8 years ago

ts-universal v2.0.5

Weekly downloads
7
License
ISC
Repository
github
Last release
8 years ago

ts-universal (gulp plugin)

A simple gulp plugin that makes it possible to use typescript modules painlessly on browser and on server. Say no webpack!

Coding

Features

  • Converts typescript output into a unversal module (1 file)
  • Exposes targets naturaly to window or NodeJS
  • 100% Typescript sourcemaps support
  • Simplicity - 4 variables to configure
  • No extra libraries required!

How it works

tsUniversal works with AMD typescript importer. But instead of having AMD, tsUniversal creates a tiny header that does magic!

Try it now!

Install it

npm install ts-universal --save-dev

Gulp Build example

const gulp = require('gulp');
const rename = require("gulp-rename");
const ts = require('gulp-typescript');
const concat = require('gulp-concat');
const tsUniversal = require("./index.js");
const sourcemaps = require('gulp-sourcemaps');
const tsProject = ts.createProject('example/tsconfig.json', {});
gulp.task('default', function() {
    var toResult = gulp.src('example/**/*.ts')
        .pipe(sourcemaps.init())
        .pipe(tsProject())
    return toResult.js.pipe(tsUniversal('build/', {
        name: 'my-lib-name',
        expose: 'root',
        expose2window: true,
        consume: ["controllers/", "routes/"]
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('build/'));
});

Win

out.js can be required with "root.ts" exposed both to front end and backend!

To test in on server:

node build/test.js

On browser -> just open build/index.html in your browser!

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago