Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Deprecate `td.function` in favor of `td.func`

Đang mở
#214 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, rollup, webpack

Hướng nghiên cứu

Start by tracing the current package exports and build setup, then compare how webpack, Rollup, and Browserify handle the proposed ES-module and CommonJS shapes. Done means preserving the intended top-level distribution API and tree shaking, documenting td.func(), and deciding when td.function should be removed in a major release.

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

Mô tả

Terrible luck to discover this after releasing 2.0.0, but subsequent improvements to the build have made me realize that the cute way we do this:

module.exports = { function: require('./function') /*...*/ }

Just won't fly in ES module-land, where something like this:

export { function }

Will blow up because it's a reserved word. (import {function} from 'testdouble' also blows up)

We can do:

export default {
  function: tdFunction
}

But then any module/bundler like webpack/rollup/browserify is going to have that default tacked onto it, which means that our distribution will be td.default.object or whatever.

I hope we can find some workaround to use ES exports exclusively and then solve this with build cleverness using one of the bundlers, but even if we do manage, having a top-level API that's a reserved word is probably not a great long-term play.

Goals:

  • hack up some short-term win with a bundler that'll let us still get tree shaking while using a CJS export at the top level or a way to modify the bundled content to td = td.default dynamically.
  • documentation change from td.function() to td.func()
  • figure out how soon we want to think about dropping td.function with another major bump.
Ngôn ngữ chính
JavaScript
Star
1.4k
Fork
140
Merge trung bình
5 giờ 55 phút
Pull request đã merge (30 ngày)
4

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 testdouble/testdouble.js

Tất cả issue của testdouble/testdouble.js

Issue tương tự

Thêm issue về JavaScript

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.