Skip to content

Commit 43e28a6

Browse files
authored
chore: add a warning if amplify configure has not been called (#14424)
* chore: add a warning if amplify configure has not been called * chore: adjust package size limits
1 parent a4e9a06 commit 43e28a6

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

packages/aws-amplify/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
"name": "[Analytics] record (Pinpoint)",
308308
"path": "./dist/esm/analytics/index.mjs",
309309
"import": "{ record }",
310-
"limit": "17.92 kB"
310+
"limit": "17.98 kB"
311311
},
312312
{
313313
"name": "[Analytics] record (Kinesis)",
@@ -331,7 +331,7 @@
331331
"name": "[Analytics] identifyUser (Pinpoint)",
332332
"path": "./dist/esm/analytics/index.mjs",
333333
"import": "{ identifyUser }",
334-
"limit": "16.40 kB"
334+
"limit": "16.41 kB"
335335
},
336336
{
337337
"name": "[Analytics] enable",
@@ -373,7 +373,7 @@
373373
"name": "[Auth] confirmResetPassword (Cognito)",
374374
"path": "./dist/esm/auth/index.mjs",
375375
"import": "{ confirmResetPassword }",
376-
"limit": "13.25 kB"
376+
"limit": "13.26 kB"
377377
},
378378
{
379379
"name": "[Auth] signIn (Cognito)",
@@ -427,7 +427,7 @@
427427
"name": "[Auth] setUpTOTP (Cognito)",
428428
"path": "./dist/esm/auth/index.mjs",
429429
"import": "{ setUpTOTP }",
430-
"limit": "13.89 kB"
430+
"limit": "13.91 kB"
431431
},
432432
{
433433
"name": "[Auth] updateUserAttributes (Cognito)",
@@ -493,13 +493,13 @@
493493
"name": "[Storage] copy (S3)",
494494
"path": "./dist/esm/storage/index.mjs",
495495
"import": "{ copy }",
496-
"limit": "16.90 kB"
496+
"limit": "16.91 kB"
497497
},
498498
{
499499
"name": "[Storage] downloadData (S3)",
500500
"path": "./dist/esm/storage/index.mjs",
501501
"import": "{ downloadData }",
502-
"limit": "17.26 kB"
502+
"limit": "17.28 kB"
503503
},
504504
{
505505
"name": "[Storage] getProperties (S3)",
@@ -511,7 +511,7 @@
511511
"name": "[Storage] getUrl (S3)",
512512
"path": "./dist/esm/storage/index.mjs",
513513
"import": "{ getUrl }",
514-
"limit": "17.75 kB"
514+
"limit": "17.77 kB"
515515
},
516516
{
517517
"name": "[Storage] list (S3)",

packages/core/src/singleton/Amplify.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class AmplifyClass {
1919
| ((authConfig: AuthConfig['Cognito']) => void)
2020
| undefined = undefined;
2121

22+
private isConfigured = false;
23+
2224
resourcesConfig: ResourcesConfig;
2325
libraryOptions: LibraryOptions;
2426

@@ -76,6 +78,7 @@ export class AmplifyClass {
7678
);
7779

7880
this.notifyOAuthListener();
81+
this.isConfigured = true;
7982
}
8083

8184
/**
@@ -84,6 +87,13 @@ export class AmplifyClass {
8487
* @returns Returns the immutable back-end resource configuration.
8588
*/
8689
getConfig(): Readonly<ResourcesConfig> {
90+
if (!this.isConfigured) {
91+
// eslint-disable-next-line no-console
92+
console.warn(
93+
`Amplify has not been configured. Please call Amplify.configure() before using this service.`,
94+
);
95+
}
96+
8797
return this.resourcesConfig;
8898
}
8999

0 commit comments

Comments
 (0)