[Bug]: test-utils sourcemaps point to sources that are not in the package

オープン 初心者向け
#5,267 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
build-system

調査の方向性

build-tools/tasks/test-utils.jsを読み、そのTypeScriptコンパイラーオプションをbuild-tools/tasks/typescript.jsと比較してください。issueでは、test-utilsのビルドに--inlineSourcesを追加することが提案されています。生成されたtest-utils/内の.js.mapファイルにsourcesContentが含まれていることを確認し、ツールがパッケージ外のソースファイルを探さずにマップを解決できることを検証してください。

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

説明

bug
Browser

No response

Package version

3.0.1410

React version

No response

Description
Summary

The .js.map files in test-utils/ do not embed their sources, and their sources paths point outside the package. Tools that follow the maps cannot find the sources. Vite, for example, logs one warning for each test-utils file that it transforms:

Sourcemap for "node_modules/@cloudscape-design/components/test-utils/dom/index.js" points to a source file outside its package: "node_modules/src/test-utils/dom/index.ts"

The component sourcemaps do not have this problem.

Steps to reproduce
  1. Install @cloudscape-design/components.
  2. Open node_modules/@cloudscape-design/components/test-utils/dom/index.js.map.
Actual result
"sources": ["../../../../src/test-utils/dom/index.ts"]

There is no sourcesContent. Four levels up from test-utils/dom/ is outside the package, so the path resolves to node_modules/src/test-utils/dom/index.ts, which does not exist. All .js.map files in test-utils/ are the same.

Expected result

The test-utils maps embed their sources, as the component maps do. For example, internal/base-component/index.js.map has the same kind of path (../../../../src/internal/base-component/index.ts), but it also has sourcesContent, so tools do not need the file.

Cause

build-tools/tasks/typescript.js compiles the components with --sourceMap --inlineSources --declarationMap. build-tools/tasks/test-utils.js compiles test-utils with --sourceMap only:

await execa('tsc', ['-p', config, '--outDir', outDir, '--tsBuildInfoFile', `./lib/${theme.name}-test-utils.tsbuildinfo`, '--sourceMap'], ...);

The sources paths are relative to the build output folder (lib/components/test-utils/...), which is two levels deeper than the published package. Without --inlineSources, the maps need the .ts files at those paths, and the package does not include them.

Proposed fix

In build-tools/tasks/test-utils.js, add '--inlineSources' after '--sourceMap', the same as build-tools/tasks/typescript.js. Optionally also add '--declarationMap' to match the components.

Related
Source code

No response

Reproduction

No response

Code of Conduct
主要言語
TypeScript
スター
2.7k
フォーク
248
平均マージ
2日 7時間
マージ済み PR(30日)
89

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

cloudscape-design/components のほかの issue

cloudscape-design/components の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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