-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add prebuilt library to react-native NPM package (for webpack / browserify) #278
Comments
I don't think that's the greatest solution. Having many npm packages will make versioning really hard. Unfortunately I don't have better ideas for now. But I'm sure we can come up with something better. |
I disagree that putting in a pre-built static library is a good thing. I enjoy the ability to dive into the source code for RCT and I see it as a valuable asset. JG :: sent from my mobile device ::
|
The proposal was to add prebuilt JS bundle of |
@amasad I agree there must be a better solution. At best, the proposed solution above serves as non-breaking, temporary hack until webpack/browserify is officially supported by If it's too much work to maintain official prebuilt JS releases, would it be possible to add an option to the built-in packager cli for clean local builds at least? That way webpack/browserify users can start experimenting with their preferred setups until |
I think a prebuilt package solves a few problems:
I can't see a downside, as there would only be one released version on npm. |
I do also use webpack and it would be great to have an option to build the bundle using webpack. As @pilwon mentioned, if you can include pre-built JS for webpack to resolve modules properly, that would help webpack community a lot! |
A better approach is building a webpack loader and resolver that delegates to the React Native packager. This way webpack can process your files but will delegate to the packager for things it can't find, i.e. the core libraries. Any takers? should be a fun project. |
Just to confirm, the resolver is simply recursing down from root to locate the package/module, right? Then it would be just a matter of applying the JSXTransformer. I tried this a couple of weeks ago, but wasn't making much progress. I was hitting duplicate module problems from the root. |
yes
I don't know what you mean here. You mean on webpack's side?
It'd be useful to share more details, like error messages, what exactly you've done etc. |
Sure, I'll put up what I did later. What I mean is that the require("xxx") in the react-native code needs to locate the module, and it does that in a dir-layout agnostic way by recursively descending down the directory structure looking for JS files with the |
I tried implementing @amasad's idea and here's what I've got so far. It successfully reads module dependencies information asynchronously with packager and then it constructs an alias map in the format I also tried hard-coding the above alias map in the |
I decided to settle on this solution for now. It only overrides |
Closing this issue as this approach solves my problem. I no longer see a need for adding prebuilt |
I'm trying to build JS bundle with webpack and serve my custom bundle at http://localhost:8081/index.ios.bundle with webpack-dev-server. I'm willing to make a tradeoff of build speed for cross-project code reusability. (For example, I like using babel as my ES6 transpiler as it supports much richer es6 feature set than jstransform that default packager uses. I'd like to write
react-native
apps with the same ES6 features)The problem arises when webpack fails to resolve
react-native
defined internal module names since webpack doesn't understand the flattened internal names. Manually mapping usingresolve.alias
feature of webpack is one way but there are simply too many of them and it's too much work to track changes in every future version releases.To simplify this process, please consider adding prebuilt JS binding portion of
react-native
library to NPM published package. Also, it'd be also nice to add an option to the built-in packager cli so library bundle can be conveniently rebuilt with local changes.The text was updated successfully, but these errors were encountered: