gfmio/TypeScript

Forked from microsoft/TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

http://www.typescriptlang.org

License: Apache-2.0

Language: TypeScript


Build Status VSTS Build Status npm version Downloads

TypeScript

Patched version of TypeScript to support MJS file emission.

Install the ts-mjs package as a devDependency with yarn add -D ts-mjs or npm install --save-dev ts-mjs.

Everything stays the same, but you can now call the patched version of tsc as tsc-mjs and if you can add the compiler option --mjs to emit .mjs files instead of .js files.

These are required for NodeJS to correctly identify MJS modules as such.

If you use the --sourceMap compiler option, this will also emit the corresponding .mjs.map source map for your .mjs file.

If the output target for JSX would be preserve via one of the compiler options, regular JSX code with the regular extension .jsx will be emitted.

For example, if you run

tsc --sourceMap --declaration --target es3 --module commonjs index.ts

this will emit

index.d.ts (the declaration file)
index.js (the CommonJS ES3 module)
index.js.map (the source map for the CommonJS module)

If you run

tsc-mjs --sourceMap --declaration --target esnext --module esnext --mjs index.ts
index.d.ts (the declaration file)
index.mjs (the ES module)
index.mjs.map (the source map for the ES module)

The declaration files that are generated will be identical in both cases.

You can use this to publish hybrid modules by running both commands in succession (or in parallel, since they won't interfere with each other). The output will be:

index.d.ts (the declaration file)
index.js (the CommonJS ES3 module)
index.js.map (the source map for the CommonJS module)
index.mjs (the ES module)
index.mjs.map (the source map for the ES module)

If you have other source files, the corresponding 5 files will be generated for them.

If someone enters your package now via an .mjs file, node will automatically search for .mjs file in all import (or require) statements (and it will fall back to .js should an .mjs file not exist).

In your package.json, you can make the main field "dynamic" by removing the extension of the linked file.

{
    "main": "index",
    "browser": "index.js",
    "module": "index.mjs",
    "types": "index.d.ts"
}

For a real-life example of this being in use, check out my hsluv-ts library (Github, NPM).


Join the chat at https://gitter.im/Microsoft/TypeScript

TypeScript is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the playground, and stay up to date via our blog and Twitter account.

Installing

For the latest stable version:

npm install -g typescript

For our nightly builds:

npm install -g typescript@next

Contribute

There are many ways to contribute to TypeScript.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Building

In order to build the TypeScript compiler, ensure that you have Git and Node.js installed.

Clone a copy of the repo:

git clone https://github.com/Microsoft/TypeScript.git

Change to the TypeScript directory:

cd TypeScript

Install Jake tools and dev dependencies:

npm install -g jake
npm install

Use one of the following to build and test:

jake local            # Build the compiler into built/local 
jake clean            # Delete the built compiler 
jake LKG              # Replace the last known good with the built one.
                      # Bootstrapping step to be executed when the built compiler reaches a stable state.
jake tests            # Build the test infrastructure using the built compiler. 
jake runtests         # Run tests using the built compiler and test infrastructure. 
                      # You can override the host or specify a test for this command. 
                      # Use host=<hostName> or tests=<testPath>. 
jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional
                        parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.
jake baseline-accept  # This replaces the baseline test results with the results obtained from jake runtests.
jake lint             # Runs tslint on the TypeScript source.
jake help             # List the above commands. 

Usage

node built/local/tsc.js hello.ts

Roadmap

For details on our planned features and future direction please refer to our roadmap.

Project Statistics

Sourcerank 6
Repository Size 736 MB
Stars 1
Forks 0
Watchers 1
Open issues disabled
Dependencies 788
Tags 96
Created
Last updated
Last pushed

Packages Referencing this Repo

ts-mjs
TypeScript is a language for application scale JavaScript development
Latest release 3.1.0 - Published - 1 stars

Recent Tags See all

v3.0.1 July 25, 2018
v3.0-rc July 12, 2018
v3.0-rc July 12, 2018
v3.0.0 July 06, 2018
v2.9.2 June 12, 2018
v2.9.1 May 25, 2018
v2.8.4 May 15, 2018
v2.8.4 May 15, 2018
v2.9-rc May 14, 2018
v2.9.0 May 14, 2018
v2.8.3 April 19, 2018
v2.8.2 April 03, 2018
v2.8.2 April 03, 2018
v2.8.1 March 23, 2018
v2.8-rc March 13, 2018

Something wrong with this page? Make a suggestion

Last synced: 2019-05-25 07:15:22 UTC

Login to resync this repository