Add barrel export and exports map to packages/components#6130
Add barrel export and exports map to packages/components#6130michaell-workday wants to merge 10 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces subpath exports for the flowise-components package, establishing a stable entry point for node-level utilities and adding a dependency override for es-iterator-helpers. Review feedback highlights potential issues with the wildcard export mapping that could lead to incorrect file resolution when extensions are used, and suggests narrowing the broad catch-all export to avoid exposing internal package files.
| "types": "./dist/nodes/*.d.ts", | ||
| "default": "./dist/nodes/*.js" | ||
| }, | ||
| "./*": "./*" |
There was a problem hiding this comment.
Exposing the entire package directory via "./*": "./*" is a broad catch-all that includes internal files like tsconfig.json or the src/ directory. While this preserves backward compatibility for deep imports that include dist/, it is generally safer to restrict exports to the dist/ folder. If all intended deep imports are within dist/, consider mapping "./*": "./dist/*" instead, though this may break existing imports that already include the dist/ prefix.
There was a problem hiding this comment.
@michaell-workday would you be able to take a look at this?
There was a problem hiding this comment.
done. this is the right call and results in cleaner/better scoped imports. the only tradeoff is that existing imports that rely on dist/ prefix will break, but that is not best practice anyway and users should be able to update and remove dist/ prefix
There was a problem hiding this comment.
actually reverted this because it prevents the rare but possible case of importing files from root folder of the package like models.json. it also preserves backward compatibility for /dist prefix which doesn't hurt for possible existing consumers
There was a problem hiding this comment.
can you share which file in the repo references dist? I was doing a search and couldn't find any reference to flowise-components/dist/** ?
(I only found 44 instances of imports from the package root from 'flowise-components, and there is no usage of full path either)
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces subpath exports for the flowise-components package, adds a new entry point for node-level utilities, and includes a dependency override. Feedback was provided regarding the exports configuration in package.json, specifically that the catch-all mapping could break backward compatibility for existing deep imports and access to root files like package.json.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new barrel file for node-level utilities and configures package exports in packages/components/package.json to expose them. It also adds a dependency override for es-iterator-helpers in the root package.json. Feedback was provided to refine the exports configuration, specifically suggesting a mapping for node subpaths to ensure they resolve correctly to the dist directory and avoid potential module resolution errors.
Summary
exportsfield topackages/components/package.jsonto declare the official public API surface offlowise-componentspackages/components/nodes/index.tsas a stable barrel entry point for MCP node utilitieses-iterator-helpers@1.0.15in pnpm overrides to resolve a transitive dependency conflictBackground
flowise-componentshad noexportsfield, meaning Node.js resolved imports by directly walking the filesystem. This worked forflowise-components(the main entry) but meantflowise-components/nodeshad no defined entry —nodes/index.tscompiles todist/nodes/index.js, notnodes/index.js, so the import failed at runtime withMODULE_NOT_FOUND.Changes
packages/components/nodes/index.tsNew barrel file that re-exports MCP toolkit utilities (
MCPToolkit,MCPTool, validation helpers) fromnodes/tools/MCP/core. Consumers should import fromflowise-components/nodesrather than deep paths, insulating them from internal refactors.packages/components/package.json—exportsfieldpackage.json (root)
Added "es-iterator-helpers": "1.0.15" to pnpm.overrides to resolve a transitive version conflict surfaced after the lockfile update.
Breaking change
Adding an exports field opts out of CJS automatic extension guessing for all subpaths. Extensionless dist/-prefixed imports (e.g. require('flowise-components/dist/src/Interface')) will no longer resolve — the fix for consumers is to add the .js extension. All other previously working import patterns continue to work.