Skip to content

proj4 require statement errors with parcel bundler #70

@JoeGermuska

Description

@JoeGermuska

When trying to use reproject in a project built with Parcel v2, the build errors when scope hoisting with this:

🚨 Build failed.
@parcel/core: node_modules/proj4/lib/index.js does not export 'hasOwnProperty'
/Users/germuska/Development/censusreporter/node_modules/reproject/index.js:3:13
  2 | 
> 3 | var proj4 = require('proj4').hasOwnProperty('default') ? require('proj4').default : require('proj4');
>   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  4 | // Checks if `list` looks like a `[x, y]`.
  5 | function isXY(list) {

With Parcel v2, turning off scope hoisting prevented the error, but of course, at the expense of the optimization benefits that enables.

I was able to work around this by copying reproject/index.js into my own codebase and replacing line 3 with
import proj4 from "proj4"

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