Add web-compatible parsePackageExports API - #20
Draft
privatenumber wants to merge 68 commits into
Draft
Conversation
- Update ParsedExport type to allow target: null - Modify traverseExports to create entries for null targets instead of filtering them out - Add test for null blocking wildcard patterns - Update existing tests to expect null entries in output This allows playground/visualization tools to: 1. Know which patterns are blocked 2. Apply blocking logic (more specific blocks override broader wildcards) 3. Match the behavior of analyzeExportsWithFiles for eventual internal use
Refactored the internal implementation of getPackageEntryPoints and getPackageEntryPointsSync to use the new parsePackageExports function. Created analyze-exports-with-files.ts that: - Calls parsePackageExports to get a flat list of export entries - Separates wildcard-generated entries from static entries - Validates file existence for all target paths - Applies proper precedence: static entries override wildcards - Handles null blocking for both static and wildcard patterns - Supports wildcard-to-static path mapping with '_' substitution - Handles static subpaths with wildcard targets (e.g., '.': './file-*.js') Key features: - First-wins within same type (wildcard vs static) - Static always wins over wildcard for same subpath+conditions - Null targets create blocks that filter out matching entries - Files with literal '*' in name are handled correctly All 93 tests passing.
Reduced from 128 to 89 lines (30% reduction) by: - Combining null and string handling (same logic) - Removing duplicate wildcard validation - Using cleaner ternary chains for target assignment - Inlining simple conditions All 93 tests passing.
Changed analyzeExportsWithFiles to accept ParsedExport[] as first argument instead of PackageJson.Exports. This makes the separation cleaner: - parsePackageExports: parsing logic (web-compatible) - analyzeExportsWithFiles: file validation logic - getPackageEntryPoints: orchestrates both All 93 tests passing.
…nto parse-package-exports
privatenumber
marked this pull request as draft
October 15, 2025 11:49
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
Adds
parsePackageExports()function for parsingpackage.json#exportswithout filesystem dependencies, enabling web-based playground/visualization tools.parsePackageExports(exports)returns array ofParsedExportobjectstarget: null) for playground blocking logicParsedExporttype for TypeScript consumersKey Features
'./dist/*'→['./dist/', '']for easy.join(match)target: nullentries to enable blocking logic in playgroundsUse Case
Enables building a
package.json#exportsplayground where users can:Test Plan