[RFC]: Bringing `resolve` Dependency In-House
Maintainer thường phản hồi trong vòng 1 ngày
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
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
Bắt đầu bằng cách xem xét cấu trúc được đề xuất của @stdlib/utils/resolve, sau đó kiểm tra các consumer của resolve được liệt kê, đặc biệt là modules/pkg-deps và test/test.walk_file.js của nó. Chạy các bài kiểm tra consumer hiện có trước khi thay đổi các dependency, sau đó thêm các bài kiểm tra package và chuyển đổi các import được liệt kê. Hoàn tất có nghĩa là các bài kiểm tra hồi quy đều chạy thành công và resolve cùng các dependency bắc cầu của nó được loại bỏ; việc xác minh thủ công vẫn được đánh dấu là TODO.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Replace resolve Dependency with In-House @stdlib/utils/resolve
Replace the external resolve npm dependency with a new stdlib-native package. This eliminates resolve and its 3 transitive dependencies (is-core-module, path-parse, supports-preserve-symlinks-flag) from the supply chain — removing 4 third-party packages total.
Background
The resolve package implements Node.js's require.resolve() algorithm with configurable basedir and paths options.
Only these features are used:
| Feature | Used? |
|---|---|
resolve(id, {basedir}, cb) (async) |
✅ 5 files |
resolve.sync(id, {basedir}) |
✅ 7 files |
resolve.sync(id, {basedir, paths}) |
✅ 1 file |
All other options (packageFilter, pathFilter, extensions, moduleDirectory, etc.) |
❌ |
Proposed Changes
New Package: @stdlib/utils/resolve
Folder Structure
lib/node_modules/@stdlib/utils/resolve/
├── README.md
├── package.json
│
├── lib/
│ ├── index.js # Entry point: exports async + .sync
│ ├── main.js # Async resolve( id, opts, clbk )
│ ├── sync.js # Sync resolve( id, opts ) → string
│ ├── validate.js # Options validation
│ ├── defaults.js # Default options (basedir, extensions)
│ ├── resolve_path.js # Core sync resolution algorithm
│ ├── async_resolve_path.js # Core async resolution algorithm
│ └── is_core_module.js # Built-in module check via module.builtinModules
│
├── docs/
│ ├── repl.txt
│ └── types/
│ ├── index.d.ts
│ └── test.ts
│
├── benchmark/
│ └── benchmark.js # Performance benchmarks (sync vs async)
│
├── examples/
│ └── index.js # Usage examples
│
└── test/
├── test.js # Main export tests
├── test.sync.js # Sync API tests
├── test.async.js # Async API tests
├── test.validate.js # Options validation tests
├── test.is_core_module.js # Core module detection tests
└── fixtures/
├── node_modules/
│ └── mock-pkg/
│ ├── package.json # { "main": "./lib/index.js" }
│ └── lib/
│ └── index.js
├── index.js # Mock directory index
├── foo.js # Mock module
└── foo.json # Mock JSON module
Key Implementation Details
lib/index.js — Entry point matching the resolve package's API shape:
var resolve = require( './main.js' ); // async
var sync = require( './sync.js' ); // sync
resolve.sync = sync;
module.exports = resolve;
lib/resolve_path.js— Core Node.js resolution algorithm:
- If
idis a core module → returnid - If
idstarts with./or../or/→ resolve as file, then as directory - Otherwise → walk
node_modulesdirectories upward frombasedir; ifpathsoption given, also search those - File resolution: try exact path →
.js→.json→.node - Directory resolution: read
package.jsonmainfield → fallback toindex.js→index.json→index.node
lib/is_core_module.js — Zero-dependency replacement for is-core-module:
var builtinModules = require( 'module' ).builtinModules;
function isCoreModule( id ) {
return builtinModules.indexOf( id ) !== -1;
}
Internal dependencies only — no third-party packages:
path(Node.js built-in)fs(Node.js built-in)module(Node.js built-in)@stdlib/assert/is-string(input validation)@stdlib/assert/is-plain-object(options validation)@stdlib/assert/has-own-property(options checking)@stdlib/error/tools/fmtprodmsg(error formatting)
Consumer Migration (13 files)
Each migration is a 1-line require swap. The API shape is identical.
Sync consumers (8 files) — require( 'resolve' ).sync → require( '@stdlib/utils/resolve' ).sync:
| # | File |
|---|---|
| 1 | eslint/require-file-extensions/lib/main.js |
| 2 | modules/pkg-deps/lib/walk_file.sync.js |
| 3 | pkgs/browser-compatible/lib/resolve.sync.js |
| 4 | pkgs/entry-points/lib/resolve.sync.js |
| 5 | pkgs/browser-entry-points/lib/resolve.sync.js |
| 6 | utils/library-manifest/lib/main.js |
| 7 | repl/help/scripts/build.js |
Async consumers (6 files) — require( 'resolve' ) → require( '@stdlib/utils/resolve' ):
| # | File |
|---|---|
| 8 | modules/pkg-deps/lib/walk_file.js |
| 9 | modules/pkg-deps/test/test.walk_file.js (also update proxyquire mock key) |
| 10 | pkgs/browser-compatible/lib/resolve.js |
| 11 | pkgs/entry-points/lib/resolve.js |
| 12 | pkgs/browser-entry-points/lib/resolve.js |
| 13 | lint/namespace-aliases/lib/resolve.js |
Dependency Removal
npm uninstall resolve
Verification Plan
Automated Tests
stdlib uses make test:
- Run new package tests using stdlib's test infrastructure:
make EXAMPLES_FILTER=".*/utils/resolve/.*"" examples
make BENCHMARKS_FILTER=".*/utils/resolve/.*"" benchmark
make TESTS_FILTER=". */utils/resolve/.*"" test
- Run consumer regression tests (pkg-deps has the most extensive test suite):
make TESTS_FILTER=". */_tools/modules/pkg-deps/.*"" test
Manual Verification
{TODO}
- Ngôn ngữ chính
- JavaScript
- Star
- 6k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 224
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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 stdlib-js/stdlib
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
stdlib-js/stdlib#16655 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix JavaScript lint errorsCó thể đã có người làm @protestershankar đã nhận 5 ngày trước. Đang mởGood First Issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
stdlib-js/stdlib#16563 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix C lint errorsCó thể đã có người làm @raus7n đã nhận 14 ngày trước. Đang mởGood First Issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
stdlib-js/stdlib#16454 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix JavaScript lint errorsCó thể đã có người làm @Devansh-18155 đã nhận 39 ngày trước. Đang mởGood First Issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
stdlib-js/stdlib#15970 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix JavaScript lint errorsCó thể đã có người làm @lb1192176991-lab đã nhận 44 ngày trước. Đang mởGood First Issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
stdlib-js/stdlib#15831 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stdlib-js/stdlib
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automation chore ci-cd consistency developer-experience difficulty: easy discoverability documentation enhancement github-actions good first issue help wanted hygiene priority: P3 seo shell yaml
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
swc-project/swc-next-issues#394 ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#5790 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
adobe/helix-tools-website#480 ·
Maintainer thường phản hồi trong vòng 1 ngày