Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

STEP 7 - Lazy load conditional dependencies #8

Open
wants to merge 1 commit into
base: lazy-intersection
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions client/routes/PDP/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import React from 'react';
import { object } from 'prop-types';
import loadable from '@loadable/component';

import PdpComponent from './components';
const errorLoading = err => console.log('PDP page loading failed!', err);

const PDP = ({ match }) => {
return (<PdpComponent match={match}/>)
};
const PDPComponent = loadable(() =>
import(/* webpackChunkName: "pdp" */ './components').catch(errorLoading),
);

PDP.propTypes = {
match: object.isRequired,
};

export default PDP;
export default PDPComponent;
2 changes: 2 additions & 0 deletions tools/client/webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ module.exports = function() {
color: '#61dafb',
}),

new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),

new FriendlyErrorsWebpackPlugin(),
// Generates an `index.html` or `index.client.html` file with the <script> injected.
new HtmlWebpackPlugin(
Expand Down