microsoft / microsoft/TypeScript
Proposal: `export as namespace` for UMD module output
オープン
まだ誰も着手していません。
In Discussion
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Current problem
TypeScript supports UMD output but does not support exporting as a global namespace.
Syntax
NamespaceExportDeclaration:
export as namespace IdentifierPath
Behavior
export var x = 0;
export function y() {}
export default {};
export as namespace My.Custom.Namespace;
// emits:
(function (global, factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
else {
global.My = global.My || {};
global.My.Custom = global.My.Custom || {};
global.My.Custom.Namespace = global.My.Custom.Namespace || {};
var exports = global.My.Custom.Namespace;
factory(global.require, exports);
}
})(this, function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = 0;
function y() { }
exports.y = y;
exports["default"] = {};
});
Note
- This proposal basically follows Babel behavior.
- Importing any module without a module loader will throw in this proposal. A further extension may use global namespaces as Babel does.
- Babel overwrites on the existing namespace whereas this proposal extends the existing one, as TS
namespacedoes. - Rollup has a special behavior where
export default Xworks like CommonJSmodule.exports = Xwhereas this proposal does not.
Prior arts: Babel exactGlobals, Webpack multi part library, Rollup output.name option with namespace support
See also
#8436
#10907
#20990
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue には、ソースファイル、テスト、エントリポイントが記載されていません。まず、NamespaceExportDeclaration と UMD の提案された動作を、関連する issue #8436、#10907、#20990 と比較してください。グローバル namespace の出力について、合意された設計と実装基準が整えば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100