Omit "require" and "export" from TypeScript emitted AMD dependencies

Given the following TypeScript file,

export = {};

tsc(c "module": "amd") emits:

define(["require", "exports"], function (require, exports) {
  "use strict";
   return {};
});

However, I would prefer it to radiate

define([], function() {
    "use strict";
    return {};
});

... and include only requireor exportsif I import them explicitly, i.e.

import relativeRequire = require("require");

Can I tell TypeScript not emit require, and exportsin AMD released modules (ie, ask not to use CommonJS simplified packaging )?

Notes:

  • The conclusion that I propose is fully consistent with the AMD specification .
  • ( , require, exports module).

4 2017 : , TypeScript GitHub: https://github.com/Microsoft/TypeScript/issues/669

, ? (, TypeScript ?)

+6
2

, . , , , , , . require exports - , . ( "" , AMD, , .) issue 669, , 2014 "" 2015 . , , .

TypeScript , . , TypeScript define, "module" . ( Angular, module.id Angular, , .. module.id CommonJS AMD module .) , , , tsc , , tsc . regexp, , "module", , . , . , , , , .

Esprima JavaScript, tsc, "require" "exports" factory, define, , factory. . ( , require, AMD ( require([...], function (...) {})) factory.) , , tsc , .

+3

:

.. , , .. import relativeRequire = require("require");

require, . , .

exports , - . , export =, TypeScript return. export const foo = 123 exports.

, .

+1

All Articles