UNPKG

@rnv/engine-rn-next

Version:

ReNative Engine to build next based platforms with react native support.

75 lines 3.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withRNVNext = void 0; var tslib_1 = require("tslib"); var withImages = require('next-images'); var withFonts = require('next-fonts'); var webpack_1 = require("webpack"); function _withRNWNext(nextConfig) { if (nextConfig === void 0) { nextConfig = {}; } return tslib_1.__assign(tslib_1.__assign({}, nextConfig), { webpack: function (config, options) { var _a, _b; // Mix in aliases if (!config.resolve) { config.resolve = {}; } config.resolve.alias = tslib_1.__assign(tslib_1.__assign({}, (config.resolve.alias || {})), { // Alias direct react-native imports to react-native-web 'react-native$': 'react-native-web', // Alias internal react-native modules to react-native-web 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter$': 'react-native-web/dist/vendor/react-native/EventEmitter/RCTDeviceEventEmitter', 'react-native/Libraries/vendor/emitter/EventEmitter$': 'react-native-web/dist/vendor/react-native/vendor/emitter/EventEmitter', 'react-native/Libraries/EventEmitter/NativeEventEmitter$': 'react-native-web/dist/vendor/react-native/EventEmitter/NativeEventEmitter' }); config.resolve.extensions = tslib_1.__spreadArray([ '.web.js', '.web.jsx', '.web.ts', '.web.tsx' ], ((_b = (_a = config.resolve) === null || _a === void 0 ? void 0 : _a.extensions) !== null && _b !== void 0 ? _b : []), true); if (!config.plugins) { config.plugins = []; } // Expose __DEV__ from Metro. config.plugins.push(new webpack_1.DefinePlugin({ __DEV__: JSON.stringify(process.env.NODE_ENV !== 'production'), })); // Execute the user-defined webpack config. if (typeof nextConfig.webpack === 'function') { return nextConfig.webpack(config, options); } return config; } }); } //TODO: https://turbo.build/pack/docs/features/customizing-turbopack var withRNVNext = function (config) { var cnf = tslib_1.__assign(tslib_1.__assign({ // can be overwritten by user distDir: process.env.NEXT_DIST_DIR }, config), { images: tslib_1.__assign({ disableStaticImages: true }, ((config === null || config === void 0 ? void 0 : config.images) || {})), webpack: function (cfg, props) { var isServer = props.isServer; if (!cfg.resolve) { cfg.resolve = {}; } if (process.env.RNV_EXTENSIONS) { cfg.resolve.extensions = process.env.RNV_EXTENSIONS.split(',') .map(function (e) { return ".".concat(e); }) .filter(function (ext) { return isServer || !ext.includes('server.'); }); } if (typeof config.webpack === 'function') { return config.webpack(cfg, props); } return cfg; } }); if (process.env.NEXT_EXPORT === 'true') { cnf.output = 'export'; } var transModules = []; var cnf1 = _withRNWNext(withFonts(withImages(cnf))); if (process.env.RNV_EXTENSIONS) { cnf1.pageExtensions = process.env.RNV_EXTENSIONS.split(','); } if (process.env.RNV_NEXT_TRANSPILE_MODULES) { transModules = process.env.RNV_NEXT_TRANSPILE_MODULES.split(','); cnf1.transpilePackages = transModules; } return cnf1; }; exports.withRNVNext = withRNVNext; //# sourceMappingURL=nextAdapter.js.map