Replies: 3 comments 17 replies
-
Sorry, I know nothing about remix, and don't have time to investigate.
It is just a regular namespace that gets "injected" into the build and establishes the websocket connect when loaded So, in theory you could try to strip this namespace down to the bare essentials in a way that works in both remix client and server? The node version is substantially smaller since it doesn't do all the HUD stuff? None of this is documented, but maybe you can figure it out. It basically just wants to connect to A demo repo would help, even if it doesn't work. I can at least provide tips from the build side. |
Beta Was this translation helpful? Give feedback.
-
Got the remix minimal setup here: https://github.com/eccentric-j/cljs-shadow-remix-demo
Bad news, I'm getting a whole new error.
Not sure why. I'm going to keep poking at it this weekend but if you by chance have any insight here, it would be vastly appreciated 😅 |
Beta Was this translation helpful? Give feedback.
-
Traced down the original error more:
This is due to goog checking to see if a module was already provided, which is established in the compiled goog.provide = function(name) {
if (goog.isInModuleLoader_()) {
throw new Error("goog.provide cannot be used within a module.");
}
if (!COMPILED) {
if (goog.isProvided_(name)) {
throw new Error('Namespace "' + name + '" already declared.');
}
}
goog.constructNamespace_(name);
}; It's caused by remix's auto-reloaded solution for integrating with express apps: app.all(
"*",
process.env.NODE_ENV === "development"
? (req, res, next) => {
purgeRequireCache()
return createRequestHandler({
build: require(BUILD_DIR),
mode: process.env.NODE_ENV,
})(req, res, next)
}
: createRequestHandler({
build: require(BUILD_DIR),
mode: process.env.NODE_ENV,
}),
)
function purgeRequireCache() {
// purge require cache on requests for "server side HMR" this won't let
// you have in-memory objects between requests in development,
// alternatively you can set up nodemon/pm2-dev to restart the server on
// file changes, but then you'll have to reconnect to databases/etc on each
// change. We prefer the DX of this, so we've included it for you by default
for (const key in require.cache) {
if (key.startsWith(BUILD_DIR)) {
delete require.cache[key]
}
}
} I've tried adding the following to purgeRequireCache:
Unfortunately though, that solution does not work. Going to keep at it, but if any solutions come to mind I'm very interested! |
Beta Was this translation helpful? Give feedback.
-
Currently integrating shadow-cljs builds into an existing TS Remix app at work.
My strat is to target esm, then import it into TS route files as the single component rendered on the page and\or import the loader function.
Just got it building and rendering a reactified reagent view so happy about that. However, one tragic casualty was the repl support. From what I understand only the browser runtime is supported, but unfortunately that caused the remix bundling to break server side due to the missing WebSocket APIs. Remix bundles each route and it's dep twice: Once for server and once for client.
Trying to think through if there's a way to make it work.
One solution off the top of my head would be to create separate bundles via shadow-cljs edn builds directly into the remix build directory. Might mess with the static analysis tooling but should still run.
Any better ideas out there?
Beta Was this translation helpful? Give feedback.
All reactions