Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build application for web using babel-plugin-react-native-web #1274

Closed
xdmnl opened this issue Feb 5, 2020 · 3 comments
Closed
Labels

Comments

@xdmnl
Copy link

xdmnl commented Feb 5, 2020

Bug

I recently upgraded to react-native-web 0.12.0 and react-native-svg 11.0.1. Unfortunately, it broke my build using metro and babel-plugin-react-native-web (0.12.0).

Downgrading to react-native-svg 10.0.1 and react-natibe-web 0.11.7 fixes the issue.

Looking at the built files, it appears that the published package does not allow the babel plugin for react native web to rewrite the require added by #1240:

// In lib/commonjs/ReactNativeSVG.web.js
[...]
var createElement=require('react-native').unstable_createElement||require('react-native').createElement;
[...]

Environment info

React native info output:

System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 2.00 GB / 16.00 GB
    Shell: 5.7.1 - /usr/local/bin/zsh
  Binaries:
    Node: 12.14.1 - /var/folders/r_/4htv7dj10zjcpwslc3w0w1sh0000gp/T/yarn--1580943189690-0.6179425353021855/node
    Yarn: 1.16.0 - /var/folders/r_/4htv7dj10zjcpwslc3w0w1sh0000gp/T/yarn--1580943189690-0.6179425353021855/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  IDEs:
    Xcode: /undefined - /usr/bin/xcodebuild
  npmPackages:
    react: ^16.12.0 => 16.12.0
    react-native: ^0.61.5 => 0.61.5
✨  Done in 0.84s.

Library version: 11.0.1

Steps To Reproduce

  1. Install metro
  2. Add the babelconfig:
module.exports = {
  // The 'metro-react-native-babel-preset' preset is recommended to match React Native's packager
  presets: ['module:metro-react-native-babel-preset'],
  // Re-write paths to import only the modules needed by the app
  plugins: ['react-native-web']
};
  1. Run metro build ./index.ts --platform web --out ./index.web.js

As long as index.ts uses react-native-svg, the output error is

Error: Unable to resolve module `../Components/AccessibilityInfo/AccessibilityInfo` from `node_modules/react-native/Libraries/react-native/react-native-implementation.js`:
@msand
Copy link
Collaborator

msand commented Feb 29, 2020

I guess we should probably use this instead, and not support older versions of react-native-web anymore:
import { GestureResponderEvent, unstable_createElement as createElement } from 'react-native';

@msand msand added the bug label Feb 29, 2020
msand pushed a commit that referenced this issue Mar 4, 2020
# [12.0.0](v11.0.1...v12.0.0) (2020-03-04)

* fix!: #1262 default width and height on svg ([1d6798b](1d6798b)), closes [#1262](#1262)
* fix!: #1247 Animated view translation inside Svg tag ([0288d95](0288d95)), closes [#1247](#1247) [#1258](#1258)

### Bug Fixes

* **ios:** handle gradient and pattern transform when null ([715e9b8](715e9b8))
* **ios:** pod install error ([675df92](675df92))
* **web:** [#1274](#1274) Unable to build using babel-plugin-react-native-web ([80b5064](80b5064))
* removed missing unnecessary React headers import error caused by non-framework style import ([f795029](f795029))

### Performance Improvements

* optimize extraction of fill, stroke, responder, matrix & display ([279c3fc](279c3fc))
* optimize handling of font properties in G elements ([0fa4177](0fa4177))
* optimize handling of inherited styles ([363c1b4](363c1b4))
* optimize svg root prop handling, simplify element development ([f0cd11d](f0cd11d))

### BREAKING CHANGES

* default size might change if width or height is missing
* Behavior of native elements is reverted to pre v10
@msand
Copy link
Collaborator

msand commented Mar 8, 2020

@xdmnl Can you try with the latest version?

@msand
Copy link
Collaborator

msand commented Mar 8, 2020

Closing for now.

@msand msand closed this as completed Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants