Skip to content

Add barrel export and exports map to packages/components#6130

Open
michaell-workday wants to merge 10 commits intomainfrom
feat/barrel-export
Open

Add barrel export and exports map to packages/components#6130
michaell-workday wants to merge 10 commits intomainfrom
feat/barrel-export

Conversation

@michaell-workday
Copy link
Copy Markdown
Contributor

@michaell-workday michaell-workday commented Apr 2, 2026

Summary

  • Adds an exports field to packages/components/package.json to declare the official public API surface of flowise-components
  • Introduces packages/components/nodes/index.ts as a stable barrel entry point for MCP node utilities
  • Pins es-iterator-helpers@1.0.15 in pnpm overrides to resolve a transitive dependency conflict

Background

flowise-components had no exports field, meaning Node.js resolved imports by directly walking the filesystem. This worked for flowise-components (the main entry) but meant flowise-components/nodes had no defined entry — nodes/index.ts compiles to dist/nodes/index.js, not nodes/index.js, so the import failed at runtime with MODULE_NOT_FOUND.

Changes

packages/components/nodes/index.ts

New barrel file that re-exports MCP toolkit utilities (MCPToolkit, MCPTool, validation helpers) from nodes/tools/MCP/core. Consumers should import from flowise-components/nodes rather than deep paths, insulating them from internal refactors.

packages/components/package.jsonexports field

"exports": {                                                                                                                                                                       
    ".": {                                                                                                                                                                         
        "types": "./dist/src/index.d.ts",                                                                                                                                          
        "default": "./dist/src/index.js"                                                                                                                                           
    },                                                                                                                                                                             
    "./nodes": {                                                                                                                                                                   
        "types": "./dist/nodes/index.d.ts",                                                                                                                                        
        "default": "./dist/nodes/index.js"                                                                                                                                         
    },                                                                                                                                                                             
    "./*": "./*"                                                                                                                                                                 
}                                                                                                                                                                                  
  • . — explicit main entry (no change in behavior)
  • ./nodes — new stable entry for MCP utilities via the barrel
  • ./* — neutral passthrough catch-all; preserves all previously working import patterns including dist/-prefixed deep imports and root file access (e.g. models.json)

package.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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
},
"./*": "./*"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaell-workday would you be able to take a look at this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

@michaell-workday michaell-workday Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

@jocelynlin-wd jocelynlin-wd Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@michaell-workday
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@michaell-workday
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants