Tests failing with latest Closure Compiler snapshot

Description

If you use the latest Closure Compiler, tests will break with ReferenceError: module is not defined.

Repro:

  1. script/bootstrap --closure-compiler-snapshot

  2. script/test

Note that this broke as of closure-compiler-1.0-20180629.155739-322.jar.

Environment

None

Activity

Show:

Mike Fikes July 4, 2018 at 12:05 PM

Mike Fikes July 2, 2018 at 12:23 PM

Confirmed that this PR causes the ClojureScript compiler unit tests to pass https://github.com/google/closure-compiler/pull/3000

Mike Fikes July 1, 2018 at 11:48 PM

Mike Fikes July 1, 2018 at 11:17 PM

Perhaps this is a regression in Closure Compiler:

node_modules/lodash/isBuffer.js contains this bit of code:

/** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;

Previously this would be rewritten as (when copied to builds/out-adv/node_modules/lodash/isBuffer.js):

var freeModule$$module$Users$mfikes$Projects$clojurescript$node_modules$lodash$isBuffer=freeExports$$module$Users$mfikes$Projects$clojurescript$node_modules$lodash$isBuffer&&"object"=="object"&&module&&!module.nodeType&&module;

but with the change in Closure Compiler this is now rewritten as the following:

var freeModule$$module$Users$mfikes$Projects$clojurescript$node_modules$lodash$isBuffer=freeExports$$module$Users$mfikes$Projects$clojurescript$node_modules$lodash$isBuffer&&"object"=="object"&&{}&&!module.nodeType&&{};

In particular note that the sub-expression

module&&!module.nodeType&&module

becomes simply

{}&&!module.nodeType&&{}

with a dangling un-rewritten module reference.

A theory is that Closure Compiler is looking for expressions involving module to rewrite and misses or mishandles the bit of code in Lodash.

Mike Fikes July 1, 2018 at 10:43 PM

Completed

Details

Assignee

Reporter

Priority

Created June 29, 2018 at 7:32 PM
Updated July 4, 2018 at 12:05 PM
Resolved July 4, 2018 at 12:05 PM