Skip to content

Instantly share code, notes, and snippets.

@anthumchris
Last active May 3, 2023 11:16
Show Gist options
  • Select an option

  • Save anthumchris/249d741b64081f88db7938f502855447 to your computer and use it in GitHub Desktop.

Select an option

Save anthumchris/249d741b64081f88db7938f502855447 to your computer and use it in GitHub Desktop.
Use Webpack 5 and Babel 7 to create JavaScript bundle for Internet Explorer 11 (IE11, IE 11)
export default 'Hello!'
/*
* Test file for IE 11 that uses modern JavaScript
*/
import greeting from './Greeting'
window.addEventListener('load', async () => {
const o = {
greeting: await Promise.resolve(greeting)
}
console.log(
o,
Object.entries(o),
Object.keys(o),
Object.values(o),
)
})
{
"browserslist": [
"ie 11"
],
"scripts": {
"dev": "webpack -w",
"build": "webpack"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"babel-loader": "^8.2.2",
"core-js": "^3.8.0",
"webpack": "^5.8.0",
"webpack-cli": "^4.2.0"
}
}
module.exports = {
entry: './index.js',
module: {
rules: [{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
useBuiltIns: 'usage',
corejs: 3
}]
]
}
}
}]
}
}
@grdhog
Copy link
Copy Markdown

grdhog commented May 3, 2023

Still useful 2023. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment