diff --git a/.babelrc b/.babelrc index fbd6da0..b88ce11 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,5 @@ { + "plugins": ["@loadable/babel-plugin"], "presets": [ "@babel/preset-env", "@babel/preset-react" diff --git a/client/loaders/DetailsLoader.jsx b/client/loaders/DetailsLoader.jsx index 03e45c1..5bddd06 100644 --- a/client/loaders/DetailsLoader.jsx +++ b/client/loaders/DetailsLoader.jsx @@ -5,7 +5,16 @@ import './spinner.css'; const slug = item => item.toLowerCase().split(' ').join('-'); -const DetailsLoader = loadable(props => import(`../patterns/${slug(props.pattern)}/Details`), { +// In order to create a link to another page that is dynamically loaded (via ), +// the page chunks have to be loadable by @loadable. +// We have to add a magic comment /* #__LOADABLE__ */ here +// and the following plugin to Babel's settings (.babelrc): +// { +// "plugins": ["@loadable/babel-plugin"], +// } +const loadDetails = /* #__LOADABLE__ */ (props) => import(`../patterns/${slug(props.pattern)}/Details`) + +const DetailsLoader = loadable(loadDetails, { fallback: (