Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadow-cljs failing to run watch-with-amplify #8

Open
rberger opened this issue Dec 21, 2021 · 4 comments
Open

shadow-cljs failing to run watch-with-amplify #8

rberger opened this issue Dec 21, 2021 · 4 comments

Comments

@rberger
Copy link

rberger commented Dec 21, 2021

If I clone master of this repo and do

npm install
npm run watch-with-amplify

The shadow-cljs run gets a warning and doesn't build the js modules for the app-with-amplify

The build output:

 npm run watch-with-amplify

> [email protected] watch-with-amplify
> shadow-cljs watch app-with-amplify stories

shadow-cljs - config: /Users/rberger/work/aws/clojurescript-amplified/shadow-cljs.edn
shadow-cljs - HTTP server available at http://localhost:8080
shadow-cljs - server version: 2.16.4 running at http://localhost:9630
shadow-cljs - nREPL server started on port 64363
shadow-cljs - watching build :app-with-amplify
shadow-cljs - watching build :stories
[:app-with-amplify] Configuring build.
[:stories] Configuring build.
[:app-with-amplify] Compiling ...
[:stories] Compiling ...
[2021-12-20 23:55:33.193 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (map? rc)
	shadow.build.resolve/maybe-babel-rewrite (resolve.clj:205)
	shadow.build.resolve/maybe-babel-rewrite (resolve.clj:205)
	shadow.build.resolve/fn--11790 (resolve.clj:414)
	shadow.build.resolve/fn--11790 (resolve.clj:405)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:80)
	shadow.build.resolve/find-resource-for-string (resolve.clj:69)
	shadow.build.resolve/resolve-string-require (resolve.clj:452)
	shadow.build.resolve/resolve-string-require (resolve.clj:435)
	shadow.build.resolve/resolve-require (resolve.clj:672)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-deps/fn--11704 (resolve.clj:51)
[:stories] Build completed. (436 files, 0 compiled, 0 warnings, 3.33s)

Any idea what's up? I presume this did work. The only things I could think is different is I'm running node v17.2.0. Otherwise everything else is set by the package.json and the shadow-cljs.edn which are unchanged from the repo.

@DavidVujic
Copy link
Owner

I get that too, tried in both Node 17 and 16. I'll look into it, thank you for reporting!

@DavidVujic
Copy link
Owner

I think I have solved it 😄

This one took a while to find out! I suspected it might have to do with the :js-options thing in the amplify alias. So I commented it out just to see if the code will compile, and ran the watcher on it.

By doing that, the actual error appeared in the terminal. It is an auto-generated AWS Amplify that is missing. It is the src/main/aws-exports.js file, required by src/main/app/amplified/core.cljs.

The auto generated file begins with something like:

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "eu-west-1",

.......

and will be generated when doing the AWS Amplify setup.

I have to find a way to make this clearer, perhaps there is a better way to require this one. Do you have any ideas? @rberger

@rberger
Copy link
Author

rberger commented Dec 21, 2021

So yeah, I should have thought about this. If I even just copy my aws-exports.js from another project to here, your repo builds correctly (though probably won't actually work since my project doesn't have the same resources).

The /aws-exports.js is supplied when one does the amplify pull which would be based on the actual Amplify project. This can only be done if you have the app-id and permission to access the AWS Amplify backend project (Which only you should have). Or by creating a new amplify project in the repo and going thru all the steps of that and then doing the amplify pull

Silly mistake, though I am still having the problem on my own new amplify project (trying to get a project with the new Amplify Studio to work with Clojurescript) which is based on the same concepts as your repo. But I must have some other bug that is causing the failure. I'll have to see what's different.

The :js-options stuff seems to be masking the issue on my end. I.e. if I remove the :js-options on my project, I get different failures like:

The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/client-sso/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js".

The required JS dependency "aws-crt" is not available, it was required by "node_modules/@aws-sdk/client-sso/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js"
Thanks for checking into it.

If I try to resolve it as per a bug I had reported to was-amplify and didn't remember, I end up with another failure which just seems to show I must be doing something really wrong, but I have no idea what it is yet!

Failed to inspect file
  /Users/rberger/work/aws/amplify-rental-reagent-app/node_modules/lower-case/dist/index.js

it was required from
  /Users/rberger/work/aws/amplify-rental-reagent-app/node_modules/no-case/dist/index.js

Errors encountered while trying to parse file
  /Users/rberger/work/aws/amplify-rental-reagent-app/node_modules/lower-case/dist/index.js
  {:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}
[:app] Configuring build.
[:app] Compiling ...
[2021-12-21 14:21:34.180 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:config {:target :browser, :output-dir "public/js", :asset-path "/js", :js-options {:resolve {"http2" false, "aws-crt" false}, :js-provider :external, :external-index "target/index.js"}, :modules {:main {:init-fn amplify-rental-reagent-app.app.core/main}}, :build-id :app}, :shadow.cljs.model/topic [:shadow.cljs.model/config-watch :app]}}
AssertionError Assert failed: (map? rc)

@rberger
Copy link
Author

rberger commented Dec 22, 2021

The problems I'm having in my derivative work look to be my own problems. I also realized I was trying to "import" jsx files not js files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants