faceyspacey / faceyspacey/react-universal-component

chunkName not working?

Open
#200 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.7k
Forks
80
PR merge metrics
No merged PRs in 30d

Description

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:

``` jsx harmony
const options = {
render: (props: Props, Mod: any) => {
if (!Mod) return ;

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

return ;
},
};

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

export default universal(asyncComponent, options);
```

I tried to add in the options these properties:

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

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

return ;
},
};
```

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

``` jsx harmony
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.