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

Webpack, AMD, CommonJS... which one are you using? #115

Open
lamuertepeluda opened this issue Feb 23, 2016 · 9 comments
Open

Webpack, AMD, CommonJS... which one are you using? #115

lamuertepeluda opened this issue Feb 23, 2016 · 9 comments
Milestone

Comments

@lamuertepeluda
Copy link

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.

//ES5 style
var PruneCluster = require("prunecluster/dist/PruneCluster.js");
//ES6 with Babel
import {PruneCluster, PruneClusterForLeaflet} from "prunecluster/dist/PruneCluster.js";
//hoping to find some default
import "prunecluster/dist/PruneCluster.js";

Leaflet

import L from "leaflet/dist/leaflet-src.js";

I guess you should do something about it...

@lamuertepeluda
Copy link
Author

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.

@fungiboletus
Copy link
Member

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.

@lamuertepeluda
Copy link
Author

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.

@danvirsen
Copy link

Any updates on this?

@fungiboletus fungiboletus added this to the 2.0.0 milestone Sep 12, 2016
@fungiboletus
Copy link
Member

It's on the TODO list.

@ghost
Copy link

ghost commented May 6, 2017

Using webpack export loader, add this line to your javascript.

import { PruneCluster, PruneClusterForLeaflet } from 'exports-loader?PruneCluster,PruneClusterForLeaflet!prunecluster/dist/PruneCluster.js'

@disarticulate
Copy link
Contributor

@gtanguay may not be obvious to some:

npm install exports-loader --save-dependency

@pedroetb
Copy link

Any update on this? I have been using the fork proposed at #161 pull request since 2018.

@fungiboletus
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants