Skip to content

Is it possible to fully dynamically load external package component ?  #915

Open
@marckraw

Description

@marckraw

We have a component library. We are trying to load a component with dynamic name. It doest work when i try to load it from node_modules, but it works when i try to load local files

This guy works

const AsyncComponent = loadable(
    (props) => {
        return import(`./${props.icon}`)
    }
);

This guy doesnt work

const AsyncComponent = loadable(
    (props) => {
        return import(`@amazing/componentlib/${props.icon}`)
    }
);

So my question is, is it possible to load dynamically files from node_modules ?

(doing it in nextjs)

Also, to make clear, the problem is with dynamically constructed imports, this guy, works without problems:

const AsyncComponent = loadable(
    props => 
        import(`@amazing/componentlib/IconAirplane`)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions