Dash_extensions doesn't find Namespace after beeing built with cx_freeze

Viewed 153

I use the dash_extensions.javascript function Namespace to use js code in my dash application. It works fine when running in the IDE. After building with cx_freeze the Namespace is not found. The exact error is:

No match for [myNamespace.mySubNamespace.function_name] in the global window object.

Similar errors occure when using the assign function of dash_extensions and when using dash_transcrypt module_to_props()

I am using:

  • dash=2.1.0
  • dash_extensions=0.0.67
  • dash_transcrypt=0.0.6
  • dash_leaflet=0.1.18
  • cx_freeze=6.10

Can someone reproduce this behavior? Is this intentional or is my use case not suited for dash?

1 Answers

Try to place inside yout Dash /assets folder a .js file with all your functions (e.g. dashExtensions.js)

Example:

window.dashExtensions = Object.assign({}, window.dashExtensions, {
  default: {
    drawMarkers: function (feature, latlng, context) {
      return L.circleMarker(latlng, { radius: 2 }); // sender a simple circle marker.
    },
  },
});

Then inside your python code put ns = Namespace("dashExtensions", "default"). Notice the correspondance between the dashExtensions and the default

Related