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

sample project does not compile #120

Closed
bleonard opened this issue Nov 4, 2015 · 8 comments
Closed

sample project does not compile #120

bleonard opened this issue Nov 4, 2015 · 8 comments
Assignees

Comments

@bleonard
Copy link

bleonard commented Nov 4, 2015

ran this : react-native bundle --minify

Building package...
transforming [========================================] 100% 335/335
Build complete
/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/promise/lib/done.js:10
      throw err;
      ^

Error: Error while minifying JS
Transformed code line: "for(var _callback of this[listenersKey]) {"
Module name (best guess): realm/realm.js
Unexpected token name «of», expected punc «;» (line: 54365, col: 18, pos: 998341)

Error
    at new JS_Parse_Error (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1508:18)
    at js_error (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1516:11)
    at croak (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2008:9)
    at token_error (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2016:9)
    at expect_token (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2029:9)
    at expect (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2032:36)
    at regular_for (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2262:9)
    at for_ (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2258:16)
    at eval (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2140:24)
    at eval (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2055:24)
    at block_ (eval at <anonymous> (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2335:20)
    at Bundle.getMinifiedSourceAndMap (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/packager/react-packager/src/Bundler/Bundle.js:150:13)
    at Bundle.getSource (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/packager/react-packager/src/Bundler/Bundle.js:101:19)
    at /Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/local-cli/bundle.js:55:36
    at tryCallOne (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/brian/github/realm-js/examples/ReactExample/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
@bleonard
Copy link
Author

bleonard commented Nov 4, 2015

i believe the version react native puts on the phone doesn't support of yet.

@appden
Copy link
Contributor

appden commented Nov 4, 2015

Looks like a known bug with React Native (facebook/react-native#1499). I'll check into a workaround.

@appden
Copy link
Contributor

appden commented Nov 4, 2015

It fails because they haven't configured babel to transform for of loops, which works at least on iOS 9, but it makes UglifyJS choke. They reopened the issue at my request.

@bleonard
Copy link
Author

bleonard commented Nov 5, 2015

so we are supporting iOS 8. Is realm going to work with that. Are you sure you shouldn't just use in for better support?

@alazier
Copy link
Contributor

alazier commented Nov 5, 2015

Yeah, we should probably switch back to using in until of is officially supported.

@kristiandupont
Copy link
Contributor

..or we could reconsider lodash. I know you are not fans but I have to say that little lib has made js development more enjoyable for me many times. You can even require it on a per-feature basis so it doesn't add too much overhead.

appden added a commit that referenced this issue Nov 6, 2015
The React Native packager does not transform for-of loops, and minification step uses UglifyJS, which does not yet support ES6 syntax.

Fixes #120
@appden appden self-assigned this Nov 6, 2015
@appden
Copy link
Contributor

appden commented Nov 6, 2015

@bleonard in iterates over keys whereas of iterates of values. It turns out that iOS 8 actually does support for-of loops, but since --minify uses UglifyJS (which does not), I removed our uses of for of loops in favor of forEach in PR #125.

@bleonard
Copy link
Author

bleonard commented Nov 6, 2015

thanks.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants