Improve Babel configuration and automatically load polyfills (#27333)
parent
9c8891b39a
commit
0e3401bc1c
@ -1,5 +1,5 @@
|
||||
# Node.js
|
||||
NODE_ENV=tests
|
||||
# In test, compile the NodeJS code as if we are in production
|
||||
NODE_ENV=production
|
||||
# Federation
|
||||
LOCAL_DOMAIN=cb6e6126.ngrok.io
|
||||
LOCAL_HTTPS=true
|
||||
|
@ -1,30 +0,0 @@
|
||||
import 'core-js/features/object/assign';
|
||||
import 'core-js/features/object/values';
|
||||
import 'core-js/features/symbol';
|
||||
import 'core-js/features/promise/finally';
|
||||
import { decode as decodeBase64 } from '../utils/base64';
|
||||
|
||||
if (!Object.hasOwn(HTMLCanvasElement.prototype, 'toBlob')) {
|
||||
const BASE64_MARKER = ';base64,';
|
||||
|
||||
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
||||
value: function (
|
||||
this: HTMLCanvasElement,
|
||||
callback: BlobCallback,
|
||||
type = 'image/png',
|
||||
quality: unknown,
|
||||
) {
|
||||
const dataURL: string = this.toDataURL(type, quality);
|
||||
let data;
|
||||
|
||||
if (dataURL.includes(BASE64_MARKER)) {
|
||||
const [, base64] = dataURL.split(BASE64_MARKER);
|
||||
data = decodeBase64(base64);
|
||||
} else {
|
||||
[, data] = dataURL.split(',');
|
||||
}
|
||||
|
||||
callback(new Blob([data], { type }));
|
||||
},
|
||||
});
|
||||
}
|
@ -1,2 +1 @@
|
||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
|
||||
import 'requestidlecallback';
|
||||
|
@ -1,27 +0,0 @@
|
||||
const { join } = require('path');
|
||||
|
||||
const { settings, env } = require('../configuration');
|
||||
|
||||
module.exports = {
|
||||
test: /\.(js|mjs)$/,
|
||||
include: /node_modules/,
|
||||
exclude: [
|
||||
/@babel(?:\/|\\{1,2})runtime/,
|
||||
/tesseract.js/,
|
||||
],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
babelrc: false,
|
||||
plugins: [
|
||||
'transform-react-remove-prop-types',
|
||||
],
|
||||
cacheDirectory: join(settings.cache_path, 'babel-loader-node-modules'),
|
||||
cacheCompression: env.NODE_ENV === 'production',
|
||||
compact: false,
|
||||
sourceMaps: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
||||
|
||||
const { merge } = require('webpack-merge');
|
||||
|
||||
const sharedConfig = require('./shared');
|
||||
|
||||
module.exports = merge(sharedConfig, {
|
||||
mode: 'production',
|
||||
});
|
Loading…
Reference in new issue