Skip to content

Commit

Permalink
Update babel config for esm target (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Aug 24, 2023
1 parent b1df561 commit a9e1145
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 17 additions & 3 deletions modules/dev-tools/src/configuration/get-babel-config.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
/** @typedef {import('./get-babel-config')} types */
const deepMerge = require('deepmerge');
const {inspect} = require('util');

// The following targets are designed to support the most commonly used evergreen browsers.
// As of Feb 2021 they all support async function, async iterator, and spread operator.
const ES5_TARGETS = ['>0.2%', 'maintained node versions', 'not ie 11', 'not dead', 'not chrome 49'];
const ESM_TARGETS = ['>0.2% and supports async-functions', 'maintained node versions', 'not dead'];
// Reduce verbosity
const ESM_PLUGIN_BLACKLIST = [
// Template literals are supported in all latest versions of environments
'@babel/plugin-transform-template-literals'
];

const DEFAULT_CONFIG = {
comments: false
comments: false,
// These settings reduce the verbosity of transpile outputs
assumptions: {
// When declaring classes, assume that methods don't shadow getters on the superclass and that the program doesn't depend on methods being non-enumerable.
setClassMethods: true,
// When using public class fields, assume that they don't shadow any getter in the current class, in its subclasses or in its superclass.
setPublicClassFields: true
}
};

const COMMON_PRESETS = [
Expand Down Expand Up @@ -41,6 +54,7 @@ const ENV_CONFIG = {
'@babel/env',
{
targets: ESM_TARGETS,
exclude: ESM_PLUGIN_BLACKLIST,
modules: false
}
]
Expand All @@ -59,6 +73,7 @@ const ENV_CONFIG = {
'@babel/env',
{
targets: ESM_TARGETS,
exclude: ESM_PLUGIN_BLACKLIST,
modules: false
}
]
Expand Down Expand Up @@ -112,8 +127,7 @@ module.exports.getBabelConfig = function getBabelConfig(options = {}) {
}

if (options.debug) {
// eslint-disable-next-line
console.log(config);
console.log(inspect(config, {colors: true, depth: null}));
}

return config;
Expand Down
3 changes: 2 additions & 1 deletion modules/dev-tools/src/configuration/get-eslint-config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const typescriptConfigs = require('@typescript-eslint/eslint-plugin').configs;
const deepMerge = require('deepmerge');
const {getValidPath} = require('../utils/utils.cjs');
const {inspect} = require('util');

const DEFAULT_OPTIONS = {
react: false
Expand Down Expand Up @@ -165,7 +166,7 @@ module.exports.getESLintConfig = function getESLintConfig(options = {}) {
}
if (options.debug) {
// eslint-disable-next-line
console.log(config);
console.log(inspect(config, {colors: true, depth: null}));
}

return config;
Expand Down

0 comments on commit a9e1145

Please sign in to comment.