Allow Secondary Entry Point for Local Nx Plugin #26668
jogelin
started this conversation in
Feature Requests
Replies: 1 comment 4 replies
-
I have a secondary entry point in "src/plugin" and it works locally. https://github.com/RobbyRabbitman/nx-plus/tree/demo/local-plugin. I could not create a stackblitz, somehow nx is not working in there, but i created a branch to fork/clone/download. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Current:
It is not possible to expose the
createNodes()
API in a secondary entry point for Local Nx Plugin:For example, if you create a separate
plugin.ts
to expose yourcreateNodes()
:and declare it in your
tsconfig.base.json
like:and try to access to it in you
nx.json
like:It will not work because Nx will switch to the main
src/index.ts
referenced in the project configurationExpected:
An Nx plugin can be used to serve multiple use cases:
If you need to share some functions, that are not related to the same use case, it is recommended to create separate entry points and use the one related to your use case. So you'll not import libraries that you don't need.
This is something that can be done if you publish your plugin. However, you cannot do it because of the current local Nx plugin resolution.
I expect that if I declare a path pointing to a different entry point like:
Nx uses it instead of switching to the main one specified in the project configuration.
Suggestions
I am not sure which use case we are covering when switching to the main entry point by default. If the path is found in the
tsconfig.base.json
, shouldn't we use it directly without loading the project configuration?When we look for the path matching the plugin import, we are looking for a perfect match, could we support wildcard to avoid declaring too many paths?
Last thought
I see that Nx is using that approach internally. Even for the
@nx/angular plugin
, the generators and executors are exposed using separate entry points.I am ok to propose PR if you think it makes sense?
Beta Was this translation helpful? Give feedback.
All reactions