Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Import of Element/Components from outside project #641

Open
SaidulBadhon opened this issue May 21, 2024 · 0 comments
Open

Allow Import of Element/Components from outside project #641

SaidulBadhon opened this issue May 21, 2024 · 0 comments

Comments

@SaidulBadhon
Copy link

Certainly! Here is the updated feature request with your additional input, formatted in Markdown:


Feature Request: Dynamic Component Importing

Is your feature request related to a problem? Please describe.

Currently, to use a component like Navbar, we need to import it explicitly using a standard import statement:

import Navbar from "@/components/elements/Navbar";

<Element
  is={Navbar}
  custom={{ displayName: "Navbar" }}
/>

This approach has limitations, particularly when Navbar or similar components are not present within the project. It requires all components to be known and available at compile-time, reducing flexibility.

Describe the solution you'd like

My idea is to import the file from a string and pass it, enabling the dynamic import of components. If this is not viable, an alternative solution should be implemented to allow using files from outside of the current project.

Example:

<Element
  is="Navbar"
  custom={{ displayName: "Navbar" }}
/>

Under the hood, this string would be used to resolve and import the corresponding component dynamically, potentially using a method like import() or a custom resolver function.

Additional context

  • This feature would increase flexibility and modularity, allowing components to be loaded from external sources or repositories.
  • It could leverage existing dynamic import capabilities in JavaScript (e.g., import() function) or involve setting up a custom resolver within the framework.
  • Consideration should be given to error handling for cases where the component is not found or fails to load.

Let me know if you need any more adjustments or additional details.

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

No branches or pull requests

1 participant