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

chunkName not working? #200

Open
Dagniele opened this issue Nov 13, 2019 · 0 comments
Open

chunkName not working? #200

Dagniele opened this issue Nov 13, 2019 · 0 comments

Comments

@Dagniele
Copy link

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.

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