You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
I have a legacy project written in CommonJS, so I had to bundle and transpile this project in combination with Babel. Almost everything works fine, except a few import statements from the package '@Turf'.
My project consists of .js (CommonJS) files and .mjs files (ECMAscript 6). This interoperability works good for the most part, but when I import import center from '@turf/center'; in one of my .mjs files, I get this error: center_ is not a function
When I look at the bundled code I see this:
// EXTERNAL MODULE: external "@turf/center"
var center_ = __webpack_require__("@turf/center");
But when I console.log the center_ variable, I see that it exports a default function: { default: [Function: center] }
And in the code it's trying to access this function like so: center_(boundingBoxPolygon);
Which does not work, and raises the "center_ is not a function" error.
Expected/desired behavior:
That the library gets imported and automatically uses the default export. Instead of trying to invoke the returned object.
`import { BBox, Id, AllGeoJSON, Feature, Point, Properties } from "@turf/helpers";
/**
* Takes a {@link Feature} or {@link FeatureCollection} and returns the absolute center point of all features.
*
* @name center
* @param {GeoJSON} geojson GeoJSON to be centered
* @param {Object} [options={}] Optional parameters
* @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
* @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point
* @param {Object} [options.id={}] Translate GeoJSON Id to Point
* @returns {Feature<Point>} a Point feature at the absolute center point of all input features
* @example
* var features = turf.points([
* [-97.522259, 35.4691],
* [-97.502754, 35.463455],
* [-97.508269, 35.463245]
* ]);
*
* var center = turf.center(features);
*
* //addToMap
* var addToMap = [features, center]
* center.properties['marker-size'] = 'large';
* center.properties['marker-color'] = '#000';
*/
declare function center<P = Properties>(geojson: AllGeoJSON, options?: {
properties?: P;
bbox?: BBox;
id?: Id;
}): Feature<Point, P>;
export default center;
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
Webpack Version:
5.91.0
Babel Core Version:
7.24.5
Babel Loader Version:
9.1.3
Please tell us about your environment:
OSX 14.4.1
Current behavior:
I have a legacy project written in CommonJS, so I had to bundle and transpile this project in combination with Babel. Almost everything works fine, except a few import statements from the package '@Turf'.
My project consists of .js (CommonJS) files and .mjs files (ECMAscript 6). This interoperability works good for the most part, but when I import
import center from '@turf/center';
in one of my .mjs files, I get this error:center_ is not a function
When I look at the bundled code I see this:
But when I console.log the
center_
variable, I see that it exports a default function:{ default: [Function: center] }
And in the code it's trying to access this function like so:
center_(boundingBoxPolygon);
Which does not work, and raises the "center_ is not a function" error.
Expected/desired behavior:
That the library gets imported and automatically uses the default export. Instead of trying to invoke the returned object.
Webpack config file
@turf/center/index.d.ts
The text was updated successfully, but these errors were encountered: