Skip to content

Commit 314f7fa

Browse files
concavelenzcopybara-github
authored andcommitted
Add a unit test showing that goog.module.get is not properly collapsed and this results in unnecessary bloat.
PiperOrigin-RevId: 715981791
1 parent 108c87a commit 314f7fa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/com/google/javascript/jscomp/InlineAndCollapsePropertiesTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,27 @@ public void testCtorManyAssignmentsDontInlineWarn() {
19021902
warning(InlineAndCollapseProperties.UNSAFE_CTOR_ALIASING));
19031903
}
19041904

1905+
@Test
1906+
public void testCollapseOfGoogModule() {
1907+
test(
1908+
lines(
1909+
"var goog = goog || {};", //
1910+
"/** @constructor */",
1911+
"goog.module = function(id) {};",
1912+
"goog.module.get = function(id) {};",
1913+
"goog.module.getInternal_ = function(id) {};",
1914+
"goog.module = goog.module || {};",
1915+
""),
1916+
lines(
1917+
"var goog = goog || {};", //
1918+
"var goog$module = function(id) {};",
1919+
// TODO(b/389129315): This should be goog$module$get.
1920+
"goog$module.get = function(id) {};",
1921+
"goog$module.getInternal_ = function(id) {};",
1922+
"goog$module = goog$module || {};",
1923+
""));
1924+
}
1925+
19051926
@Test
19061927
public void testCodeGeneratedByGoogModule() {
19071928
// The static property is added to the exports object

0 commit comments

Comments
 (0)