[email protected] require is not defined

Created on 7 Dec 2017  路  12Comments  路  Source: Turfjs/turf

When using <script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>:

ReferenceError: require is not defined
turf.min.js:1
    at https://npmcdn.com/@turf/[email protected]/turf.min.js:1:102072
    at https://npmcdn.com/@turf/[email protected]/turf.min.js:1:140
    at https://npmcdn.com/@turf/[email protected]/turf.min.js:1:153

testing before publishing wouldn't hurt...

bug publishing

Most helpful comment

Already fixed... didn't know about the require() (commit https://github.com/Turfjs/turf/commit/01796fe7ddde2a1401f3772700cd6a29697cd684)

All 12 comments

@Spown This was my workaround. https://npmcdn.com/@turf/turf@5.0.4/turf.min.js

Already fixed... didn't know about the require() (commit https://github.com/Turfjs/turf/commit/01796fe7ddde2a1401f3772700cd6a29697cd684)

There is this testing for browser thing http://zombie.js.org/ exactly for this kind of situations.

Thank you for quick response.

It's strange because it worked locally and then when publishing it goes out of whack.

That's what happens when you try to publish 150+ modules with tons of dependencies which are a mixed between CommonJS & ES Modules.

I'll be patching it very soon

@Spown @robertclayton7 Try it now, seems to work on my side using the following:

https://github.com/Turfjs/turf/blob/master/builds/npmcdn/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>React App</title>
    <script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
  </head>
  <body>
  <script>
    console.log(turf.greatCircle([0, 0], [100, 10]));
  </script>
  </body>
</html>

This one doesn't seem to work (cached?):

But yep, I'm up and running with this one:

I just started turfing yesterday - I got the first link from the readme here. When turf.point failed I thought it was because it was deprecated. Thanks for the excitement! :)

I've just switched to npm and using .min version <script src="/static/js/lib/turf.min.js"></script> (which is copied from ./node_modules/@turf/turf/turf.min.js) seems to work fine. unminified version however is bugged. I'll open another issue.

Hi @Spown

Thanks for reporting the issue, we do appreciate that, however please try and minimise the the snark, eg

testing before publishing wouldn't hurt...

Turf is a community run project, @DenisCarriere and others spend a considerable amount of time maintaining this project in their own time unpaid. We've recently had some changes to build processes in transitions to ES6 modules which have introduced a few challenges so we appreciate a bit of patience while we iron out some kinks.

Thanks

unminified version however is bugged.

The unminified is only for CommonJS and not meant for the Browser since it's not a UMD build.

The unminified is only for CommonJS and not meant for the Browser since it's not a UMD build.

Ok... this is confusing. I would suggest putting minified version into a /dist subfolder (along with the unminified one) like it is common with many other modules.

@rowanwins before going and accusing people, please try and minimize drama-queen-acting. I was very literal in my statement. and just like I suggested in this comment you should perfirm a final independent testing on browser distr before publishing a new version.

No-one is drama-queening acting, we're just asking for people to talk nicely to us.

We've acknowledged your issue and taken your feedback on board, I even suspect we'll write those tests as and when time becomes available. Even better would be if you submitted a pull request with the desired tests.

We're truly sorry Turf isn't perfect and that our myriad of tests that do run prior to publishing didn't catch this error but such is life in maintaining big and complicated repos in spare time.

Was this page helpful?
0 / 5 - 0 ratings