Add custom webpack loader to reduce polyfills in axe code

pull/12726/head
Sage Abdullah 2024-12-20 18:52:56 +00:00
rodzic 0a8c121437
commit a80d8e449a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
2 zmienionych plików z 25 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,9 @@
export default function replaceAllLoader(source) {
const options = this.getOptions();
const { replace } = options;
let newSource = source;
Object.entries(replace).forEach(([oldString, newString]) => {
newSource = newSource.replaceAll(oldString, newString);
});
return newSource;
}

Wyświetl plik

@ -196,6 +196,22 @@ module.exports = function exports(env, argv) {
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /axe\.js$/,
loader: path.resolve(__dirname, 'string-replaceall-loader.js'),
options: {
replace: {
"!('hasOwn' in Object)": 'false',
"!('values' in Object)": 'false',
"!('Promise' in window)": 'false',
"!('Uint32Array' in window)": 'false',
"!('some' in window.Uint32Array.prototype)": 'false',
"!('reduce' in window.Uint32Array.prototype)": 'false',
"typeof Object.assign !== 'function'": 'false',
'if (!Array.from)': 'if (false)',
},
},
},
{
test: /\.(svg)$/i,
type: 'asset/inline',