Skip to content

Commit

Permalink
chore: Expand * exports to optimize tree-shaking (aws-amplify#10555)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Oct 27, 2022
1 parent 20b096b commit bfb75d4
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
export * from './DataType';
export * from './SessionInfoManager';
export * from './MediaAutoTrack';
export {
EventData,
RecordEventListPayload,
RecordEventPayload,
RequestParams,
SessionInfo,
} from './DataType';
export { SessionInfoManager } from './SessionInfoManager';
export { MediaAutoTrack } from './MediaAutoTrack';
7 changes: 6 additions & 1 deletion packages/analytics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@

export { Analytics } from './Analytics';
export { AnalyticsProvider } from './types';
export * from './Providers';
export {
AWSPinpointProvider,
AWSKinesisProvider,
AWSKinesisFirehoseProvider,
AmazonPersonalizeProvider,
} from './Providers';
2 changes: 1 addition & 1 deletion packages/aws-amplify-react-native/src/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
* and limitations under the License.
*/

export * from './GraphQL';
export { Connect } from './GraphQL';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './ChatBot';
export { ChatBot } from './ChatBot';
36 changes: 30 additions & 6 deletions packages/aws-amplify-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,37 @@ import dict from './AmplifyI18n';

export { default as AmplifyTheme } from './AmplifyTheme';
export { MapEntries as AmplifyMessageMapEntries } from './AmplifyMessageMap';
export * from './AmplifyUI';
export * from './Auth';
export * from './API';
export * from './Storage';
export * from './Interactions';
export {
AmplifyButton,
Container,
ErrorRow,
FormField,
Header,
LinkCell,
PhoneField,
SignedOutMessage,
Wrapper,
} from './AmplifyUI';
export {
AuthPiece,
Authenticator,
ConfirmSignIn,
ConfirmSignUp,
ForgotPassword,
Greetings,
Loading,
RequireNewPassword,
SignIn,
SignUp,
VerifyContact,
withAuthenticator,
withOAuth,
} from './Auth';
export { Connect } from './API';
export { S3Album, S3Image } from './Storage';
export { ChatBot } from './Interactions';

const configure = function(config) {
const configure = function (config) {
const msg = [
'',
'\x1b[33mWarning: Amplify.configure() is deprecated from aws-amplify-react-native.',
Expand Down
36 changes: 21 additions & 15 deletions packages/cache/src/Utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
/*
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

export * from './CacheUtils';
export { default as CacheList } from './CacheList';
/*
* Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

export {
CacheObject,
defaultConfig,
getByteLength,
getCurrTime,
isInteger,
} from './CacheUtils';
export { default as CacheList } from './CacheList';
2 changes: 1 addition & 1 deletion packages/core/src/Logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
* and limitations under the License.
*/

export * from './ConsoleLogger';
export { ConsoleLogger, LOG_TYPE } from './ConsoleLogger';
2 changes: 1 addition & 1 deletion packages/core/src/Providers/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './AWSCloudWatchProvider';
export { AWSCloudWatchProvider } from './AWSCloudWatchProvider';
28 changes: 23 additions & 5 deletions packages/core/src/Util/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
export * from './Retry';
export {
NonRetryableError,
isNonRetryableError,
jitteredBackoff,
jitteredExponentialRetry,
retry,
} from './Retry';
export { default as Mutex } from './Mutex';
export { default as Reachability } from './Reachability';
export * from './DateUtils';
export * from './StringUtils';
export * from './Constants';
export * from './BackgroundProcessManager';
export { DateUtils } from './DateUtils';
export { urlSafeDecode, urlSafeEncode } from './StringUtils';
export {
AWS_CLOUDWATCH_BASE_BUFFER_SIZE,
AWS_CLOUDWATCH_CATEGORY,
AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE,
AWS_CLOUDWATCH_MAX_EVENT_SIZE,
AWS_CLOUDWATCH_PROVIDER_NAME,
NO_CREDS_ERROR_STRING,
RETRY_ERROR_CODES,
} from './Constants';
export {
BackgroundProcessManager,
BackgroundManagerNotOpenError,
BackgroundProcessManagerState,
} from './BackgroundProcessManager';
53 changes: 45 additions & 8 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,66 @@ export { Amplify } from './Amplify';
export { AmplifyClass } from './Amplify';
export { ClientDevice } from './ClientDevice';
export { ConsoleLogger, ConsoleLogger as Logger } from './Logger';
export * from './Errors';
export { invalidParameter, missingConfig } from './Errors';
export { Hub, HubCapsule, HubCallback, HubPayload } from './Hub';
export { I18n } from './I18n';
export * from './JS';
export {
browserOrNode,
filenameToContentType,
generateRandomString,
isEmpty,
isStrictObject,
isTextFile,
isWebWorker,
makeQuerablePromise,
objectLessAttributes,
sortByField,
transferKeyToLowerCase,
transferKeyToUpperCase,
} from './JS';
export { Signer } from './Signer';
export * from './parseAWSExports';
export * from './Providers';
export { parseAWSExports } from './parseAWSExports';
export { AWSCloudWatchProvider } from './Providers';
export { FacebookOAuth, GoogleOAuth } from './OAuthHelper';
export * from './RNComponents';
export { AppState, AsyncStorage, Linking } from './RNComponents';
export { Credentials, CredentialsClass } from './Credentials';
export { ServiceWorker } from './ServiceWorker';
export { ICredentials } from './types';
export { StorageHelper, MemoryStorage } from './StorageHelper';
export { UniversalStorage } from './UniversalStorage';
export { Platform, getAmplifyUserAgent } from './Platform';
export * from './constants';
export {
INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER,
INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER,
USER_AGENT_HEADER,
} from './constants';

export const Constants = {
userAgent: Platform.userAgent,
};

export * from './constants';
export * from './Util';
export {
AWS_CLOUDWATCH_BASE_BUFFER_SIZE,
AWS_CLOUDWATCH_CATEGORY,
AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE,
AWS_CLOUDWATCH_MAX_EVENT_SIZE,
AWS_CLOUDWATCH_PROVIDER_NAME,
BackgroundManagerNotOpenError,
BackgroundProcessManager,
BackgroundProcessManagerState,
DateUtils,
Mutex,
NO_CREDS_ERROR_STRING,
NonRetryableError,
RETRY_ERROR_CODES,
Reachability,
isNonRetryableError,
jitteredBackoff,
jitteredExponentialRetry,
retry,
urlSafeDecode,
urlSafeEncode,
} from './Util';

/**
* @deprecated use named import
Expand Down
6 changes: 3 additions & 3 deletions packages/interactions/src/Providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
export * from './AWSLexProvider';
export * from './AWSLexV2Provider';
export * from './InteractionsProvider';
export { AWSLexProvider } from './AWSLexProvider';
export { AWSLexV2Provider } from './AWSLexV2Provider';
export { AbstractInteractionsProvider } from './InteractionsProvider';
6 changes: 3 additions & 3 deletions packages/interactions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

export { Interactions } from './Interactions';
export * from './types';
export * from './Providers/InteractionsProvider';
export * from './Providers/AWSLexProvider';
export * from './Providers/AWSLexV2Provider';
export { AbstractInteractionsProvider } from './Providers/InteractionsProvider';
export { AWSLexProvider } from './Providers/AWSLexProvider';
export { AWSLexV2Provider } from './Providers/AWSLexV2Provider';
5 changes: 0 additions & 5 deletions packages/pubsub/src/Providers/MqttOverWSProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ export interface MqttProviderOptions extends ProviderOptions {
url?: string;
}

/**
* @deprecated Migrated to MqttProviderOptions
*/
export type MqttProvidertOptions = MqttProviderOptions;

class ClientsQueue {
private promises: Map<string, Promise<any>> = new Map();

Expand Down
18 changes: 13 additions & 5 deletions packages/pubsub/src/Providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
export * from './PubSubProvider';
export * from './AWSAppSyncProvider';
export * from './AWSAppSyncRealTimeProvider';
export * from './AWSIotProvider';
export * from './MqttOverWSProvider';
export { AbstractPubSubProvider } from './PubSubProvider';
export { AWSAppSyncProvider } from './AWSAppSyncProvider';
export {
AWSAppSyncRealTimeProvider,
AWSAppSyncRealTimeProviderOptions,
ObserverQuery,
} from './AWSAppSyncRealTimeProvider';
export { AWSIoTProvider, AWSIoTProviderOptions } from './AWSIotProvider';
export {
MqttProviderOptions,
MqttOverWSProvider,
mqttTopicMatch,
} from './MqttOverWSProvider';
13 changes: 12 additions & 1 deletion packages/pubsub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
*/

export { PubSub } from './PubSub';
export * from './Providers';
export { CONNECTION_STATE_CHANGE } from './Providers/constants';
export { ConnectionState, CONTROL_MSG } from './types';
export {
AWSAppSyncProvider,
AWSAppSyncRealTimeProvider,
AWSAppSyncRealTimeProviderOptions,
AWSIoTProvider,
AWSIoTProviderOptions,
AbstractPubSubProvider,
MqttOverWSProvider,
MqttProviderOptions,
ObserverQuery,
mqttTopicMatch,
} from './Providers';
2 changes: 1 addition & 1 deletion packages/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
import { Storage, StorageInstance } from './Storage';

export { Storage as StorageClass, StorageInstance as Storage };
export * from './providers';
export { AWSS3Provider } from './providers';
export * from './types';
12 changes: 10 additions & 2 deletions packages/xr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@
*/

export { XR } from './XR';
export * from './Providers/SumerianProvider';
export * from './Errors';
export { SumerianProvider } from './Providers/SumerianProvider';
export {
XRError,
XRNoDomElement,
XRNoSceneConfiguredError,
XRProviderNotConfigured,
XRSceneLoadFailure,
XRSceneNotFoundError,
XRSceneNotLoadedError,
} from './Errors';

0 comments on commit bfb75d4

Please sign in to comment.