Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Uncaught TypeError: t.draggableLines.enableForLayer is not a function" (Leaflet.DraggableLines is broken in production) #20

Open
lehnerpat opened this issue May 30, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@lehnerpat
Copy link
Owner

When trying to edit the track path in editing mode, nothing happens and the following error is printed in the browser console:

Uncaught TypeError: t.draggableLines.enableForLayer is not a function

It seems something breaks with DraggableLines in production, possibly an issue with minification.

@lehnerpat lehnerpat added the bug Something isn't working label May 30, 2022
@lehnerpat
Copy link
Owner Author

I've tracked this a little bit.
Because of our browserslist selection of browser compatibility (default from CRA), the dev build only targets very modern browsers, while the prod build targets a wider range of browsers. As a result, the underlying webpack build produces ES6 output for dev, but ES5 for prod.

In the ES5 prod build, most methods of the DraggableLinesHandler class from Leaflet.DraggableLines are not accessible. When instantiating it, the compiled code simply doesn't correctly use the prototype built from the class definition.

I don't know yet why this happens, it could possibly be a compilation bug, though these are generally unlikely. I'll continue investigating again at a later point.

@lehnerpat
Copy link
Owner Author

One hypothesis I have is that mixing the ES6/TS class-based inheritance you use in DraggableLinesHandler with Leaflet's custom-built class system somehow confuses the Babel transpiler or something.
I'm planning to test this by adding another simple subclass of Handler in my own code, and see if it shows the same behavior, and then possibly also trying to change DraggableLinesHandler to use Leaflet's L.Class.extend() instead of ES6 classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant