cljs应用程式中需要aws

cljs应用程式中需要aws

本文介绍了在clojurescript/reagent shadow-cljs应用程式中需要aws-amplify v.3 Amplify和Auth类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个aws-amplify v.1.2.4,它可以正常工作

I had a aws-amplify v.1.2.4 and it was working fine with

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

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

(js/console.log Amplify) was a module(js/console.log Auth) and was a AuthClass

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

But I can't make it work after I upgraded aws-amplify to v.3.3.4

这两个值现在都不可用.

Both values are not available now.

我尝试过的是:

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

但是它没有按预期工作.

But it doesn't work as expected.

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

amplify-core/Amplify now is a AmplifyClass, but almost everything in it is null. Maybe it's an issue?I can call a

(.configure amplify-core/Amplify awsAmplifyConfig)

它似乎工作正常.

但是

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

,我对此无能为力.是否可以获取实际的Auth类?

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

additionally there is a bunch of warnings in the console. Seems shadow-cljs can't load some modules:console screen

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

有什么想法吗?

推荐答案

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

I was able to resolve module loading issues. For an example, please take a look at this repository.

诀窍是

  1. 将编译器选项切换到ES 6
  2. 确保使用 main 解析JavaScript库中的代码.这样可以确保使用兼容的模块系统来解析AWS Amplify代码.
  3. 激活对试剂中功能性反应成分的支持
  4. 安装由AWS Amplify使用但无法通过依赖关系解析安装的库
  1. Switch compiler options to ES 6
  2. Make sure that main is used to resolve code from JavaScript libraries. This ensures that AWS Amplify code is resolved with a compatible module system.
  3. Activate support for functional react components in reagent
  4. Install libraries that are used by AWS Amplify but somehow not installed via dependency resolution

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

For 1. and 2. just andd the following lines to your shadow-cljs.edn file:

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

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

For 3. you need to add these two lines to your core.cljs:

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

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

These changes might have unintended side effects!

这篇关于在clojurescript/reagent shadow-cljs应用程式中需要aws-amplify v.3 Amplify和Auth类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:17