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

[Packager] Publish as a standalone NPM module #363

Closed
pilwon opened this issue Mar 27, 2015 · 16 comments
Closed

[Packager] Publish as a standalone NPM module #363

pilwon opened this issue Mar 27, 2015 · 16 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@pilwon
Copy link
Contributor

pilwon commented Mar 27, 2015

It'd be nice to publish react-packager as a standalone NPM module.

@pilwon pilwon changed the title Publish react-packager as a standalone NPM package react-packager: Publish as a standalone NPM package Mar 27, 2015
@pilwon pilwon changed the title react-packager: Publish as a standalone NPM package react-packager: Publish as a standalone NPM module Mar 27, 2015
@amasad
Copy link
Contributor

amasad commented Mar 27, 2015

We plan to do that, this will solve #341

@jsierles
Copy link
Contributor

Is this in the works or should I take a look at packaging it?

@brentvatne brentvatne changed the title react-packager: Publish as a standalone NPM module [Packager] Publish as a standalone NPM module May 31, 2015
@amasad
Copy link
Contributor

amasad commented Jun 2, 2015

@jsierles no. Go for it!
I'd like to know your use case, I'm curious.

@jsierles
Copy link
Contributor

jsierles commented Jun 3, 2015

For the React Native Playground, we're running the packager along side different versions of React Native. Having the packager separate would make it easier to test changes there without having to upgrade react-native itself, and vice-versa.

@amasad
Copy link
Contributor

amasad commented Jun 4, 2015

I tried to keep it as decoupled as possible, so it shouldn't be too hard. Happy to help.

@paramaggarwal
Copy link
Contributor

Yes, this would be great. I would like to add this as an Xcode build phase, that simply creates a jsbundle to add into the app bundle when doing an Archive build. With a separate packager, I don't need to run the server, wait for it to be ready and then curl the bundle from it.

@jsierles
Copy link
Contributor

Been looking at this. It looks like the packager is already setup to be published as a module. A few doubts:

  • Should it be split out to a separate repository?
  • Do we need to change anything besides the RN sample app?

@jsierles
Copy link
Contributor

@paramaggarwal By the way, you can bundle that way today using 'react-native bundle' at the root of your project.

@paramaggarwal
Copy link
Contributor

@jsierles Oh, that would be great. I'm seeing this error:

$ npm install -g react-native-cli
/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
react-native-cli@0.1.4 /usr/local/lib/node_modules/react-native-cli
└── prompt@0.2.14 (revalidator@0.1.8, pkginfo@0.3.0, read@1.0.6, winston@0.8.3, utile@0.2.1)
$ react-native bundle
Command `bundle` unrecognized. Did you mean to run this inside a react-native project?

I tried running it inside my project. I also don't see any mention of the bundle command inside the react-native-cli code here.

@jsierles
Copy link
Contributor

It needs to be run from inside your project. The global cli loads a local cli which provides the bundle command.

https://github.com/facebook/react-native/blob/master/local-cli/cli.js

@paramaggarwal
Copy link
Contributor

Ah, I see. Unfortunately that local-cli directory is not available when installed via Pods - it probably needs to be in preserve_paths in the pod spec. Will raise separate issue for that, thanks.

@amasad
Copy link
Contributor

amasad commented Jun 30, 2015

Yes, we wrote in isolation but it made the syncing process a lot easier to be coupled with react-native. Isolating into it's own repo needs some changes internally. I'm taking some time off in July but I can start looking into this in August. We'll also start using parts of the packager in other projects.

@jsierles
Copy link
Contributor

Sounds good! For now, isolating it in npm would be a good step, I'll be looking at that during July. In general, for rnplay.org we're trying to work out some better solutions for running multiple packagers with multiple entry points each. What would be a good place to discuss this?

@amasad
Copy link
Contributor

amasad commented Jun 30, 2015

I think here is as good as any. Can you expand on more on your requirement? What can be better about it?

@jsierles
Copy link
Contributor

jsierles commented Jul 1, 2015

It may be too ambitious, but we'd like to have a packager running for each version of React Native, and have each one of those serving multiple apps. This works today, by using a single copy of react native at one root, and the applications all at another.

But this slows down as more and more application data gets cached in the packager. I also assume that if multiple apps require packages with the same name, they could conflict in the packager cache. This has happened when more than one react-native copy gets installed in one of the app's node_modules. And, as more apps get created with complex dependencies, I figure file watching for entire node_modules trees will not scale.

It would be great to know if there's a better way to optimize this use case, and where we should be looking to help improve the packager.

A few ideas I had to help this:

  • Shard apps across multiple packagers per react-native version to keep the cache size down
  • bundle an apps node_modules into a single file, required by the app, since these files wont be edited and don't need to be crawled

@amasad
Copy link
Contributor

amasad commented Sep 8, 2015

Good news, we're moving the packager to it's own npm package and github repo. Should release very soon.

@amasad amasad closed this as completed Sep 8, 2015
@facebook facebook locked as resolved and limited conversation to collaborators Jul 23, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
jfrolich pushed a commit to jfrolich/react-native that referenced this issue Apr 22, 2020
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

No branches or pull requests

5 participants