You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arguably the project maintainer should provide compiled versions.
I don't really see how this is an issue with react-native-webpack-server.
If the project maintainer wants to provide only ES6 version, indeed, the only thing you can do is to add its configuration explicitly to your Webpack config. Which is not nice at all because you don't know the Babel settings expected by the author.
Thanks for the answer! I do agree with you, unfortunately looks like the problem lives somewhere else. The packager fails at syntax that it normally handles without webpack - destructing (which is widely used in almost all the projects and examples and none of them mentions a single word about ES6 pre-compiling).
How I understand that is that packager compiles the whole bundle to one index.ios.bundle and that's pretty much everything. Haven't investigated that a lot yet but it would've been weird if all open source packages were published with syntax that's not supported by default yet providing no additional notes.
@grabbou@gaearon Yeah it was expected that people use the packager, which transforms your code for you - even your modules. If think the problem here is that the dev server is ignoring the modules directory? But sure, I can provide an ES5 version I guess :)
Sorry to jump in late on this one. This has come up a couple times before. node_modules is only excluded for performance reasons in the example project - this is a fairly common setup from what I've seen.
I'll update the docs to call this out. Thanks for raising the issue.
I was having a different (but I think related) error when loading a 3rd party module that required linking and I thought I would drop my solution here since this was the issue my searches brought up.
I was trying to require react-native-icons and after I ran the installation instructions, the docs say var Icon = require('FAKIconImage') will work. But webpack was giving me the error:
ERROR in ./src/components/Settings.js
Module not found: Error: Cannot resolve module 'FAKIconImage' in /Users/lukekarrys/projects/lukekarrys/react-native-app/src/components
@ ./src/components/Settings.js 27:19-41
What I needed to do was make babel-loader include the react-native-icons module and to require it with var Icon = require('react-native-icons') instead. This might be obvious to some, but took me a bit to figure out. I'm also not sure why this is the case, if anyone has an explanation I would love to learn why.
@mjohnston Do you think this is worth calling out in the docs as well? Happy to submit a PR if you think it is.
Personally, I think it's bad practice for 3rd party modules to rely on the proprietary @providesModule syntax - especially when you consider standard CommonJS/ES6 modules work with the default react-native packager.
That being said, if this has become common practice in the react-native ecosystem I'd be happy to accept a PR for a docs update.
Ah, I had never heard of @providesModule before so I didn't know thats why this was happening. Also this was the first module I had ever required in react-native with a linking step so it threw me for a loop.
I've only seen it in two modules, so I think these comments are enough for now. If I keep seeing this I'll reconsider the PR.
I am also getting a ERROR in ./src/containers/Create/CaptureScreen/index.js Module not found: Error: Cannot resolve module 'react-native-camera' in /Users/micgunnu/code/sap/routes/Routes-native/src/containers/Create/CaptureScreen @ ./src/containers/Create/CaptureScreen/index.js 48:13-43
Even though I include it like this: include: [ path.resolve(__dirname, 'src'), path.resolve(__dirname, 'node_modules/react-native-camera') ],
Not sure if this has something to do with react-native-camera, seeing you have to add an object-c file to the project library. Has anyone had this experience?
@sslash react-native-camera needs an native implementation. So, if you havent allready you first need to add the needing resources in xcode. See the 'getting started' section on react-native-camera repo.
Also, i have turned back to use packager over webpack-server for react-native. The es5 shim is a bit limited, and lack support for android(you cannot change debugging port on android). It does not have hot-loader but you can reload you entire bundle on change using Reload.js, which is good enough for me.
@emilmork In an attempt to get this working I tried to run the example app with v0.6.0 and it gives me node_modules/react-native-webpack-server/lib/Server.js:3 const fs = require('fs'); ^^^^^ SyntaxError: Use of const in strict mode. at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10). Also happens in my own project
@sslash I would try updating react-native and create a new react-native project from scratch. 'react-native init Test'. Then install react-native-camera and run with packager.
@gaearon silly of me was on 0.12. However using v2.1.0 I am back to the old Cannot resolve module 'react-native-camera' (const in strict mode is gone though)
Activity
gaearon commentedon Jun 10, 2015
Arguably the project maintainer should provide compiled versions.
I don't really see how this is an issue with react-native-webpack-server.
If the project maintainer wants to provide only ES6 version, indeed, the only thing you can do is to add its configuration explicitly to your Webpack config. Which is not nice at all because you don't know the Babel settings expected by the author.
cc @johanneslumpe
grabbou commentedon Jun 10, 2015
Thanks for the answer! I do agree with you, unfortunately looks like the problem lives somewhere else. The packager fails at syntax that it normally handles without webpack - destructing (which is widely used in almost all the projects and examples and none of them mentions a single word about ES6 pre-compiling).
gaearon commentedon Jun 10, 2015
Isn't the packager only used for RN's own modules?
I thought that everything else is handled by Webpack (including the deps).
grabbou commentedon Jun 10, 2015
How I understand that is that packager compiles the whole bundle to one
index.ios.bundleand that's pretty much everything. Haven't investigated that a lot yet but it would've been weird if all open source packages were published with syntax that's not supported by default yet providing no additional notes.Examples:
In the latest release, they decided to replace
jstransformwithbabelbut the list of available transformations stays the same as of today:http://facebook.github.io/react-native/docs/javascript-environment.html#javascript-syntax-transformers
johanneslumpe commentedon Jun 11, 2015
@grabbou @gaearon Yeah it was expected that people use the packager, which transforms your code for you - even your modules. If think the problem here is that the dev server is ignoring the modules directory? But sure, I can provide an ES5 version I guess :)
grabbou commentedon Jun 11, 2015
Yeah, it ignores node_modules and the only solution is to pass selected whitelisted folders via
babelwhich works like a charm.johanneslumpe commentedon Jun 11, 2015
@grabbou so do you still want an ES5 version?
grabbou commentedon Jun 11, 2015
Nope, all works flawlessly with the above config, just wanted to create an issue as excluding
node_modulesas per example can cause some issues.johanneslumpe commentedon Jun 11, 2015
Ah ok, cool. If you run into any issues with the keyboard event lib, feel free to post at the other repo though :)
mjohnston commentedon Jun 13, 2015
Sorry to jump in late on this one. This has come up a couple times before. node_modules is only excluded for performance reasons in the example project - this is a fairly common setup from what I've seen.
I'll update the docs to call this out. Thanks for raising the issue.
lukekarrys commentedon Jun 24, 2015
I was having a different (but I think related) error when loading a 3rd party module that required linking and I thought I would drop my solution here since this was the issue my searches brought up.
I was trying to require
react-native-iconsand after I ran the installation instructions, the docs sayvar Icon = require('FAKIconImage')will work. Butwebpackwas giving me the error:What I needed to do was make
babel-loaderinclude thereact-native-iconsmodule and to require it withvar Icon = require('react-native-icons')instead. This might be obvious to some, but took me a bit to figure out. I'm also not sure why this is the case, if anyone has an explanation I would love to learn why.@mjohnston Do you think this is worth calling out in the docs as well? Happy to submit a PR if you think it is.
mjohnston commentedon Jun 24, 2015
Personally, I think it's bad practice for 3rd party modules to rely on the proprietary
@providesModulesyntax - especially when you consider standard CommonJS/ES6 modules work with the default react-native packager.That being said, if this has become common practice in the react-native ecosystem I'd be happy to accept a PR for a docs update.
lukekarrys commentedon Jun 24, 2015
Ah, I had never heard of
@providesModulebefore so I didn't know thats why this was happening. Also this was the first module I had ever required inreact-nativewith a linking step so it threw me for a loop.I've only seen it in two modules, so I think these comments are enough for now. If I keep seeing this I'll reconsider the PR.
emilmork commentedon Sep 15, 2015
I had the same problem with a 3rd party lib. My solution was to including the prefered modules + my js instead of excluding node_modules.
amccloud commentedon Sep 15, 2015
What was the 3rd party lib. I've noticed a lot of react native projects
that actually require babel processing because they are es6.
On Tuesday, September 15, 2015, Emil Mork notifications@github.com wrote:
emilmork commentedon Sep 15, 2015
@amccloud: It was gb-native-router. Its a fork of react-native-router.
And Yes, the library uses es6 syntax.
sslash commentedon Oct 3, 2015
I am also getting a
ERROR in ./src/containers/Create/CaptureScreen/index.js Module not found: Error: Cannot resolve module 'react-native-camera' in /Users/micgunnu/code/sap/routes/Routes-native/src/containers/Create/CaptureScreen @ ./src/containers/Create/CaptureScreen/index.js 48:13-43Even though I include it like this:
include: [ path.resolve(__dirname, 'src'), path.resolve(__dirname, 'node_modules/react-native-camera') ],Not sure if this has something to do with react-native-camera, seeing you have to add an object-c file to the project library. Has anyone had this experience?
emilmork commentedon Oct 3, 2015
@sslash react-native-camera needs an native implementation. So, if you havent allready you first need to add the needing resources in xcode. See the 'getting started' section on react-native-camera repo.
Also, i have turned back to use packager over webpack-server for react-native. The es5 shim is a bit limited, and lack support for android(you cannot change debugging port on android). It does not have hot-loader but you can reload you entire bundle on change using Reload.js, which is good enough for me.
sslash commentedon Oct 3, 2015
Yes, I have added all the necessary resources that is described in getting started at the camera repo. I will try to see if using the packager helps!
sslash commentedon Oct 3, 2015
@emilmork In an attempt to get this working I tried to run the example app with v0.6.0 and it gives me
node_modules/react-native-webpack-server/lib/Server.js:3 const fs = require('fs'); ^^^^^ SyntaxError: Use of const in strict mode. at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10). Also happens in my own projectemilmork commentedon Oct 3, 2015
@sslash I would try updating react-native and create a new react-native project from scratch. 'react-native init Test'. Then install react-native-camera and run with packager.
sslash commentedon Oct 3, 2015
@emilmork So not use react-native-webpack-server and get awesome hot loading? :(
emilmork commentedon Oct 3, 2015
@sslash You might use more time debugging webpack-server than hot loading will save you time developing :)
If you make react-native-camera work on a fresh prosjekt with packager it might be easier to make it work with webpack-server.
gaearon commentedon Oct 3, 2015
Are you using at least io >= 2?
sslash commentedon Oct 3, 2015
@gaearon silly of me was on 0.12. However using v2.1.0 I am back to the old
Cannot resolve module 'react-native-camera'(const in strict mode is gone though)jkyau commentedon Oct 26, 2015
@sslash did you figure out how to get react-native-camera working with rnws?
amccloud commentedon Oct 26, 2015
@sslash @jkyau
sslash commentedon Oct 26, 2015
@jkyau nopes, didn't bother ;)