Skip to content

Commit

Permalink
build: configure Babel with Browserslist
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 25, 2025
1 parent 2b2c173 commit f99f70b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
> 0.1% in GB and not dead
last 6 Chrome versions
last 6 Firefox versions
last 6 Edge versions
last 2 Samsung versions
Firefox ESR
Safari >= 11
iOS >= 11
IE 11

[node]
node 22
18 changes: 17 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
module.exports = {
presets: ['@babel/preset-env']
presets: [
[
'@babel/preset-env',
{
// Apply bug fixes to avoid transforms
bugfixes: true,

// Apply smaller "loose" transforms for browsers
loose: true
}
]
],
env: {
test: {
browserslistEnv: 'node'
}
}
}
6 changes: 5 additions & 1 deletion gulp/tasks/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { join, parse } = require('path')

const { babel } = require('@rollup/plugin-babel')
const commonjs = require('@rollup/plugin-commonjs')
const nodeResolve = require('@rollup/plugin-node-resolve')
const terser = require('@rollup/plugin-terser')
Expand All @@ -24,7 +25,10 @@ function compileScripts(assetPath, { srcPath, destPath, output = {} }) {
jquery: 'window.jQuery'
}),
nodeResolve(),
commonjs()
commonjs(),
babel({
babelHelpers: 'bundled'
})
]
})

Expand Down
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@babel/preset-env": "^7.26.7",
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.4",
Expand Down

0 comments on commit f99f70b

Please sign in to comment.