Skip to content

Commit

Permalink
Run playground Gen1/2 in IE11 (#3599)
Browse files Browse the repository at this point in the history
OKTA-714198 Adds script `start:ie11`
  • Loading branch information
denysoblohin-okta committed Apr 17, 2024
1 parent 1858480 commit f999c2b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"build:webpack-dev": "webpack --config webpack.dev.config.js",
"build:webpack-release": "webpack --config webpack.release.config.js",
"start": "node scripts/buildtools start",
"start:ie11": "IE11_COMPAT_MODE=true OKTA_SIW_HOST=0.0.0.0 ENTRY=default yarn start --watch",
"start:test:app": "yarn workspace @okta/test.app start",
"mock:device-authenticator": "dyson playground/mocks/spec-device-authenticator/ 6512",
"clean:types": "grunt clean:types",
Expand Down
10 changes: 10 additions & 0 deletions webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function({
cdn = true,
useBuiltIns = false,
}) {
/* eslint complexity: [2, 11] */

// normalize entry so it is always an array
entry = Array.isArray(entry) ? entry : [entry];
Expand Down Expand Up @@ -53,6 +54,15 @@ module.exports = function({
corejs: '3.9',
} : {}
]);
} else if (process.env.IE11_COMPAT_MODE === 'true') {
babelOptions.presets.unshift([
'@babel/preset-env',
{
targets: {
ie: '11'
},
}
]);
} else {
// In local development, we would prefer not to include any babel transforms as they make debugging more difficult
// However, there is an issue with testcafe which requires us to include the optional chaining transform
Expand Down
3 changes: 3 additions & 0 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ module.exports = (env = {}) => {
usePolyfill(webpackConfig);
} else {
webpackConfig.optimization.minimize = false;
if (process.env.IE11_COMPAT_MODE === 'true' && entryName === 'default') {
usePolyfill(webpackConfig);
}
}

if (env.mockDuo) {
Expand Down
18 changes: 17 additions & 1 deletion webpack.playground.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ if (!process.env.DISABLE_CSP) {
headers['Content-Security-Policy'] = csp;
}

const hotReloadOptions = process.env.IE11_COMPAT_MODE === 'true' ? {
hot: false,
liveReload: false,
webSocketServer: false,
} : {};

module.exports = {
mode: 'development',
target: 'web',
Expand Down Expand Up @@ -81,14 +87,24 @@ module.exports = {
presets: [
// preset-env is disabled for a better debugging experience.
// It can be enabled if necessary to run playground on IE11
// '@babel/preset-env',
...(process.env.IE11_COMPAT_MODE === 'true' ? [
[
'@babel/preset-env',
{
targets: {
ie: '11'
}
}
]
] : []),
'@babel/preset-typescript' // must run before preset-env: https://github.com/babel/babel/issues/12066
]
}
},
]
},
devServer: {
...hotReloadOptions,
host: HOST,
watchFiles: [...staticDirs],
static: [
Expand Down

0 comments on commit f999c2b

Please sign in to comment.