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

Unblock react native support when using corev2 packages #17783

Merged
13 commits merged into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/core/core-client-paging-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"browser": {
"./dist-esm/src/url.js": "./dist-esm/src/url.browser.js"
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
Comment on lines +12 to +14
Copy link
Member

Choose a reason for hiding this comment

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

@joheredi is this package still a dep in the rest clients? if not, we could probably skip updating it. Same applies for the lro one.

"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:samples": "echo Obsolete",
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Updates package to work with the react native bundler. Browser APIs may still need to be pollyfilled for this package to run in react native. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

Comment on lines +13 to +14
Copy link
Member

Choose a reason for hiding this comment

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

I am curious, is there a way to document those APIs with mappings to the appropriate polyfills?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pollyfill landscape in react native is kind of still like the wild west. I plan to have an example shims file in the samples that are included in a follow-up PR, but I don't want to recommend any specific 3rd party pollyfill at this time since I haven't properly vetted them beyond ensuring some seem to work.

Copy link
Member

Choose a reason for hiding this comment

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

That is fair. In order to make it easier for react native customers to use the SDK, should we consider providing documentation of non-standard definitions that need to be polyfilled for every package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My plan was to document that in react-native samples (that live alongside our current react/electron samples.) Happy to include some documentation at that point as well similar to how we have documentation on bundling.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds great! Thanks!

## 1.3.0 (2021-08-04)

### Features Added
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"browser": {
"./dist-esm/src/base64.js": "./dist-esm/src/base64.browser.js"
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"types": "types/latest/core-client.d.ts",
"typesVersions": {
"<3.6": {
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"browser": {
"./dist-esm/src/sha256.js": "./dist-esm/src/sha256.browser.js"
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"types": "types/latest/core-crypto.d.ts",
"typesVersions": {
"<3.6": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-crypto/src/sha256.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function computeSha256Hash(
encoding: "base64" | "hex"
): Promise<string> {
const contentBytes = utf8ToBytes(content);
const digest = await getCrypto().digest("SHA-256", contentBytes);
const digest = await getCrypto().digest({ name: "SHA-256" }, contentBytes);

switch (encoding) {
case "base64":
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-lro/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Other Changes

- Updates package to work with the react native bundler. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

## 2.2.0 (2021-08-05)

### Features Added
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-lro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"os": false,
"process": false
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"license": "MIT",
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-lro/README.md",
"repository": "github:Azure/azure-sdk-for-js",
Expand Down
6 changes: 6 additions & 0 deletions sdk/core/core-paging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 1.2.1 (Unreleased)

### Other Changes

- Updates package to work with the react native bundler. Browser APIs such as `URL` will still need to be pollyfilled for this package to run in react native. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

Copy link
Member

Choose a reason for hiding this comment

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

I believe this package does not reference URL or any browser APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I was thinking of core-paging-rest

## 1.2.0 (2021-08-30)

### Features Added
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-rest-pipeline/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Updates package to work with the react native bundler. Browser APIs such as `URL` will still need to be pollyfilled for this package to run in react native. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

## 1.3.0 (2021-09-02)

### Bugs Fixed
Expand Down
4 changes: 4 additions & 0 deletions sdk/core/core-rest-pipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"./dist-esm/src/util/url.js": "./dist-esm/src/util/url.browser.js",
"./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.browser.js"
},
"react-native": {
Copy link
Member

Choose a reason for hiding this comment

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

changelog?

"./dist/index.js": "./dist-esm/src/index.js",
"./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.native.js"
},
"types": "core-rest-pipeline.shims.d.ts",
"typesVersions": {
"<3.6": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/*
* NOTE: When moving this file, please update "react-native" section in package.json.
*/

/**
* @internal
*/
export function getHeaderName(): string {
return "x-ms-useragent";
}

/**
* @internal
*/
export function setPlatformSpecificData(map: Map<string, string>): void {
// TODO: Investigate using `import { Platform } from "react-native"` to get "OS" and "Version".
// This may bring in a lot of overhead if we have to use this package directly, perhaps we can shim
// types.
map.set("OS", `react-native`);
}
2 changes: 2 additions & 0 deletions sdk/core/core-tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

### Other Changes

- Updates package to work with the react native bundler. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

## 1.0.0-preview.13 (2021-07-15)

### Features Added
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"browser": {
"./dist-esm/src/utils/global.js": "./dist-esm/src/utils/global.browser.js"
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"types": "types/core-tracing.d.ts",
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-util/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 1.0.0-beta.2 (Unreleased)

### Other Changes

- Updates package to work with the react native bundler. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

## 1.0.0-beta.1 (2021-05-06)

Expand Down
3 changes: 3 additions & 0 deletions sdk/core/core-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"browser": {
"./dist-esm/src/isNode.js": "./dist-esm/src/isNode.browser.js"
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"types": "types/latest/core-util.d.ts",
"typesVersions": {
"<3.6": {
Expand Down
3 changes: 3 additions & 0 deletions sdk/core/logger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 1.0.3 (Unreleased)

### Other Changes

- Updates package to work with the react native bundler. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)

## 1.0.2 (2021-03-04)

Expand Down
3 changes: 3 additions & 0 deletions sdk/core/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"./dist-esm/src/log.js": "./dist-esm/src/log.browser.js",
"process": false
},
"react-native": {
"./dist/index.js": "./dist-esm/src/index.js"
},
"engines": {
"node": ">=12.0.0"
},
Expand Down