fix(webpack): handle package.json exports field for non-buildable libs#31444
fix(webpack): handle package.json exports field for non-buildable libs#31444
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
View your CI Pipeline Execution ↗ for commit 4b49c31.
☁️ Nx Cloud last updated this comment at |
- Add utility to parse exports field and generate regex patterns for webpack allowlist - Convert wildcard exports like './*': './src/*.ts' to regex patterns - Support conditional exports (import/require/development/default) - Handle exact subpath exports and mixed export patterns - Maintain backward compatibility with libraries without exports field - Add comprehensive unit tests for all export patterns Fixes #31419 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@claude provide a good description for this PR |
|
Claude finished @Coly010's task in 1m 30s —— View job PR Description Complete ✅Here's a comprehensive description for this PR: Current BehaviorThe webpack and rspack plugins for handling non-buildable libraries don't properly process the When a library defines multiple export paths using the Expected BehaviorThe webpack and rspack plugins should properly parse the
Changes MadeCore Features Added:
Files Modified:
Implementation Details:
Related Issue(s)Fixes #31419 This description provides the context and technical details needed for reviewers to understand the scope and impact of the changes. |
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
The webpack and rspack plugins for handling non-buildable libraries don't properly process the exports field in package.json. They incorrectly assume libraries have only a single entry point, typically through a barrel file (index.ts).
When a library defines multiple export paths using the exports field (e.g., "./": "./src/.ts"), the plugins fail to generate the correct allowlist patterns for webpack externals. This causes build failures when trying to use non-buildable libraries that expose multiple entry points without barrel files.
Expected Behavior
The webpack and rspack plugins should properly parse the exports field from package.json and generate appropriate allowlist patterns for all exported subpaths. This includes:
Handling wildcard patterns ("./": "./src/.ts")
Processing conditional exports (import/require/development)
Supporting exact subpath exports ("./utils": "./src/utils.ts")
Escaping special characters in package names for regex patterns
Gracefully falling back to reading package.json directly when metadata is unavailable