Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #47 from asudoh/webpack-entry-patch-ie11
Browse files Browse the repository at this point in the history
fix(devenv): patch WebPack entry config
  • Loading branch information
alisonjoseph authored Sep 17, 2018
2 parents 725ebc3 + 4d843d0 commit 8285dec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,33 @@ exports.createPages = ({ actions, graphql }) => {
});
};

exports.onCreateWebpackConfig = ({ actions, getConfig }) => {
exports.onCreateWebpackConfig = ({ actions, getConfig, stage }) => {
const config = getConfig();
const { module } = config;
const { entry, module } = config;
const { rules } = module;
const { commons } = entry || {};
const appIndex = !commons ? -1 : commons.findIndex(item => /app$/i.test(item));
actions.replaceWebpackConfig({
...config,
entry: stage !== 'develop' || appIndex < 0 ? entry : {
...entry,
commons: [
// Ensure loading polyfills before RHL loads `react` module
// This prevents a condition where `Symbol` polyfill loaded
// after `react` is loaded and before `react-dom` is loaded
// which makes `react` and `react-dom` refer to different `Symbol` definitions.
//
// Refs:
// https://github.com/gatsbyjs/gatsby/issues/7003
// https://github.com/facebook/react/issues/8379#issuecomment-263962787
//
// The problem seems to happen only in development environment (see below link)
// and thus we patch `entry` WebPack config only for development environment.
// https://github.com/carbon-design-system/carbon-website-gatsby/issues/24#issuecomment-421593414
path.resolve(__dirname, 'src/polyfills/index.js'),
...commons,
],
},
module: {
...module,
rules: [
Expand Down
1 change: 1 addition & 0 deletions src/polyfills/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'core-js/modules/es7.object.values';
import 'core-js/modules/es6.promise.js';
import 'core-js/modules/es6.string.includes';
import 'core-js/modules/es6.string.trim';
import 'core-js/modules/es6.symbol';
/* eslint-enable import/no-extraneous-dependencies */

import './custom-event';
Expand Down

0 comments on commit 8285dec

Please sign in to comment.