Error with --out when --module is used

Topics: General, Language Specification
Jul 5, 2014 at 1:06 PM
Edited Jul 5, 2014 at 1:31 PM
I've got a multi-file internal module

Now I need to expose this module in commonjs (node) and requirejs, but keeping the possibility of using it as single file without any modules (so, three options of build target - commonjs, amd and no-modules)

What should I do for that ?

I did the following:

UnitOfMeasurements.ts
/// <reference path="UnitOfMeasurements1.ts" />
/// <reference path="UnitOfMeasurements2.ts" />
/// <reference path="UnitOfMeasurements3.ts" />

function _(value) {  return  new UnitOfMeasurements.Unit(value); }
All UnitOfMeasurementsN have the same structure, i.e.
UnitOfMeasurements1.ts
module UnitOfMeasurements {
  // export class Unit and etc
}
I need some file, that contains just export section for commonjs
units-node.ts
/// <reference path="UnitOfMeasurements.ts" />

export = UnitOfMeasurements;
I try to build it using
tsc units-node.ts --out dist/node/units-node.js --module commonjs

The actual result: units-node.js contains the code of all UnitOfMeasurements files, but does not contains any export section

when I omit -- out parameter, it contains just
module.exports = UnitOfMeasurements;
To me, looks like --out option works wrong when --module is set
As I understand, -- out should inline referenced internal modules
Jul 6, 2014 at 7:23 PM
I would suggest reading up the documentation on modules.
Jul 7, 2014 at 10:45 AM
I'm afraid there is nothing about multi-target build.
Jul 7, 2014 at 10:49 AM
Edited Jul 7, 2014 at 10:53 AM
You want to build one external module (AMD or CommonJS) from multiple source files. Alas, TypeScript doesn't support this for now.

See this issue https://typescript.codeplex.com/workitem/759