ClojureScript

Node packages with browser entry don't work with Closure

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 1.9.854
  • Fix Version/s: 1.10.238
  • Component/s: None
  • Approval:
    Vetted

Description

Closure doesn't yet support package.json browser field: https://github.com/google/closure-compiler/issues/2433

However, our, module_deps.js / brower-resolve, and use this field.

One package that has problems is https://github.com/PaulLeCam/react-leaflet which depends on https://github.com/BerkeleyTrue/warning which uses browser entry.
index-node-modules-dir reuturns a list of all JS files in node_modules, this includes both warning/warning.js and warning/browser.js. index-node-modules only includes warning/browser.js. Because Closure doesn't understand package.json browser field, it can't resolve the warning require when processing React-leaflet: https://github.com/PaulLeCam/react-leaflet/blob/master/lib/Pane.js#L47

(cljs.closure/index-node-modules-dir)
;; =>
{:file "/home/juho/Source/x/y/node_modules/warning/warning.js", :module-type :es6, :provides ["warning/warning.js" "warning/warning" "warning"]}
{:file "/home/juho/Source/x/y/node_modules/warning/browser.js", :module-type :es6, :provides ["warning/browser.js" "warning/browser"]}
(cljs.closure/index-node-modules ["react-leaflet"])
;; =>
{:file "/home/juho/Source/x/y/node_modules/warning/browser.js", :module-type :es6, :provides ["warning" "warning/browser.js" "warning/browser"]}

Activity

Hide
António Nuno Monteiro added a comment -

This is now fixed in Closure Compiler master (https://github.com/google/closure-compiler/pull/2598).

Show
António Nuno Monteiro added a comment - This is now fixed in Closure Compiler master (https://github.com/google/closure-compiler/pull/2598).

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: