Skip to content

Commit

Permalink
Fix website and legacy demo in IE 11 (#19237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 authored Aug 4, 2021
1 parent 5369d33 commit b841037
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 265 deletions.
8 changes: 4 additions & 4 deletions apps/test-bundles/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const {
createEntry,
} = require('./webpackUtils');

const package = process.env.PACKAGE;
const packageName = process.env.PACKAGE;

let entries;
if (package === '@fluentui/react-northstar') {
if (packageName === '@fluentui/react-northstar') {
createFluentNorthstarFixtures();
entries = buildEntries('@fluentui/react-northstar');
} else if (package === '@fluentui/react') {
} else if (packageName === '@fluentui/react') {
createFluentReactFixtures();
createEntry('@fluentui/keyboard-key');

Expand All @@ -24,4 +24,4 @@ if (package === '@fluentui/react-northstar') {
process.exit(1);
}

module.exports = createWebpackConfig(entries);
module.exports = createWebpackConfig(entries, packageName);
12 changes: 9 additions & 3 deletions apps/test-bundles/webpackUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const TerserPlugin = require('terser-webpack-plugin');

const FIXTURE_PATH = 'temp/fixtures/';

function createWebpackConfig(entries) {
function createWebpackConfig(entries, packageName) {
return Object.keys(entries).map(entryName => {
/** @type {BundleAnalyzerPlugin.Options} */
let anaylizerPluginOptions = {
analyzerMode: 'static',
reportFilename: entryName + '.stats.html',
Expand All @@ -29,7 +30,7 @@ function createWebpackConfig(entries) {
modules: true,

builtAt: false,
outputPath: false,
.../** @type {*} */ ({ outputPath: false }),
namedChunkGroups: false,
logging: false,
children: false,
Expand All @@ -45,7 +46,7 @@ function createWebpackConfig(entries) {
};
}

return resources.createConfig(
const config = resources.createConfig(
entryName,
true,
{
Expand All @@ -69,6 +70,11 @@ function createWebpackConfig(entries) {
true,
true,
)[0];
if (packageName === '@fluentui/react-northstar') {
// This is used most of the configs for IE 11 compat, which northstar doesn't need
delete config.target;
}
return config;
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fix website and legacy demo in IE 11",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@
"typescript": "4.1.5",
"webpack": "5.44.0",
"webpack-bundle-analyzer": "4.4.2",
"webpack-cli": "4.3.1",
"webpack-cli": "4.7.2",
"webpack-dev-middleware": "4.2.0",
"webpack-dev-server": "4.0.0-beta.0",
"webpack-dev-server": "4.0.0-rc.0",
"webpack-hot-middleware": "2.25.0",
"webpack-merge": "5.7.3",
"workspace-tools": "0.12.3",
Expand Down
11 changes: 11 additions & 0 deletions scripts/webpack/webpack-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ const cssRule = {
use: ['style-loader', 'css-loader'],
};

/**
* As of webpack 5, you have to add the `es5` target for IE 11 compatibility.
* Otherwise it will output lambdas for smaller bundle size.
* https://webpack.js.org/migrate/5/#need-to-support-an-older-browser-like-ie-11
*/
const target = ['web', 'es5'];

module.exports = {
webpack,

Expand Down Expand Up @@ -82,6 +89,7 @@ module.exports = {
pathinfo: false,
},
module,
target,
devtool,
plugins: getPlugins(packageName, false),
},
Expand All @@ -101,6 +109,7 @@ module.exports = {
},

module,
target,
devtool: excludeSourceMaps ? undefined : devtool,
plugins: getPlugins(packageName, true, profile),
},
Expand Down Expand Up @@ -263,6 +272,8 @@ module.exports = {
...(process.env.TF_BUILD || process.env.SKIP_TYPECHECK ? [] : [new ForkTsCheckerWebpackPlugin()]),
...(process.env.TF_BUILD || process.env.LAGE_PACKAGE_NAME ? [] : [new webpack.ProgressPlugin({})]),
],

target,
},
customConfig,
);
Expand Down
Loading

0 comments on commit b841037

Please sign in to comment.