UNPKG

@rnv/adapter

Version:

ReNative Adapters for babel, metro, next and other build configs

72 lines 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withRNVWebpack = exports.withRNVNext = exports.withRNVRNConfig = exports.withRNVMetro = exports.withRNVBabel = exports.withBabelPluginModuleResolver = void 0; var tslib_1 = require("tslib"); var fs_1 = tslib_1.__importDefault(require("fs")); var env = process === null || process === void 0 ? void 0 : process.env; var withBabelPluginModuleResolver = function (cnf) { return [ require.resolve('babel-plugin-module-resolver'), tslib_1.__assign({ root: [env.RNV_MONO_ROOT || '.'] }, (cnf || {})), ]; }; exports.withBabelPluginModuleResolver = withBabelPluginModuleResolver; var _withDefaultRNVBabel = function (cnf) { return (tslib_1.__assign({ retainLines: true, presets: [['@babel/preset-env', {}]], plugins: [(0, exports.withBabelPluginModuleResolver)()] }, cnf)); }; var withRNVBabel = function (cnf) { return function (api) { api.cache(true); if (env.RNV_ENGINE_PATH && !fs_1.default.existsSync(env.RNV_ENGINE_PATH)) { console.warn("Path to engine cannot be resolved: ".concat(env.RNV_ENGINE_PATH, ". Will use default one")); api.cache(false); return _withDefaultRNVBabel(cnf); } if (env.RNV_ENGINE_PATH) { var engine = require(env.RNV_ENGINE_PATH); api.cache(true); if (engine.withRNVBabel) { return engine.withRNVBabel(cnf); } } return cnf; }; }; exports.withRNVBabel = withRNVBabel; var withRNVMetro = function (cnf) { if (env.RNV_ENGINE_PATH) { var engine = require(env.RNV_ENGINE_PATH); if (engine.withRNVMetro) { return engine.withRNVMetro(cnf); } } return cnf; }; exports.withRNVMetro = withRNVMetro; var withRNVRNConfig = function (cnf) { if (env.RNV_ENGINE_PATH) { var engine = require(env.RNV_ENGINE_PATH); if (engine.withRNVRNConfig) { return engine.withRNVRNConfig(cnf); } } return cnf; }; exports.withRNVRNConfig = withRNVRNConfig; var withRNVNext = function (cnf) { if (env.RNV_ENGINE_PATH) { var engine = require(env.RNV_ENGINE_PATH); if (engine.withRNVNext) { return engine.withRNVNext(cnf); } } return cnf; }; exports.withRNVNext = withRNVNext; var withRNVWebpack = function (cnf) { if (env.RNV_ENGINE_PATH) { var engine = require(env.RNV_ENGINE_PATH); if (engine.withRNVWebpack) { return engine.withRNVWebpack(cnf); } } return cnf; }; exports.withRNVWebpack = withRNVWebpack; //# sourceMappingURL=adapters.js.map