{"id":19136,"library":"babel-plugin-react-native-electron","title":"babel-plugin-react-native-electron","description":"A Babel plugin (v0.2.0, stable) that resolves imports for react-native-electron, enabling React Native components to run in Electron. It remaps react-native imports to react-native-electron and optionally transforms to CommonJS. Needed when targeting Electron with React Native codebases. Rarely updated but fills a specific niche.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/mybigday/babel-plugin-react-native-electron","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-react-native-electron","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-react-native-electron","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-react-native-electron","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Babel plugins are CommonJS modules; they cannot be imported via ESM in .babelrc.","wrong":"import plugin from 'babel-plugin-react-native-electron'","symbol":"default","correct":"module.exports = function(babel) { ... }"},{"note":"Without the options array, the plugin may not be configured correctly.","wrong":"{\"plugins\": [\"react-native-electron\"]}","symbol":"config in .babelrc","correct":"{\"plugins\": [[\"react-native-electron\", { commonjs: true }]]}"},{"note":"Use the full string (with babel-plugin- prefix) or the shorthand 'react-native-electron'.","wrong":"module.exports = { plugins: ['babel-plugin-react-native-electron'] }","symbol":"require in babel.config.js","correct":"module.exports = { plugins: [['babel-plugin-react-native-electron', { commonjs: true }]] }"}],"quickstart":{"code":"{\n  \"plugins\": [\n    [\"react-native-electron\", { \"commonjs\": true }]\n  ]\n}","lang":"javascript","description":"Add the plugin to your Babel config with the commonjs option."},"warnings":[{"fix":"Run 'yarn add react-native-electron' or 'npm install react-native-electron'.","message":"The plugin requires react-native-electron to be installed separately.","severity":"gotcha","affected_versions":"all"},{"fix":"Configure Webpack target: 'electron-renderer' and add node: { __dirname: false, __filename: false }.","message":"The plugin only transforms imports/exports; it does not polyfill Node.js APIs (e.g., fs, path). You may need additional Webpack config or electron-renderer-target.","severity":"gotcha","affected_versions":"all"},{"fix":"Add a CSS loader and file-loader/asset modules to your Webpack config.","message":"The plugin does not handle CSS or asset imports; those must be processed separately (e.g., with Webpack).","severity":"gotcha","affected_versions":"all"},{"fix":"N/A","message":"No known breaking changes or deprecations.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'babel':2,8 'babel-plugin-react-native-electron':1 'codebas':51 'commonj':43 'compon':23 'electron':6,19,27,38,47 'enabl':20 'fill':55 'import':14,33 'javascript':59 'nativ':5,18,22,32,37,50 'need':44 'nich':58 'option':40 'plugin':3,9 'rare':52 'react':4,17,21,31,36,49 'react-nat':30 'react-native-electron':16,35 'remap':29 'resolv':13 'run':25 'specif':57 'stabl':11 'target':46 'transform':41 'updat':53 'v0.2.0':10","created_at":"2026-04-25T11:16:13.460607+00:00","updated_at":"2026-04-25T11:16:13.460607+00:00","problems":[{"fix":"Ensure babel-plugin-react-native-electron is in your plugins array (e.g., .babelrc or babel.config.js) and that Babel is running on the affected files.","cause":"Babel is not transforming imports, so webpack tries to resolve 'react-native' directly (which fails in Electron).","error":"Module not found: Can't resolve 'react-native' in '...'"},{"fix":"Add @babel/preset-env or @babel/plugin-transform-modules-commonjs to your Babel config.","cause":"Babel is not configured to handle ES module syntax for the plugin target.","error":"SyntaxError: Unexpected token import (or require)"},{"fix":"Set nodeIntegration: true and contextIsolation: false in the BrowserWindow options, or use preload scripts.","cause":"Electron's renderer process does not have a DOM window during initialization if nodeIntegration is false or contextIsolation is true.","error":"window is not defined (ReferenceError)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mybigday/babel-plugin-react-native-electron","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-plugin-react-native-electron","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}