Skip to content

Commit

Permalink
Use the @babel/preset-env to selecte working list of browser
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 14, 2023
1 parent 35c3b1b commit ab6d8f4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
10 changes: 7 additions & 3 deletions buildtools/webpack.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ module.exports = (env, argv) => {
options: {
babelrc: false,
comments: false,
plugins: [
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
presets: [
'@babel/preset-env',
{
targets: require('./webpack.share').browsers,
modules: false,
loose: true,
},
],
},
},
Expand Down
24 changes: 12 additions & 12 deletions buildtools/webpack.commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ module.exports = function (config) {
$: 'jquery',
});

const babelPresetEnv = [
require.resolve('@babel/preset-env'),
{
targets: config.browsers || require('./webpack.share').browsers,
loose: true,
},
];

// Expose corejs-typeahead as window.Bloodhound
const typeaheadRule = {
test: require.resolve('corejs-typeahead'),
Expand Down Expand Up @@ -144,16 +152,14 @@ module.exports = function (config) {
assumptions: {
setPublicClassFields: true,
},
presets: [babelPresetEnv],
plugins: [
[
require.resolve('@babel/plugin-transform-typescript'),
// TODO remove allowDeclareFields with Babel 8
{allowDeclareFields: true},
],
[require.resolve('@babel/plugin-proposal-decorators'), {decoratorsBeforeExport: true}],
require.resolve('@babel/plugin-proposal-class-properties'),
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
],
},
},
Expand All @@ -173,11 +179,8 @@ module.exports = function (config) {
options: {
babelrc: false,
comments: false,
plugins: [
require.resolve('babel-plugin-angularjs-annotate'),
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
],
presets: [babelPresetEnv],
plugins: [require.resolve('babel-plugin-angularjs-annotate')],
},
},
};
Expand All @@ -200,10 +203,7 @@ module.exports = function (config) {
options: {
babelrc: false,
comments: false,
plugins: [
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
],
presets: [babelPresetEnv],
},
},
};
Expand Down
12 changes: 9 additions & 3 deletions buildtools/webpack.config.dll.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ module.exports = {
options: {
babelrc: false,
comments: false,
plugins: [
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
presets: [
[
require.resolve('@babel/preset-env'),
{
targets: require('./webpack.share').browsers,
modules: false,
loose: true,
},
],
],
},
},
Expand Down
25 changes: 25 additions & 0 deletions buildtools/webpack.share.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The MIT License (MIT)
//
// Copyright (c) 2018-2023 Camptocamp SA
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

module.exports = {
// see: npx browserslist '> 0.7% in CH or > 0.7% in FR or Firefox ESR'
browsers: 'defaults, > 0.1% in CH, > 0.1% in FR, Firefox ESR and supports es6-class and not iOS < 10',
};

0 comments on commit ab6d8f4

Please sign in to comment.