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

Đang mở Phù hợp với người mới
#5,267 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
build-system

Hướng nghiên cứu

Đọc build-tools/tasks/test-utils.js và so sánh các tùy chọn trình biên dịch TypeScript của tệp này với build-tools/tasks/typescript.js. Issue đề xuất thêm --inlineSources vào bản build test-utils. Xác nhận các tệp .js.map được tạo trong test-utils/ có sourcesContent, sau đó kiểm tra xem các công cụ có thể phân giải các map mà không tìm tệp nguồn bên ngoài package hay không.

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

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
2.7k
Fork
248
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
89

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue khác của cloudscape-design/components

Tất cả issue của cloudscape-design/components

Issue tương tự

Thêm issue về TypeScript

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.