Skip to content

Mixing default and named exports makes i hard to import #85

Open
@pbvahlst

Description

@pbvahlst

After the named export pathToGeoJSON was added it has become hard to use the module in node.js without a bundler (rollup/webpack) as the mixing of default and named exports requires multiple steps to import the default export in barebones node.js. The problem is discussed here rollup/rollup#1961 (comment)

In our case we use both a bundler and node.js worker threads to calculate the path-finder graph in a worker thread, so to reuse the code to construct the path finder we have to do this to be able to handle the import in both scenarios.

import geoJsonPathFinder from "geojson-path-finder";
let GeoJsonPathFinder = geoJsonPathFinder;
if (GeoJsonPathFinder.default) {
    GeoJsonPathFinder = GeoJsonPathFinder.default;
}

is it possible to change to all named exports. Or maybe just rewrite the export to have both a default export and named export PathFinder?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions