replace: Should property accessors be replaced or not?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Compare packages/replace/test/fixtures/form/dollar-sign-boundary and replace-nothing with their _config.js files and the Vitest snapshots under packages/replace/test/snapshots/form.js.md, using the linked reproduction as context. First establish which property-access and delimiter behavior is intended; done means the conflicting fixtures and snapshots consistently reflect the agreed behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
- Rollup Plugin Name:
@rollup/plugin-replace - Rollup Plugin Version: 6.0.3
- Rollup Version: 4.62.0
- Operating System (or Browser): macOS 15.7.7 (local), unknown (stackblitz)
- Node Version: v22.22.3
- Link to reproduction (⚠️ read below): https://stackblitz.com/edit/rollup-repro-amxnsxzx?file=dist%2Fmain.js&view=editor
Expected Behavior
Given this test added in #1938 merged into 6.0.3:
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/fixtures/form/dollar-sign-boundary/input.js#L17-L20
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/fixtures/form/dollar-sign-boundary/_config.js#L2-L8
Comment strongly suggests it should produce the following replacement:
// Should be replaced - typeof window followed by dot
if ("undefined".document !== 'undefined') {
console.log('has document');
}
Actual Behavior
The snapshot stored by vitest does not actually replace this:
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/snapshots/form.js.md?plain=1#L43-L46
And, there is an older fixture + snapshot which directly conflicts with this interpretation, under replace-nothing:
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/fixtures/form/replace-nothing/input.js#L1-L2
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/fixtures/form/replace-nothing/_config.js#L2-L5
Vitest Snapshot:
https://github.com/rollup/plugins/blob/639f45638234c1c3fabfb13615c78bebaef89ef2/packages/replace/test/snapshots/form.js.md?plain=1#L76-L81
Additional Information
The older PR which introduced the replace-nothing test was #903 which had the following comment:
Personally, I believe it's dangerous to replace
VERSIONin the case you highlighted by default:if (VERSION.startsWith('foo')) { // things }In the case above with the previous default to match VERSION when used with a
.or nested access, you would need to know all of your dependencies' code, not to mess up when replacing.
Originally posted by @o-alexandrov in https://github.com/rollup/plugins/issues/903#issuecomment-885657501
What is the current intended behavior? I don't think these two tests can co-exist unless they're testing differently configured delimiters.
- Ngôn ngữ chính
- JavaScript
- Star
- 3.8k
- Fork
- 635
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rollup/plugins
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Support js-yaml v5 Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Tất cả issue của rollup/plugins
Issue tương tự
-
curation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
amponce/archive-movie-browser#186 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
clerk/javascript#9852 ·
-
bug p1 tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
HarperFast/skills#96 ·
-
factory-active factory-automatic task-bug-reproduction-cannot-reproduce task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100