Fork me on GitHub
#shadow-cljs
<
2023-10-20
>
mitchelkuijpers09:10:46

Hi all, I am trying to compile a project as ESM to use as a cloud function but when I change my project to use ESM and define module an compile it I get the following error:

[:functions] Configuring build.
[:functions] Compiling ...
[:functions] Build failure:
The required JS dependency "os" is not available, it was required by "node_modules/rollbar/src/server/rollbar.js".

Dependency Trace:
	avisi/timesheet/cloud_functions/handle_request.cljs
	avisi/timesheet/rollbar.cljs
	node_modules/rollbar/src/server/rollbar.js

Searched for npm packages in:
	/Users/mitkuijp/Development/tracket/node_modules
os is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.

	npm install --save-dev shadow-cljs

See: 
This is my shadow-cljs config:
:functions {:closure-defines {avisi.timesheet.rollbar/GIT_SHA #shadow/env "CIRCLE_SHA1"}
                      :target :esm
                      :runtime :node
                      :output-dir "dist"
                      :modules {:handle-request {:exports {handlerequestv2 avisi.timesheet.cloud-functions.handle-request/export}}}}

mitchelkuijpers09:10:52

Ah I think I need to change my import provider:

:js-options {:js-provider :import}
Adding this fixes it

mitchelkuijpers09:10:39

Does this not give a nodejs esm package though unfortunately

mitchelkuijpers09:10:26

Now I get in a world of other issues unfortunately

thheller10:10:56

like what? 😛

thheller10:10:42

switching to :js-provider :import is correct