babel-preset-playlyfe
Version:
Babel preset for playlyfe
48 lines (35 loc) • 1.74 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.DEFAULT_OPTS = exports.Opts = void 0;
var _presetReact = _interopRequireDefault(require("@babel/preset-react"));
var _babelPluginReactIntl = _interopRequireDefault(require("babel-plugin-react-intl"));
var _flowRuntime = _interopRequireDefault(require("flow-runtime"));
const Opts = _flowRuntime.default.type("Opts", _flowRuntime.default.exactObject(_flowRuntime.default.property("reactIntl", _flowRuntime.default.boolean()), _flowRuntime.default.property("useBuiltIns", _flowRuntime.default.boolean()), _flowRuntime.default.property("development", _flowRuntime.default.boolean())));
exports.Opts = Opts;
const DEFAULT_OPTS = Opts.assert(Object.freeze({
reactIntl: true,
useBuiltIns: true,
development: false
}));
exports.DEFAULT_OPTS = DEFAULT_OPTS;
var _default = _flowRuntime.default.annotate((context, opts) => {
let _contextType = _flowRuntime.default.any();
let _optsType = Opts;
_flowRuntime.default.param("context", _contextType).assert(context);
_flowRuntime.default.param("opts", _optsType).assert(opts);
return {
presets: [[_presetReact.default, {
development: opts.development,
useBuiltIns: opts.useBuiltIns
}]],
plugins: [// react-intl support
opts.reactIntl ? [_babelPluginReactIntl.default, {
enforceDescriptions: false,
extractFromFormatMessageCall: true
}] : null].filter(Boolean)
};
}, _flowRuntime.default.function(_flowRuntime.default.param("context", _flowRuntime.default.any()), _flowRuntime.default.param("opts", Opts)));
exports.default = _default;