ClojureScript

Node packages using require('assert') fail compilation

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: 1.9.854
  • Fix Version/s: 1.9.908
  • Component/s: None
  • Patch:
    Code and Test
  • Approval:
    Vetted

Description

When including packages that contain "require('assert')" as a node dependency – for example, https://github.com/uber/react-map-gl – Clojurescript fails to compile the module with the following error (note that importing react-map-gl currently requires closure compiler master because Mapbox GL has dependencies which require the fix from https://github.com/google/closure-compiler/pull/2579):

WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/react-map-gl/dist/utils/map-state.js line 14 : 4
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/react-map-gl/dist/utils/map-state.js line 14 : 14
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/viewport-mercator-project/dist/perspective-mercator-viewport.js line 24 : 14
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/viewport-mercator-project/dist/perspective-mercator-viewport.js line 24 : 4
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/viewport-mercator-project/dist/viewport.js line 52 : 14
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "assert" at [...]/node_modules/viewport-mercator-project/dist/viewport.js line 52 : 4

For reference, the relevant js files:
https://unpkg.com/react-map-gl@3.0.1/dist/utils/map-state.js
https://unpkg.com/viewport-mercator-project@4.1.1/dist/perspective-mercator-viewport.js
https://unpkg.com/viewport-mercator-project@4.1.1/dist/viewport.js

Naively adding https://github.com/defunctzombie/commonjs-assert to package.json or :npm-deps alone does not resolve the issue.

Activity

Hide
António Nuno Monteiro added a comment -

Attached patch with fix.

Show
António Nuno Monteiro added a comment - Attached patch with fix.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: