Skip to content

chunkName not working? #200

@Dagniele

Description

@Dagniele

Hi, I have a problem, I am trying to use a custom chunkName, but it does not seem to work, I tried with the babel-plugin-universal-import and without, no way, I don't know if I am doing something wrong, here is the basic piece of code:

const options = {
  render: (props: Props, Mod: any) => {
    if (!Mod) return <Loader iconSize={props.iconSize} />;

    const { iconSize, ...otherProps } = props;

    return <Mod {...otherProps} />;
  },
};

const asyncComponent = (props: Props) => import(`./icons/${allIcons[props.icon]}`);

export default universal(asyncComponent, options);

I tried to add in the options these properties:

const options = {
  ignoreBabelRename: true,
  chunkName: (props) => `whatever-${props.icon}`,
  render: (props: Props, Mod: any) => {
    if (!Mod) return <Loader iconSize={props.iconSize} />;

    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    const { iconSize, ...otherProps } = props;

    return <Mod {...otherProps} />;
  },
};

it does not work, tried to add the chunkName in the asyncLoader something similar to this:

const UniversalComponent = universal(props => universalImport({
  chunkName: props => props.page,
  path: props => path.join(__dirname, `./${props.page}`),
  resolve: props => require.resolveWeak(`./${props.page}`),
  load: props => Promise.all([
    import( /* webpackChunkName: '[request]' */ `./${props.page}`)
  ]).then(proms => proms[0])
}));

nothing seems to work, the output is always icons/MyIcon for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions