sullvn / tastes

Visualize software behavior with intelligent sampling

Home Page:https://sullvn.github.io/tastes/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot import React components in Node

sullvn opened this issue · comments

There's an error which occurs during import of the SamplesList component in Node:

/error-example/node_modules/react-native-web/dist/exports/StyleSheet/ReactNativeStyleResolver.js:17
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
       ^

SyntaxError: Unexpected token {
...

This is probably due to Node's missing support for ES modules and the associated syntax. tastes uses react-primitives which in turn uses react-native-web. Somewhere on that import path the ES modules version of react-native-web is used instead of the CommonJS version.

The issue occurs here:

https://github.com/lelandrichardson/react-primitives/blob/deba9285db148e2815821ab411a1f5033fcece94/src/injection/react-native-web.js#L19

react-primitives is hardcoded to import the ES modules version of react-native-web for that specific file.