-
Notifications
You must be signed in to change notification settings - Fork 21
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
Feature: eeg-pipes in React Native #31
Comments
Hey there! This is exciting stuff. I'm glad to see someone using the pipes on mobile! This is an issue because the eeg pipes build process only produces code with ES6 syntax. That's been fine for us in the past running node, web, and Electron projects in the past, but maybe we should extend that by compiling all the way to vanilla JS? @alexcastillo One workaround that may work for your app is to include @neurosity/pipes in your babel transpilation. Something like this might do it: babel/babel-loader#171 |
Hey @elmines, Thanks for opening an issue. What version of React Native are you running? According to the docs, es6 is supported: https://facebook.github.io/react-native/docs/javascript-environment |
Thank you, @alexcastillo; I am running React Native 0.57.3, the latest release. I don't think this is due to some breaking change in React Native, because I had this same issue with version 0.55.4. I played some with the Babel transpiler before, but I will take another look. |
I can now say with near certainty that Babel is not overlooking eeg-pipes; the issue is that it is not transpiling any of the ES6 code inside the eval() statements. I've replicated this error with a tiny module that does something similar: "use strict";
const messages = ["Wow, I love new ECMAScript syntax tricks", "Don't you?"];
messages.forEach(element => console.log(element));
eval(" const warning = \"Apparently React Native doesn\'t transpile code inside of eval()\"; console.log(warning); "); That The easiest (but perhaps crudest) solution I can currently think of is an additional distribution with the eval() statements already executed. |
Good detective work. So, those eval statements are how the UMD module system handles importing dependencies. Ideally, in a way that should support both browser and Node (and React Native). Before we get too deep in troubleshooting our build configuration or generating another distribution, can you check that this issue isn't because you're on an old version of node? https://stackoverflow.com/questions/36789889/syntaxerror-use-of-const-in-strict-mode const and let should be able to be used in strict mode in the newest version of node, I believe |
I actually did consider that and upgraded to Node 11.0.0. I'm currently looking into a Babel plugin that also transforms code inside eval() statements: https://babeljs.io/docs/en/babel-plugin-transform-eval |
Hmmm ok. Don't worry about that babel plugin, the problem is on our side with our umd config then. Until we fix it, try pointing your app to our other bundles instead. You can do that by changing eeg pipes package.json |
I actually did try out the other bundles and encountered the same issue. By all means let me know if there is any way I can help; I don't want to make a feature request without being willing to pitch in. |
Since React Native has its own Babel transformations, its sufficient to just produce a distribution in ES6, as long as it has no code in eval() statements. My changes can be summarized as follows:
That said, it is apparently difficult to install the exact packages in the yarn.lock file; so I fear that the slight version changes to the installed packages (in addition to my changing the webpack-cli dependency) could break the code on other machines. I have a commit at elmines@7932778. I'm happy to make whatever modifications are necessary before a pull request. EDIT: I did not have all my faculties writing this late yesterday evening. While it does still work to just import the src/index.js file in ES6, what I did was produce a transpiled dist/eeg-pipes.react.js without eval() statements. |
I am utilizing eeg-pipes in conjunction with a React Native Android app. I love eeg-pipes's API, but Babel doesn't run unless I have a debugger window open in the browser:
I presume the transpiler needs a browser window to run? I am quite new to front-end and am more than willing to add this feature myself and do a pull request; I may need a suggestion regarding where to start, however.
The text was updated successfully, but these errors were encountered: