microsoft / microsoft/TypeScript

Write typescript as modules, but output js without modules

オープン
#39,446 コメント 8 件 リアクション 17 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

Search Terms

Searched the whole internet for anything like it, only webpack and browserify related 'solutions' are proposed.

Suggestion

Split module options in tsconfig so typescript modules could be set separately from output target modules.

Use Cases

Our usecase:

  • We have a huge codebase, and we want to slowly move to typescript.
  • We have a sophisticated build system that we don't want to change - we want typescript to transpile to js and to take js and continue to use it as we were.
  • We don't need nor want to use modules in js. We never used modules - we have our system of imports, minification,
    versioning, caching, etc.
  • The only reason why we need to use modules in typescript is tsc incremental watch build. With no modules, it builds complete codebase on each change. We want to build only file changed and dependent files.

So currently we have two bad options - don't use modules (unacceptably slow build time) or use modules (get the output that we don't want). Currently we 'mitigate' the issue by removing parts of js tsc has output (removing stuff we recognize as related to exports and require), but that's just terrible.

Even worse, even if we were to use modules, require / exports are inlined even in output we want to inline to index.html as critical JS...

Examples

I guess I explained it all above.

Checklist

My suggestion meets these guidelines:

  • [ * ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ * ] This wouldn't change the runtime behavior of existing JavaScript code
  • [ * ] This could be implemented without emitting different JS based on the types of the expressions
  • [ * ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [ * ] This feature would agree with the rest of TypeScript's Design Goals.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、tsconfig の module オプションと、issue に記載されているインクリメンタルな watch ビルドの動作を確認します。ソースモジュールと出力モジュールの個別の設定がどのように連携すべきかを判断し、そのうえで、TypeScript がモジュールベースのインクリメンタルビルドを維持しながら非モジュール JavaScript を出力できることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, typescript
領域
build-system, compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。