Turf: bbox-polygon v6.0.0 - helpers_1.polygon is not a function

Created on 23 Mar 2018  Â·  5Comments  Â·  Source: Turfjs/turf

I just installed @turf/bbox-polygon and got v6.0.0. However upon using it I get the following error:

TypeError: helpers_1.polygon is not a function
bboxPolygon
node_modules/@turf/bbox-polygon/index.js:36

  33 | var topLeft = [west, north];
  34 | var topRight = [east, north];
  35 | var lowRight = [east, south];
> 36 | return helpers_1.polygon([[
  37 |         lowLeft,
  38 |         lowRight,
  39 |         topRight,

addLayers/<
src/components/Map.js:158

> 158 | const bboxData = bboxPolygon([
  159 |   layer.bounds.west, layer.bounds.south,
  160 |   layer.bounds.east, layer.bounds.north
  161 | ])

If I switch to v5.1.5 there's no issue.

Most helpful comment

My bad: I also had the entire @turf/turf installed as a dependency, probably causing a conflict. Removing that in favour of the specific packages I need, and there's no issue. Thanks, and great work on v6.0.0 :+1:

All 5 comments

Hi @alpha-beta-soup

Thanks for reporting. yeah we've had a few issues with v6 publishing, sometimes it's resolved using someModule.default() although in this case it looks like something wrong with the dependency being called, I can check further when I'm back at a computer.

c.c. @deniscarriere

@alpha-beta-soup Seems to work on my side, must be something with your build.

Can you provide your build setup and a sample code of how you are using the module.

The following works for me:

install

$ yarn install @turf/bbox-polygon

CommonJS - test.js

const bboxPolygon = require('@turf/bbox-polygon').default
const poly = bboxPolygon([-180, -90, 180, 90])
console.log(poly)
$ node test.js
{ type: 'Feature',
  bbox: [ -180, -90, 180, 90 ],
  properties: {},
  geometry: { type: 'Polygon', coordinates: [ [Array] ] } }



md5-b65105ed7b35617a996f77fa1dc2ea9a



$ ts-node test.ts
{ type: 'Feature',
bbox: [ -180, -90, 180, 90 ],
properties: {},
geometry: { type: 'Polygon', coordinates: [ [Array] ] } }
```

Going to close the issue unless there's more information provided by @alpha-beta-soup

Install

npm i --save @turf/bbox-polygon

npm -v → 5.6.0
node -v → v6.10.3

mbLayer.js

import bboxPolygon from '@turf/bbox-polygon'

export default (bounds, id) => {
  return {
    layer: {
      id,
      type: 'line',
      source: id,
      paint: {
        'line-width': 2,
        'line-color': '#0E345D',
        'line-offset': -1,
        'line-opacity': 0.8
      },
      layout: {
        'visibility': 'visible',
        'line-join': 'round'
      },
    },
    source: {
      type: 'geojson',
      data: bboxPolygon([
        bounds.west, bounds.south,
        bounds.east, bounds.north
      ])
    }
  }
}

Same code across versions v5.1.5 and v6.0.0, and only v6.0.0 produced the error.

My bad: I also had the entire @turf/turf installed as a dependency, probably causing a conflict. Removing that in favour of the specific packages I need, and there's no issue. Thanks, and great work on v6.0.0 :+1:

@alpha-beta-soup Ok thanks for the update, conflicting dependencies always cause an issue.

Was this page helpful?
0 / 5 - 0 ratings