Add comprehensive test coverage and improve resolver implementations#2
Merged
Add comprehensive test coverage and improve resolver implementations#2
Conversation
Two bugs fixed: - fs was hardcoded to node:fs instead of using ctx.meta.fs (the virtual filesystem), unlike file.ts which already handled this correctly - The fallback loop only tried require.resolve, which can't see virtual filesystems — added an fs.existsSync fallback for text files like .jsonic When require.resolve succeeds, results are read with SystemFs (real fs) since require.resolve only knows about the real filesystem. The virtual fs is used for the existsSync fallback path. https://claude.ai/code/session_015pFjG7ghbYrAiF5g9nfVcM
Add 15 new tests covering previously untested code paths: - pkg resolver: require as string/array, virtual fs fallback, node_modules walk, resolvefolder isFile, fs error handling, load failure - file resolver: implicit extension search, pathfinder callback - multisource: spec as object, map.merge, Object.assign fallback, JS default exports, jsonic null src guard Restructure source imports to avoid TypeScript helper coverage artifacts: use single-line imports, inline type imports, copyright comments, and namespace imports matching multisource.ts pattern. Coverage: 100% line, 87% branch, 91% function (remaining branch/function gaps are from TypeScript __importStar helper code) https://claude.ai/code/session_015pFjG7ghbYrAiF5g9nfVcM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds extensive test coverage for the MultiSource plugin and refactors resolver implementations to improve code quality and maintainability. The changes include 13 new test cases covering package resolution, file resolution, virtual filesystem support, and edge cases, along with modernized import statements and improved error handling.
Key Changes
Test Coverage
pkg-require-array,pkg-require-string)pkg-virtual-fs-fallback)pkg-no-path)pkg-resolvefolder-file)pkg-fs-error,pkg-load-failure)pkg-node-modules-walk)file-implicit)file-pathfinder)spec-object)merge,assign)js-default-export)jsonic-null-src)k05.jsfor JavaScript module testingResolver Improvements
pkg.ts:
node:fsandnode:pathrequire.resolvefails.jsonic)ctx.meta?.fsfor filesystem abstractionfile.ts:
node:pathmem.ts:
Code Quality
Notable Implementation Details
require.resolvefails, enabling support for text-based configuration files (.jsonic) in virtual filesystemshttps://claude.ai/code/session_015pFjG7ghbYrAiF5g9nfVcM