I have an internal library used in Node.js and a browser. It has many files related to the Grunt task and various prologs, one for the browser, one for Node:
browser:
window.myLib = { }
myLib.renderPartDetail = function (...) {...};
Node:
var Mustache = require('mustache');
var myLib = {};
module.exports = myLib;
The result is 2 different single-phase js files, one for the browser, one for Node.
What i would like
- use typeScript
- if possible, use only one CommonJS syntax (or ES6 modules) for the browser and node
- invest in something that does not die in the next couple of months.
- be a little more modular (maybe someone needs only part of lib)
What bothers me
I find 2 different types of module handling in TypeScript:
import {a, b} from './x'
and
import c = require('./y')
I am using the latter from node, but the former looks like ES6 (it may be the future).
tsc --module commonjs, , ? --module system, , , , export = ... .
browserify, tsify, watchify, jspm, SystemJS, webpack - , , .
require(<a node module living in node_modules>), tsc : "TS2307: " ".
- Node ?
- ? , ? ( Gulp, Grunt).
- TypeScript Node ? 1.4, IntelliJ, 1.6.2 , "TypeError: host.fileExists " ( ). , Node v4.1.1?
, . , , , , .