v12: Ditch CJS build

オープン
#26,671 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

Start by surveying Node.js versions that support require(esm), then inspect the repository’s CI matrices, package engines fields, documentation, runtime dependencies, and build and deployment configuration. Check whether any runtime dependency uses top-level await and identify an integration test that can catch it. Done means the supported Node.js versions and CI reflect the survey, the dependency constraint is guarded by a test, and builds no longer produce CJS.

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

説明

A common user request is to provide a default export from our SDKs: import Sentry from '@sentry/somesdk' rather than import * as Sentry from '@sentry/somesdk'.

However, this is quite annoying to do, for the fact that we build for both CJS and ESM, using the same types definitions, as typescript represents the default export quite differently between CJS and ESM. (For good reason; they're semantically different in very subtle ways that are impossible to represent 100% faithfully, even if these only become an issue in certain edge cases.)

Option 1: build types twice

This is definitely a possibility, and not terrible. It does increase our build times a tiny bit, but many projects do hybrid builds this way, and it's typically not that bad. It'll increase the download size of our packages by a modest amount, but the run-time cost stays what it is today.

As this is less good than Option 2 below, it's a known-mediocre fallback (maybe still better than "leave it, no change") if we run into problems.

Option 2: Ditch CJS

This has a ton of benefits. Faster CI (because we can cut out entire dimensions of several build/test matrices), smaller download size, etc. And, we can do it with only a very modest platform support coverage hit, because new Node versions all support require(esm).

The only hazard (apart from version support) is that if anything in the runtime dependency chain uses top-level await, it blows up.

Done when...
  • Survey node versions that support require(esm) to confirm we have the appetite to restrict our supported node versions to that list, and then do so. (Adjust CI matrices, engines fields, docs, etc.)
  • Ensure that none of our runtime dependencies use top-level await. This is probably fine, mostly the only runtime deps we have outside of this repo are either optional peer-deps that the user provides, @sentry/conventions, and @opentelemetry/api. But we should check, and have an integration test that'll fail if this changes. (Currently it seems safe.)
  • Update our build and deployment mechanisms to no longer build CJS.
主要言語
TypeScript
スター
8.8k
フォーク
1.9k
平均マージ
1日 8時間
マージ済み PR(30日)
744

環境構築

はじめの一歩

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

getsentry/sentry-javascript のほかの issue

getsentry/sentry-javascript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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