microsoft / microsoft/TypeScript

Write typescript as modules, but output js without modules

Đang mở
#39,446 8 bình luận 17 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các tùy chọn module của tsconfig và hành vi watch-build tăng dần được mô tả trong issue. Xác định cách các thiết lập riêng biệt cho source-module và emitted-module nên tương tác với nhau, sau đó xác minh rằng TypeScript có thể phát ra JavaScript không phải module trong khi vẫn duy trì các incremental build dựa trên module.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, typescript
Lĩnh vực
build-system, compilers
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.