Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = config => {
const presets = config.babelLoaderPresets || [];
presets.unshift(stage0Preset);
presets.unshift(es2015Preset);
if (config.flow) presets.push(flowPreset);
const plugins = config.babelLoaderPlugins || [];
plugins.unshift([importPlugin.default, config.import || []]);
plugins.unshift(transformReactJsx);
if (config.flowRuntime) plugins.push([flowRuntimePlugin.default, { assert: !0, annotate: !0 }]);
const loader = {
loader: 'babel-loader',
test: /\.(js|jsx)$/,
options: {
presets,
plugins,
},
};
config.babelLoaderExclude && (loader.exclude = config.babelLoaderExclude);
return loader;
};
constructor(props) {
super(props);
this._babelPlugin = {
configFile: false,
babelrc: false,
comments: false,
ast: true,
plugins: [
[
require('@babel/plugin-syntax-class-properties'),
{ loose: true }
],
require('@babel/plugin-proposal-object-rest-spread'),
[
require('babel-plugin-import').default,
{
libraryName: 'schnee-ui',
libraryDirectory: 'components',
camel2DashComponentName: false
}
],
require('@babel/plugin-syntax-jsx'),
require('../../packages/babelPlugins/transformIfImport'),
require('../../packages/babelPlugins/h5/transformH5')
]
};
if (this.componentType === 'App') {
this._babelPlugin.plugins.push(require('../../packages/babelPlugins/h5/transformH5App'));
}
else if (this.componentType === 'Page') {
this._babelPlugin.plugins.push(require('../../packages/babelPlugins/h5/transformH5Page'));