Fork me on GitHub
#cljs-dev
<
2021-08-14
>
thheller08:08:40

@dnolen which problems did you discover in the closure-compiler upgrade? The biggest one as far as shadow-cljs is concerned is the rename of JSModule (and variants) to JSChunk, after renaming references the code seems to work. I changed JSModule and JSModuleGraph in shadow-cljs. The type of the injectedLibraries field also changed but I don't think CLJS uses that

thheller08:08:41

I get more issues in the closure-library upgrade, eg. goog.module.ModuleLoader is now a module and no longer exporting the legacy namespace. thus needs to be used via var thing = goog.require("goog.module.ModuleManager"), ie. using the return value of goog.require which none of the CLJS code currently does

dnolen14:08:53

@thheller we need to switch to builder pattern for SourceFile - JSChunk is the other thing - re: modules, I suppose we already assign some require patterns and we could do that in this case - but I guess it's annoying because it's a conditional thing

dnolen14:08:00

Hrm but is this necessary for ClojureScript? I thought we already addressed this problem - we transpile modules now during dev to lower them

thheller14:08:40

it works fine if the goog.module has the goog.module.declareLegacyNamespace(), some of the newer ones dont have that

dnolen14:08:11

So that has to be detected

thheller14:08:47

well the next problem is that goog.require only has a return value when inside goog.module IIRC

dnolen14:08:10

But that’s not a problem right? You can only use the pattern if you’re loading a module that requires it

dnolen14:08:42

Detecting non legacy modules seems like a regex

thheller14:08:46

not sure. I have a closure .js file in shadow-cljs that I couldn't get to work using the old style. had to rewrite it to also be a goog.module to import goog.module.ModuleLoader

dnolen14:08:50

Ok interesting - we shall see

thheller14:08:55

I'd assume that CLJS has the same issue when trying to use those but this might have been because shadow-cljs doesn't use the default closure debug loader at all

dnolen14:08:10

Yes we use the debug loader

thheller14:08:11

so that may have been the root cause. didn't test much further

dnolen14:08:21

So we just might not have this problem

dnolen14:08:34

It all seems familiar like I already saw all these cases

dnolen14:08:11

Ah but it was in closure lib itself

dnolen14:08:30

It was breaking the pattern - the ns assignment thing in closure itself

dnolen14:08:35

That what was fixed

dnolen14:08:08

So there’s probably still this edgecase for direct non legacy usage of modules

dnolen14:08:24

@thheller thanks for the notes will save some time

👍 6
thheller14:08:42

I briefly thought about just adding (str code "\ngoog.module.declareLegacyNamespaces();") for goog.module files that don't have it when feeding the transpiler

thheller15:08:20

might be a hack but might work

dnolen15:08:36

we already pre-load all the Closure nses and collect our own info - so I think parsing and emitting differently is not hard