该amazon-cognito-identity-js
软件包不是必需的,并且是aws-amplify
.
My modules:
"@angular/animations": "~11.0.5",
"@angular/cdk": "^11.0.3",
"@angular/common": "~11.0.5",
"@angular/compiler": "~11.0.5",
"@angular/core": "~11.0.5",
"@angular/forms": "~11.0.5",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "~11.0.5",
"@angular/platform-browser-dynamic": "~11.0.5",
"@angular/router": "~11.0.5",
"@aws-amplify/ui-angular": "^0.4.17-unstable.1",
"@types/graphql": "^14.5.0",
"angular-gridster2": "^10.1.7",
"aws-amplify": "^3.3.14-unstable.1",
"crypto-js": "^4.0.0",
"ini": "^2.0.0",
"linqts": "^1.14.3",
"ng-dynamic-component": "^8.0.0",
"node-fetch": "^2.6.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
write in polyfilss.ts:
(window as any).global = window;
directly into package.json:
"browser": {
"crypto": false
}
app-module aws-imports:
import Amplify from 'aws-amplify';
import {AmplifyUIAngularModule} from '@aws-amplify/ui-angular';
import awsmobile from '../aws-exports.js';
Amplify.configure(awsmobile);
在 .../build/options 下的 angular.json 中:
"allowedCommonJsDependencies": [
"crypto-js",
"@aws-sdk/eventstream-marshaller",
"buffer",
"js-cookie",
"@aws-crypto",
"zen-observable",
"@aws-sdk/util-utf8-node",
"@aws-crypto/sha256-js",
"@aws-crypto/crc32",
"@aws-sdk/util-buffer-from",
"@aws-sdk/smithy-client",
"@aws-sdk/middleware-serde",
"@aws-sdk/middleware-user-agent",
"@aws-sdk/middleware-retry",
"@aws-sdk/middleware-signing",
"@aws-sdk/middleware-content-length",
"@aws-sdk/middleware-host-header",
"@aws-sdk/config-resolver",
"@aws-sdk/s3-request-presigner",
"@aws-sdk/util-format-url",
"@aws-sdk/util-create-request",
"@aws-sdk/property-provider",
"axios",
"@aws-sdk/fetch-http-handler",
"@aws-sdk/protocol-http",
"@aws-sdk/querystring-builder",
"@aws-sdk/util-utf8-browser",
"@aws-sdk/url-parser-browser",
"@aws-crypto/sha256-browser",
"@aws-sdk/url-parser-node",
"@aws-sdk/util-uri-escape",
"@aws-sdk/middleware-sdk-s3",
"@aws-sdk/middleware-bucket-endpoint",
"@aws-sdk/querystring-parser",
"@aws-sdk/middleware-apply-body-checksum",
"@aws-sdk/middleware-ssec",
"@aws-sdk/middleware-expect-continue",
"fast-xml-parser",
"@aws-sdk/xml-builder",
"@aws-sdk/md5-js",
"@aws-sdk/hash-blob-browser",
"@aws-sdk/eventstream-serde-browser",
"@aws-sdk/middleware-location-constraint",
"uuid",
"@aws-sdk/credential-provider-cognito-identity",
"@aws-sdk/eventstream-serde-config-resolver",
"@aws-sdk/client-s3",
"@aws-sdk/client-pinpoint",
"ulid",
"zen-push",
"lodash",
"@aws-amplify/core",
"@aws-amplify/analytics",
"@aws-amplify/ui-components",
"isomorphic-unfetch"
]
在 tsconfig.json 作为 compilerOptions 的一部分:
"paths": {
"crypto": [
"../../node_modules/crypto-js"
]
}
那么就没有更多的警告或错误了。