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

babel strict mode transform is not working with v0.26 #7700

Closed
formatlos opened this issue May 23, 2016 · 8 comments
Closed

babel strict mode transform is not working with v0.26 #7700

formatlos opened this issue May 23, 2016 · 8 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@formatlos
Copy link
Contributor

since v0.26 babel strict mode transform is not working anymore. I get different errors mostly of internal methods which try to use setters on read-only objects.

@jmurzy
Copy link
Contributor

jmurzy commented May 24, 2016

@formatlos Cannot reproduce. What errors are you seeing? Did you try running the packager with --reset-cache

@formatlos formatlos reopened this May 30, 2016
@formatlos
Copy link
Contributor Author

I tried everything from removing and re-installing node_modules, cleaning watcher, cleaning packager cache. The error occurs in polyfillLazyGlobal function in InitializeJavaScriptEngine.js line 82

error

@formatlos
Copy link
Contributor Author

seems that it doesn't work with WebSocket

@greg5green
Copy link

Also having the same problem over here. Errors include "Properties can only be defined on Objects." (same as @formatlos posted) and "Unhandled JS Exception: Module RCTLog is not a registered callable module."

@andrewbrereton
Copy link

I am also having the same issues.

When I Reload JS I will randomly see either of these errors:

Module RCTEventEmitter is not a registered callable module.

__callFunction
    index.ios.bundle?platform=ios&dev=true&hot=true @ 11456:10
<unknown>
    index.ios.bundle?platform=ios&dev=true&hot=true @ 11368:22
guard
    index.ios.bundle?platform=ios&dev=true&hot=true @ 11319:3
callFunctionReturnFlushedQueue
    index.ios.bundle?platform=ios&dev=true&hot=true @ 11367:6

Or this one:

Properties can only be defined on Objects.

set
    index.ios.bundle?platform=ios&dev=true&hot=true @ 28986:22
get
    index.ios.bundle?platform=ios&dev=true&hot=true @ 28983:12
setupDevtools
    index.ios.bundle?platform=ios&dev=true&hot=true @ 32834:18
setUpDevTools
    index.ios.bundle?platform=ios&dev=true&hot=true @ 29096:14
<unknown>
    index.ios.bundle?platform=ios&dev=true&hot=true @ 29123:14
loadModuleImplementation
    index.ios.bundle?platform=ios&dev=true&hot=true @ 127:8
guardedLoadModule
    index.ios.bundle?platform=ios&dev=true&hot=true @ 63:37
_require
    index.ios.bundle?platform=ios&dev=true&hot=true @ 54:18
<unknown>
    index.ios.bundle?platform=ios&dev=true&hot=true @ 100300:9

I am using react-native v0.27.1

My .babelrc:

{
  "presets": [
    "react",
    "es2015",
    "stage-1",
    "react-native-stage-0/decorator-support"
  ],
  "plugins": [
    "transform-decorators-legacy",
    "babel-plugin-transform-decorators-legacy"
  ]
}

@satya164
Copy link
Contributor

satya164 commented Jun 7, 2016

cc @janicduplessis

@janicduplessis
Copy link
Contributor

This happens because polyfillLazyGlobal uses a top level this and the transform-es2015-modules-commonjs replaces top level this with undefined to match the es module spec.

I'll submit a PR to use global instead of this and it will fix this issue. In the meantime you can use the babel-preset-react-native or make sure your transform-es2015-modules-commonjs transform has allowTopLevelThis set to true.

@ghost ghost closed this as completed in f9e26b3 Jun 13, 2016
MattFoley pushed a commit to skillz/react-native that referenced this issue Jun 17, 2016
Summary:
`polyfillLazyGlobal` used a top level this which get stripped by babel `transform-es2015-modules-commonjs` with the default config. This is mainly an issues for people not using the react native babel preset.

This also replaces a few GLOBAL with global for consistency with the rest of the file.

**Test plan**

Tested that there was an error when using `['transform-es2015-modules-commonjs', { strict: true, allowTopLevelThis: false }]` in the babel config and that it was fixed after applying my changes.

Fixes facebook#7700
Closes facebook#7971

Differential Revision: D3427675

Pulled By: javache

fbshipit-source-id: 48f258b0db1bf21185193bd56df453ced9242e64
@dchambers
Copy link

These instructions didn't work for me (react-native 0.27.2 in case it matters), but I've found that the problem goes away if I merely dismiss the error by pressing Esc, and then enable debugging within Chrome (Cmd + D & 'Enable Remote JS Debugging').

samerce pushed a commit to iodine/react-native that referenced this issue Aug 23, 2016
Summary:
`polyfillLazyGlobal` used a top level this which get stripped by babel `transform-es2015-modules-commonjs` with the default config. This is mainly an issues for people not using the react native babel preset.

This also replaces a few GLOBAL with global for consistency with the rest of the file.

**Test plan**

Tested that there was an error when using `['transform-es2015-modules-commonjs', { strict: true, allowTopLevelThis: false }]` in the babel config and that it was fixed after applying my changes.

Fixes facebook#7700
Closes facebook#7971

Differential Revision: D3427675

Pulled By: javache

fbshipit-source-id: 48f258b0db1bf21185193bd56df453ced9242e64
mpretty-cyro pushed a commit to HomePass/react-native that referenced this issue Aug 25, 2016
Summary:
`polyfillLazyGlobal` used a top level this which get stripped by babel `transform-es2015-modules-commonjs` with the default config. This is mainly an issues for people not using the react native babel preset.

This also replaces a few GLOBAL with global for consistency with the rest of the file.

**Test plan**

Tested that there was an error when using `['transform-es2015-modules-commonjs', { strict: true, allowTopLevelThis: false }]` in the babel config and that it was fixed after applying my changes.

Fixes facebook#7700
Closes facebook#7971

Differential Revision: D3427675

Pulled By: javache

fbshipit-source-id: 48f258b0db1bf21185193bd56df453ced9242e64
@facebook facebook locked as resolved and limited conversation to collaborators Jun 13, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants