Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Client-side packaging changed in 0.5.2 relative to 0.5.1 #79

Closed
larixer opened this issue Feb 21, 2017 · 3 comments
Closed

Client-side packaging changed in 0.5.2 relative to 0.5.1 #79

larixer opened this issue Feb 21, 2017 · 3 comments

Comments

@larixer
Copy link

larixer commented Feb 21, 2017

Please see this issue:
sysgears/apollo-universal-starter-kit#41

My solution was to force downgrade to 0.5.1. I think something is wrong with "browser" client-side package in 0.5.2

@larixer larixer changed the title Client-side packaging seems to become broken in 0.5.2 Client-side packaging changed in 0.5.2 relative to 0.5.1 Feb 21, 2017
@larixer
Copy link
Author

larixer commented Feb 21, 2017

Seems module format for client-side bundle has changed from CommonJS in 0.5.1 to global var in 0.5.2 by Pull Request:
#77

Maybe libraryTarget: 'umd' should be used instead in unpkg-webpack.config.js?

Global var module style for client-side bundle will work without hacks involved only with <script> tags in web browser. But if one uses webpack bundler (maybe it is applicable for other bundlers as well), by default it processes browser field in package.json and hence attempts to use client-side bundle when you require('subscritption-transport-ws'). In 0.5.1 everything was fine with webpack, because client-side bundle had CommonJS module style. But in 0.5.2 module style changed to global var and now you need to require this module in rather convoluted way:

  require('script!subscriptions-transport-ws');
  const SubscriptionClient = SubscriptionsTransportWs.SubscriptionClient;

I propose to not use global var, but rather use the module style for client-side bundle that works BOTH with <script> tag and with bundlers. I think UMD module style is compatible with any usage scenario.

@Urigo
Copy link
Contributor

Urigo commented Feb 22, 2017

Fixed in 0.5.3. Thanks @Vlasenko .

@Urigo Urigo closed this as completed Feb 22, 2017
@larixer
Copy link
Author

larixer commented May 4, 2017

@Urigo The same problem has happened with 0.6.0. Browser bundle is exported as global var, whereas in 0.5.x it was exported as CommonJS module, is it intended?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants