Open lamuertepeluda opened 8 years ago
By the way a found a solution by myself but it's more an hack that puts the issue in evidence:
import L from "leaflet/dist/leaflet-src.js";
var PruneCluster = require("imports?L=leaflet/dist/leaflet-src.js!exports?PruneCluster!prunecluster/dist/PruneCluster.js");
I found out this by reading this docs.
However there would be no need if you stick to some standard module definitions.
Hi,
module.exports
or define
are not supported and undefined on web browsers, as far as I know. If you look at Leaflet's source code, it contains specific code to support AMD or CommonJS module definitions.
We could add support for AMD or CommonJS the same way Leaflet does, a PR is welcome.
That's correct: there is some additional code required to support module definition, just like Leaflet does. However there are obvious advantages when integrating the library in a wider project.
Also UMD is an option.
I'll see what I can do, given that I'm not familiar with TypeScript at all, in order to make a PR.
Any updates on this?
It's on the TODO list.
Using webpack export loader, add this line to your javascript.
import { PruneCluster, PruneClusterForLeaflet } from 'exports-loader?PruneCluster,PruneClusterForLeaflet!prunecluster/dist/PruneCluster.js'
@gtanguay may not be obvious to some:
npm install exports-loader --save-dependency
Any update on this? I have been using the fork proposed at #161 pull request since 2018.
Hei @pedroetb This project has been on pause for a few years, mostly because I left the company and no one took over.
I hope to resume the development at some point and modernize it, but I cannot give a timeline because I don't have a budget for that yet.
Things has changed with now MapBoxGLJS/MapLibre or Deck.gl. Meanwhile you can continue to use the fork if it still work.
I'm having troubles importing PruneCluster into my webpack project. None of these is working! Always undefined. It seems like the library does not follow any convention, while Leaflet does.
Leaflet
I guess you should do something about it...