Hello @thheller. On the storybook (ESM build) i'm getting the following error on reloading the namespace.
Namespace "shadow.esm.esm_import$react" already declared.
Continue on a 🧵The module in question is:
js
import "./cljs_env.js";
import * as esm_import$react from "react";
goog.provide("shadow.esm.esm_import$react");
shadow.esm.esm_import$react = esm_import$react;
the exception is raised inside goog.provide.
is storybook doing the reloading?
we are building a esm module which storybook consumes
so its storybook doing the reloading. not shadow-cljs?
i guess yes
:storybook
{:target :esm
:output-dir "target/storybook/"
:js-options
{:js-provider :import
:entry-keys ["module" "browser" "main"]
:export-conditions ["module" "import", "browser" "require" "default"]}
we use js-provider import so storybook is reponsible to resolve that imports
Do you have some hints for make this working? I mean, it works but requires a page refresh after each change
shadow-cljs calls this when its devtools are loaded/connected https://github.com/thheller/shadow-cljs/blob/d12811cfb7884d86dcecb3a16cf61c9e89bb8b05/src/main/shadow/cljs/devtools/client/env.cljs#L152-L161
that basically patches the already declared thing
I guess you'd need to do the same yourself if shadow-cljs isn't reloading
thanks for the hint
but dunno why storybook would reload that file? if it always just reloads everything stuff will likely break
i'm not clearly understand what is really happens but adding
:prepend-js ";(globalThis.goog.provide = globalThis.goog.constructNamespace_);(globalThis.goog.require = globalThis.goog.module.get);"
fixes the issue
Looks like it shadow making reloading
that wouldn't throw the already declared error
maybe both doing the reloading? I don't really use storybook, so no clue what it does
maybe try :devtools {:enabled false} in the build config and check if something is still reloading
yeah, looks like both are reloadin
disabling devtools there, still reloads on storybook
better to only use one method, otherwise they just compete and get in each others way and probably just always reloading twice
yep, totally agree many thanks for the hints