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

[Service Bus] Add browser support #5128

Merged
merged 14 commits into from
Sep 24, 2019
Merged

Conversation

ramya0820
Copy link
Member

@ramya0820 ramya0820 commented Sep 13, 2019

This PR addresses following changes as part of enabling browser support for use in production -

  • Fix rollup scripts
  • Update changelog
  • Add in copyrights
  • Update to use amqp-common preview.7 for reduced bundle size

@@ -43,7 +43,7 @@ const ignoreKnownWarnings = (warning) => {
console.error(`(!) ${warning.message}`);
};

export function nodeConfig({ test = false, production = false } = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramya0820 I am reluctant to take this change without first understanding the reason why the production flag was part of the function signature in the first place.

@bterlson I remember you had a reason to add the production flag here, but can't recall what it was. #2555 was the PR in which we moved away from using process.env.NODE_ENV to determine "production"

@ramya0820 I see that you had approved that PR. Do you recall the reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline and addressed this along with other changes per #3373 description.

There was one temporary browser test failure, and we could add in better samples.
Other than these, we should be good to release once changes and contents in PR look okay.
Please take a look at the copyrights notice file.
@ramya-rao-a @bterlson

@ramya-rao-a ramya-rao-a requested review from bterlson and removed request for ShivangiReja September 13, 2019 05:44
Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename PR as this PR no longer about fixing rolling scripts and more of adding browser bundle in the package

@@ -1,3 +1,8 @@
# 2019-09-19 1.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 2019-09-19 1.1.0
# 2019-09-22 1.1.0

We mostly will not be releasing on a Friday

sdk/servicebus/service-bus/changelog.md Outdated Show resolved Hide resolved
return ServiceBusClient.createFromTokenProvider(host, tokenProvider, options);
} else {
throw new Error("`createFromAadTokenCredentials` is not supported in browser.");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce nesting by

if (!isNode) {
    // throw error here
}
// existing code that creates and uses aad token provider

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

The reason I used isNode and not !isNode was keeping in view the rollup's "replace" plugin configuration that looks at the text " if (isNode) " and replaces it with " if (false) " in browser.
The changes seem equivalent though since we aren't enabling tree shaking. Maybe we should remove the replace plugin config? cc @bterlson

Addressed all other comments as well, please take a look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, better to use if (isNode) given the current rollup config. Short term fix might be to add the if (!isNode) pattern to the rollup config. Longer term fix is to have a platform.node.js and platform.browser.js that exports isNode = true and isNode = false respectively, that way either form will work fine with Rollup's tree shaker, and no replace plugin is required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed: #5210

const tokenProvider = new AadTokenProvider(credentials);
return ServiceBusClient.createFromTokenProvider(host, tokenProvider, options);
} else {
throw new Error("`createFromAadTokenCredentials` is not supported in browser.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message can be improved by alluding to the fact that AAD support is not yet present in browser mode and so createFromAadTokenCredentials method cannot be used to create ServiceBusClient

@ramya-rao-a
Copy link
Contributor

Also, it would be great if we can release preview 7 of amqp-common first and use that version in this PR. The benefit of reduced bundle size that preview 7 of amp-common brings to the table will help the browser bundle.

Copy link
Member

@bterlson bterlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO remove the notices.txt change and we'll update these in one pass later (/cc @jonathandturner)

buffer, is-buffer
process
debug
rollup and related browser bundling utilities
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollup is not being redistributed, and doesn't need to be included here.

@@ -0,0 +1,85 @@
NOTICES AND INFORMATION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy ThirdPartyNotices.txt from other libraries, not from the open source guidelines for now. I believe our other packages have the most up to date version. The note about 3rdpartysource.microsoft.com is inaccurate anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments and updated to use the format / contents used in other 'ThirdPartyNotices.txt' files instead.


--------------------------------------------------------------------------------
Component(s):
@azure/ms-rest-node-auth, @azure/amqp-common
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not third party components and should not be included.

process 1.11.10 - Copyright (c) 2013 Roman Shtylman <[email protected]>
debug 4.1.1 - Copyright (c) 2014 TJ Holowaychuk <[email protected]>
Type Definitions - Copyright https://github.com/DefinitelyTyped/DefinitelyTyped
@types/long 4.0.0 - Project: https://github.com/dcodeIO/long.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types are not being redistributed and do not need to be included.

--------------------------------------------------------------------------------

Component(s):
rhea 1.0.4, rhea-promise 0.1.15, long 4.0.0, tslib 1.9.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original copyright lines need to be included for these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the original notice description referring to Apache license is being included - did we mean to copy paste the more detailed description as present at https://github.com/amqp/rhea/blob/master/LICENSE ?

@ramya0820 ramya0820 changed the title [Service Bus] Fix rollup scripts [Service Bus] Enable browser support Sep 23, 2019
@ramya0820 ramya0820 changed the title [Service Bus] Enable browser support [Service Bus] Enable browser bundling Sep 23, 2019
@@ -1,11 +1,17 @@
# 2019-09-23 1.1.0

- Update library to support running all Service Bus operations in browser.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add browser support. Authentication with @azure/identity is not yet supported – use a connection string instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

**********

**********
rhea 1.0.4, rhea-promise 0.1.15, long 4.0.0, tslib 1.9.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing copyright notice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the owners

@ramya0820 ramya0820 changed the title [Service Bus] Enable browser bundling [Service Bus] Add browser support Sep 23, 2019
sdk/servicebus/service-bus/changelog.md Outdated Show resolved Hide resolved
sdk/servicebus/service-bus/changelog.md Outdated Show resolved Hide resolved
@ramya0820 ramya0820 merged commit 4c4a859 into Azure:master Sep 24, 2019
ramya0820 pushed a commit to ramya0820/azure-sdk-for-js that referenced this pull request Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants