Open sgammon opened 5 years ago
Did some digging and it definitely seems like rules_closure is doing what it should. Cross-filed with GCC at google/closure-compiler#3427.
after some discussion on google/closure-compiler#3427, and a sample repo at sgammon/css-rewrite-bug, it has been determined it isn't the compiler, which of course was likely.
it now seems like it might be an issue inside J2CL, because i can't get rules_closure
to build the sample at all without wrapping it in j2cl_application
. more to come, if anybody is hitting this same issue
btw if you are getting issues with symbols-already-defined for goog.soy
or soy
, try building through j2cl_application
. i have no idea why it works but it does.
The issue is that you set dependency_mode = "STRICT"
, which will eliminate all files that are not in the transitive closure of entry_points
(i.e. not in entry_points
and never goog.require
d). As a workaround, you can
dependency_mode = "PRUNE_LEGACY"
which will include all files without goog.{module,provide}
as entry points (https://github.com/google/closure-compiler/blob/445fdf3f31d848d955d71d10f4794b45c0f4d1a6/src/com/google/javascript/jscomp/CommandLineRunner.java#L805), orsrc/sample-styles.css.js
as entry pointWe should probably automatically add the css rewrining map as an entry point.
Also, dependency_mode = "STRICT"
is deprecated. You should switch to dependency_mode = "PRUNE"
which has the same effect:
tl;dr CSS rewriting does not seem to be working, at least in terms of JS' invocation of
getCssName
.Given the following setup (
WORKSPACE
and related wiring omitted):sample.soy
:sample.css
:sample.js
:BUILD.bazel
:When I build and run the resulting JS, the template renders, but it renders with the original CSS names, whereas, the CSS has been rewritten. This breaks styles, of course.
Digging into the intermediates:
bazel-out/darwin-fastbuild/bin/.../sample.js-0.params
:The last entry in the set of input files, is a file that ends in
css.js
. Examining that file, it looks like we're on the money:In the generated template file, it seems to know what's going on (as in, it's using
goog.getCssName
):But, in the final output JS, it uses the original classes:
Anybody have any ideas? Or, at least, is anyone seeing the same behavior?