0
votes

All:

I wonder if anyone could give me a simple comparison of development flow between CommonJS, Typescript and ES6 with perspective to Module import system( like require(), import "xx", export ), compiler( babel, tsc ) and how to use in Browser(browserify or what?)?

There are a lot of similarity which confuse me so much, especialy when I need to mix them!

Thanks

1
This is a bit too broad to be answered here. This article seems to have a pretty good explanation. exploringjs.com/es6/ch_modules.htmltoskv

1 Answers

0
votes

Here is a simple way to go about things...

Import all your modules with the ES6 style syntax:

import {SpecificBit} from './moduleName';
import * as Everything from './otherModule';

In modules that your write, export members that you want to expose...

export class SomeClass { //...

export class SomeOtherClass { //...

Or replace the module with a member...

export = SomeClass;

Now your development flow is the same everywhere, because the TypeScript compiler will transpile your code based on the module kind switch, which allows you to use ES6 (i.e. no transformation), UMD (works with AMD and CommonJS), System (as used by SystemJS), or simply AMD, or CommonJS (although UMD covers both of these with the same output).