0

我有一个 aws-amplify v.1.2.4 并且可以正常使用

(ns app.core
    ["aws-amplify" :default Amplify]
    ["aws-amplify" :refer [Auth]])

(js/console.log Amplify) 是一个模块 (js/console.log Auth) 并且是一个 AuthClass

但是在将 aws-amplify 升级到 v.3.3.4 后,我无法使其工作

这两个值现在都不可用。

我尝试的是:

["@aws-amplify/core" :as amplify-core]
["@aws-amplify/auth" :as amplify-auth]

但它没有按预期工作。

amplify-core/Amplify 现在是AmplifyClass,但其中几乎所有内容都是null。也许这是一个问题?我可以打电话给

(.configure amplify-core/Amplify awsAmplifyConfig)

它似乎工作正常。

(console.log amplify-auth) => {__esModule: true}

我不能用它做任何事情。有没有办法获得实际的 Auth 类?

此外,控制台中还有一堆警告。似乎 shadow-cljs 无法加载某些模块: 控制台屏幕

shadow-cljs - failed to load module$node_modules$http2$lib$protocol$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$http2$lib$http @ http.js:138
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$http2$lib$index @ index.js:19
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$node_http2_handler @ node-http2-handler.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig @ runtimeConfig.js:12
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$http2$lib$http
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$http2$lib$index @ index.js:19
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$node_http2_handler @ node-http2-handler.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig @ runtimeConfig.js:12
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$http2$lib$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$node_http2_handler @ node-http2-handler.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig @ runtimeConfig.js:12
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$node_http_handler$dist$cjs$node_http2_handler
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$node_http_handler$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig @ runtimeConfig.js:12
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$node_http_handler$dist$cjs$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig @ runtimeConfig.js:12
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$runtimeConfig
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient @ CognitoIdentityClient.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$CognitoIdentityClient
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$client_cognito_identity$dist$cjs$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity @ fromCognitoIdentity.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$fromCognitoIdentity
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_sdk$credential_provider_cognito_identity$dist$cjs$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_amplify$core$lib$Credentials @ Credentials.js:58
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_amplify$core$lib$Credentials
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$aws_amplify$core$lib$index @ index.js:42
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822

js.js:74 shadow-cljs - failed to load module$node_modules$$aws_amplify$core$lib$index
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
eval @ app.core.js:5
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2224
(anonymous) @ main.js:3822
main.js:2226 failed to load app.core.js Module not provided: ./framer

有任何想法吗?

4

1 回答 1

1

我能够解决模块加载问题。例如,请查看此存储库

诀窍是

  1. 将编译器选项切换到 ES 6
  2. 确保它main用于解析 JavaScript 库中的代码。这可确保使用兼容的模块系统解析 AWS Amplify 代码。
  3. 激活对试剂中功能性反应成分的支持
  4. 安装 AWS Amplify 使用但不知何故未通过依赖项解析安装的库

对于 1. 和 2. 只需将以下行添加到您的shadow-cljs.edn文件中:

:compiler-options {:output-feature-set :es6}
:js-options {:provider :closure
             :entry-keys ["main" "module" "browser"]}

对于 3. 您需要将这两行添加到您的core.cljs

(def functional-compiler (r/create-compiler {:function-components true}))
(r/set-default-compiler! functional-compiler)

这些更改可能会产生意想不到的副作用!

于 2021-03-21T16:06:50.547 回答