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

Adding package.json browser attribute pointing towards browser bundle… #1318

Closed
wants to merge 2 commits into from

Conversation

schrepfler
Copy link

@schrepfler schrepfler commented Feb 22, 2017

… and reusing current webpack setup and destination.

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
    No new logic
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • Add your name and email to the AUTHORS file (optional)
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

@stubailo
Copy link
Contributor

Why is this necessary? Does this fix some issue you were encountering?

@calebmer
Copy link
Contributor

Why do you need this? You are pointing it towards our analyze bundle which is used for internal development bundle size analysis only. It is not a production bundle in the slightest.

Please submit an issue so we can help diagnose your issue 😊

@schrepfler
Copy link
Author

Sure, I'll point to you apollographql/subscriptions-transport-ws#77 and before that apollographql/subscriptions-transport-ws#48
In essence, if you provide a "browser" element in package.json then people can just reference the npm module in https://unpkg.com/#/ and users will be automatically able to use your lib liked as a script and delivered from the unpkg cdn. Not everybody uses node and people like to experiment just by linking stuff.
I used the analyze bundle just not to duplicate anything, it should fit the bill and can be re-used.

@calebmer
Copy link
Contributor

We provide the UMD bundle as main: https://unpkg.com/apollo-client@0.8.7

Why is this not sufficient?

@stubailo
Copy link
Contributor

Yeah looks like unpkg already works!

@schrepfler
Copy link
Author

Awesome, wasn't aware it can work without a browser entry, cool 👍
Closing.

@schrepfler schrepfler closed this Feb 23, 2017
@schrepfler
Copy link
Author

schrepfler commented Feb 23, 2017

Hi guys,
Just tried the unpkg link in a static page but I can't find the apollo client in the global scope. As most examples are in ES6 and with import statements I'm not sure how to reference the client imported in this way, can somebody make an example+document it?

@schrepfler schrepfler reopened this Feb 23, 2017
@stubailo
Copy link
Contributor

@schrepfler can you give it a shot? This isn't a supported way to use Apollo Client but if you figure out how to use it it will be helpful for others.

@schrepfler
Copy link
Author

I can see there are some things in the window object but not quite certain if that's the way to get it from (Java guy here.) Thinking of the wider apollo ecosystem, I think it would be nice if there's a unified way to expose browser-type modules between apollo-client and the subscription(-ws) modules.
I'll continue experimenting but feel free for anyone to step in.

@calebmer
Copy link
Contributor

There are a couple of things I’d like to change about the build system, and this is one of them. How important is this for you @schrepfler? Any reason you can’t setup Webpack as this would be much easier at the moment and more powerful for you as a user.

@schrepfler
Copy link
Author

I certainly can but I think there are two kinds of people, those who use build systems and those which just want to experiment with the API's via a simple linked script. The thing which made me wish this is that I wanted to simply reference a module via cdn and unpkg allowed me to do so so I started to contribute to subscriptions-transport-ws but then I realised one woul also need the apollo client and maybe graphql and apollo subscriptions...
I don't think this is strictly needed but I'd say to you apollo that you should think about this dev tier as well and provide a consistently exposed module namespace and some examples mainly because ease of use.

@helfer
Copy link
Contributor

helfer commented Feb 27, 2017

We can't merge the PR in this form, but we'll work on improving our build process to make this much easier to do. Expect to see some movement on that soon.

@helfer helfer closed this Feb 27, 2017
@schrepfler
Copy link
Author

That's OK, if it sparks some movement that's great. My only desire is that whatever is delivered can be somehow used directly via unpkg.

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

Successfully merging this pull request may close these issues.

4 participants