microsoft / microsoft/TypeScript

Support import maps and bare import specifiers

オープン
#43,326 コメント 4 件 リアクション 35 件 担当者 1 名 GitHub で見る

@weswigham がすでに取り組んでいます。

2021年3月22日 から。

Needs Proposal Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Suggestion

🔍 Search Terms

  1. import maps
  2. bare import specifiers

✅ Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

As import maps are part of Chrome (as of version 89), and Firefox has given a nod of approval, it would be great if Typescript embraced this cross-package import syntax.

Import maps assume an index.html (for example) file with a script tag, e.g.:

<script type="importmap">
{
  "imports": {
    "moment": "/node_modules/moment/src/moment.js",
    "lodash": "/node_modules/lodash-es/lodash.js"
  }
}
</script>

I would suggest being able to

  1. Point to a file containing such an importmap in tsconfig and/or
  2. Just supporting bare import specifiers, based on package.json/package-lock.json, the way unpkg.com is able to do..

📃 Motivating Example

Now you can reference cross-package JS files seamlessly, without bundling tools, based on browser standards.

Workaround:

The path resolution Typescript provides is inadequate, and quite unhelpful.

The only fairly reliable workaround I've found is cloning the repo to a sibling folder of my project.

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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