Skip to content

Commit b841037

Browse files
authored
Fix website and legacy demo in IE 11 (#19237)
1 parent 5369d33 commit b841037

6 files changed

+197
-265
lines changed

apps/test-bundles/webpack.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const {
88
createEntry,
99
} = require('./webpackUtils');
1010

11-
const package = process.env.PACKAGE;
11+
const packageName = process.env.PACKAGE;
1212

1313
let entries;
14-
if (package === '@fluentui/react-northstar') {
14+
if (packageName === '@fluentui/react-northstar') {
1515
createFluentNorthstarFixtures();
1616
entries = buildEntries('@fluentui/react-northstar');
17-
} else if (package === '@fluentui/react') {
17+
} else if (packageName === '@fluentui/react') {
1818
createFluentReactFixtures();
1919
createEntry('@fluentui/keyboard-key');
2020

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

27-
module.exports = createWebpackConfig(entries);
27+
module.exports = createWebpackConfig(entries, packageName);

apps/test-bundles/webpackUtils.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const TerserPlugin = require('terser-webpack-plugin');
77

88
const FIXTURE_PATH = 'temp/fixtures/';
99

10-
function createWebpackConfig(entries) {
10+
function createWebpackConfig(entries, packageName) {
1111
return Object.keys(entries).map(entryName => {
12+
/** @type {BundleAnalyzerPlugin.Options} */
1213
let anaylizerPluginOptions = {
1314
analyzerMode: 'static',
1415
reportFilename: entryName + '.stats.html',
@@ -29,7 +30,7 @@ function createWebpackConfig(entries) {
2930
modules: true,
3031

3132
builtAt: false,
32-
outputPath: false,
33+
.../** @type {*} */ ({ outputPath: false }),
3334
namedChunkGroups: false,
3435
logging: false,
3536
children: false,
@@ -45,7 +46,7 @@ function createWebpackConfig(entries) {
4546
};
4647
}
4748

48-
return resources.createConfig(
49+
const config = resources.createConfig(
4950
entryName,
5051
true,
5152
{
@@ -69,6 +70,11 @@ function createWebpackConfig(entries) {
6970
true,
7071
true,
7172
)[0];
73+
if (packageName === '@fluentui/react-northstar') {
74+
// This is used most of the configs for IE 11 compat, which northstar doesn't need
75+
delete config.target;
76+
}
77+
return config;
7278
});
7379
}
7480

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix website and legacy demo in IE 11",
4+
"packageName": "@fluentui/react",
5+
"email": "elcraig@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@
216216
"typescript": "4.1.5",
217217
"webpack": "5.44.0",
218218
"webpack-bundle-analyzer": "4.4.2",
219-
"webpack-cli": "4.3.1",
219+
"webpack-cli": "4.7.2",
220220
"webpack-dev-middleware": "4.2.0",
221-
"webpack-dev-server": "4.0.0-beta.0",
221+
"webpack-dev-server": "4.0.0-rc.0",
222222
"webpack-hot-middleware": "2.25.0",
223223
"webpack-merge": "5.7.3",
224224
"workspace-tools": "0.12.3",

scripts/webpack/webpack-resources.js

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const cssRule = {
3030
use: ['style-loader', 'css-loader'],
3131
};
3232

33+
/**
34+
* As of webpack 5, you have to add the `es5` target for IE 11 compatibility.
35+
* Otherwise it will output lambdas for smaller bundle size.
36+
* https://webpack.js.org/migrate/5/#need-to-support-an-older-browser-like-ie-11
37+
*/
38+
const target = ['web', 'es5'];
39+
3340
module.exports = {
3441
webpack,
3542

@@ -82,6 +89,7 @@ module.exports = {
8289
pathinfo: false,
8390
},
8491
module,
92+
target,
8593
devtool,
8694
plugins: getPlugins(packageName, false),
8795
},
@@ -101,6 +109,7 @@ module.exports = {
101109
},
102110

103111
module,
112+
target,
104113
devtool: excludeSourceMaps ? undefined : devtool,
105114
plugins: getPlugins(packageName, true, profile),
106115
},
@@ -263,6 +272,8 @@ module.exports = {
263272
...(process.env.TF_BUILD || process.env.SKIP_TYPECHECK ? [] : [new ForkTsCheckerWebpackPlugin()]),
264273
...(process.env.TF_BUILD || process.env.LAGE_PACKAGE_NAME ? [] : [new webpack.ProgressPlugin({})]),
265274
],
275+
276+
target,
266277
},
267278
customConfig,
268279
);

0 commit comments

Comments
 (0)