| Server IP : 107.13.46.68 / Your IP : 216.73.216.232 Web Server : Apache/2.4.58 (Ubuntu) System : Linux mariOS 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/node_modules/babel-preset-moxy/ |
Upload File : |
'use strict';
const moduleTransformations = require('@babel/preset-env/lib/module-transformations').default;
const addDynamicImportSupport = require('./lib/dynamic-import');
const addReactSupport = require('./lib/react');
const addLodashSupport = require('./lib/lodash');
module.exports = (context, options) => {
options = Object.assign({
react: false,
lodash: true,
dynamicImport: true,
modules: process.env.BABEL_ENV === 'es' ? false : 'commonjs', // Usually set to `commonjs` or `false`
namedDefaultExport: null,
}, options);
if (options.modules !== 'commonjs' && options.modules !== 'cjs' && options.namedDefaultExport) {
throw new Error('The `namedDefaultExport` option can only be enabled when `modules` is commonjs');
}
// Set `namedDefaultExport` default value based on `modules`
if (options.namedDefaultExport == null) {
options.namedDefaultExport = options.modules === 'commonjs';
}
const config = {
sourceType: 'unambiguous',
presets: [],
plugins: [],
};
// Activate modules transformation
if (moduleTransformations[options.modules]) {
config.plugins.push(`@babel/plugin-${moduleTransformations[options.modules]}`);
}
// The plugins below activate stage 3 features that babel hasn't added to the stage 3 preset yet
config.plugins.push(
// Allows class { handleClick = () => { } static propTypes = { foo: PropTypes.string } }
require.resolve('@babel/plugin-proposal-class-properties'),
// Allows obj?.x?.y?.z
require.resolve('@babel/plugin-proposal-optional-chaining'),
// Allows object.foo ?? 'bar'
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator')
);
// Adds dynamic import support
if (options.dynamicImport) {
addDynamicImportSupport(config, options.modules);
}
// Add react support without doing any development or production transformations
if (options.react) {
addReactSupport(config, null);
}
// Cherry-pick lodash modules for smaller bundles
if (options.lodash) {
addLodashSupport(config, options.lodash);
}
// Add `module.exports = default;`, see https://github.com/59naga/babel-plugin-add-module-exports
if (options.namedDefaultExport) {
config.plugins.push('babel-plugin-add-module-exports');
}
return config;
};