"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const babel_merge_1 = __importDefault(require("babel-merge"));
const micro_core_1 = require("@vtex/micro-core");
class Build extends micro_core_1.BuildPlugin {
    constructor() {
        super(...arguments);
        this.getBabelConfig = async (previous, target) => {
            // TODO: Be able to include this plugin for es6
            const loadablePlugin = target === 'es6' ? [] : [require.resolve('@loadable/babel-plugin')];
            return babel_merge_1.default(previous, {
                presets: [
                    [
                        require.resolve('@babel/preset-react'),
                        {
                            useBuiltIns: true,
                        },
                    ],
                ],
                plugins: [
                    require.resolve('@babel/plugin-syntax-dynamic-import'),
                    ...loadablePlugin,
                ],
            });
        };
    }
}
exports.default = Build;
